Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Unified Diff: mojo/edk/embedder/platform_channel_pair_android.cc

Issue 2549363004: Multiprocess test client: Android child process launcher rework. (Closed)
Patch Set: Fixed tests Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698