Index: mojo/edk/embedder/platform_channel_pair_android.cc |
diff --git a/mojo/edk/embedder/platform_channel_pair_android.cc b/mojo/edk/embedder/platform_channel_pair_android.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..00dcb3f19a34ef7967f63fff327922adc77a6dd9 |
--- /dev/null |
+++ b/mojo/edk/embedder/platform_channel_pair_android.cc |
@@ -0,0 +1,37 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
Ken Rockot(use gerrit already)
2016/12/12 22:23:08
nit: I think it might be less confusing to just lu
Jay Civelli
2016/12/13 18:23:25
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "mojo/edk/embedder/platform_channel_pair.h" |
+ |
+#include "base/posix/global_descriptors.h" |
+#include "base/strings/string_number_conversions.h" |
+ |
+namespace mojo { |
+namespace edk { |
+ |
+std::string |
+PlatformChannelPair::PrepareToPassClientHandleToChildProcessAsString( |
+ HandlePassingInformation* handle_passing_info) const { |
+ int fd = client_handle_.get().handle; |
+ base::GlobalDescriptors::Key fd_id = |
+ base::GlobalDescriptors::GetInstance()->Register(fd); |
+ handle_passing_info->push_back(std::pair<int, int>(fd, fd_id)); |
+ return base::UintToString(fd_id); |
+} |
+ |
+// static |
+ScopedPlatformHandle |
+PlatformChannelPair::PassClientHandleFromParentProcessFromString( |
+ const std::string& value) { |
+ base::GlobalDescriptors::Key fd_id = -1; |
+ if (value.empty() || !base::StringToUint(value, &fd_id)) { |
+ LOG(ERROR) << "Missing or invalid --" << kMojoPlatformChannelHandleSwitch; |
+ return ScopedPlatformHandle(); |
+ } |
+ int fd = base::GlobalDescriptors::GetInstance()->Get(fd_id); |
+ return ScopedPlatformHandle(PlatformHandle(fd)); |
+} |
+ |
+} // namespace edk |
+} // namespace mojo |