mojo: expose [Un]WrapPlatformSharedMemoryRegion

This enables transitional mojo interfaces that communicate in
base::subtle::PlatformSharedMemoryRegion to interoperate with interfaces
that use a mojo handle<shared_buffer>.

Bug: 849207, 640840
Change-Id: I759a0115d1b677ebcbd335997553b705f61f00a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1570829
Reviewed-by: Ken Rockot <rockot@google.com>
Commit-Queue: Matthew Cary <mattcary@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652083}
diff --git a/mojo/public/cpp/system/platform_handle.cc b/mojo/public/cpp/system/platform_handle.cc
index 9e55f550..f00df808 100644
--- a/mojo/public/cpp/system/platform_handle.cc
+++ b/mojo/public/cpp/system/platform_handle.cc
@@ -33,6 +33,8 @@
 #endif
 }
 
+}  // namespace
+
 ScopedSharedBufferHandle WrapPlatformSharedMemoryRegion(
     base::subtle::PlatformSharedMemoryRegion region) {
   if (!region.IsValid())
@@ -177,8 +179,6 @@
       base::UnguessableToken::Deserialize(mojo_guid.high, mojo_guid.low));
 }
 
-}  // namespace
-
 ScopedHandle WrapPlatformHandle(PlatformHandle handle) {
   MojoPlatformHandle platform_handle;
   PlatformHandle::ToMojoPlatformHandle(std::move(handle), &platform_handle);
diff --git a/mojo/public/cpp/system/platform_handle.h b/mojo/public/cpp/system/platform_handle.h
index b18ceaf..5134275 100644
--- a/mojo/public/cpp/system/platform_handle.h
+++ b/mojo/public/cpp/system/platform_handle.h
@@ -76,6 +76,14 @@
   kReadOnly,
 };
 
+// Wraps and unwraps base::subtle::PlatformSharedMemoryRegions. This should be
+// used only while transitioning from the legacy shared memory API. In new code
+// only base::*SharedMemoryRegion should be used instead.
+ScopedSharedBufferHandle WrapPlatformSharedMemoryRegion(
+    base::subtle::PlatformSharedMemoryRegion region);
+base::subtle::PlatformSharedMemoryRegion UnwrapPlatformSharedMemoryRegion(
+    ScopedSharedBufferHandle mojo_handle);
+
 // Wraps a PlatformHandle from the C++ platform support library as a Mojo
 // handle.
 MOJO_CPP_SYSTEM_EXPORT ScopedHandle WrapPlatformHandle(PlatformHandle handle);