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

Side by Side Diff: mojo/edk/embedder/embedder.cc

Issue 2735113003: Changing SpawnChild to return a struct.
Patch Set: Created 3 years, 9 months 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 unified diff | Download patch
« no previous file with comments | « mojo/edk/embedder/connection_param.cc ('k') | mojo/edk/embedder/embedder_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/edk/embedder/embedder.h" 5 #include "mojo/edk/embedder/embedder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/task_runner.h" 16 #include "base/task_runner.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "mojo/edk/embedder/embedder_internal.h" 18 #include "mojo/edk/embedder/embedder_internal.h"
19 #include "mojo/edk/embedder/entrypoints.h" 19 #include "mojo/edk/embedder/entrypoints.h"
20 #include "mojo/edk/embedder/platform_channel_pair.h" 20 #include "mojo/edk/embedder/platform_channel_pair.h"
21 #include "mojo/edk/system/core.h" 21 #include "mojo/edk/system/core.h"
22 #include "mojo/edk/system/node_controller.h" 22 #include "mojo/edk/system/node_controller.h"
23 23
24 #if defined(OS_ANDROID)
25 #include "base/android/global_object_registry.h"
26 #include "base/android/jni_android.h"
27 #include "base/android/parcelable_channel_client.h"
28 #include "base/android/parcelable_channel_server.h"
29 #include "base/android/scoped_java_ref.h"
30 #endif
31
24 #if !defined(OS_NACL) 32 #if !defined(OS_NACL)
25 #include "crypto/random.h" 33 #include "crypto/random.h"
26 #endif 34 #endif
27 35
28 namespace mojo { 36 namespace mojo {
29 namespace edk { 37 namespace edk {
30 38
31 class Core; 39 class Core;
32 class PlatformSupport; 40 class PlatformSupport;
33 41
42 namespace {
43 #if defined(OS_ANDROID)
44 const int kParcelableChannelClientID = 1;
45 const int kParcelableChannelServerID = 2;
46 #endif
47 } // namespace
48
34 namespace internal { 49 namespace internal {
35 50
36 Core* g_core; 51 Core* g_core;
37 52
38 Core* GetCore() { return g_core; } 53 Core* GetCore() { return g_core; }
39 54
40 } // namespace internal 55 } // namespace internal
41 56
42 void SetMaxMessageSize(size_t bytes) { 57 void SetMaxMessageSize(size_t bytes) {
43 } 58 }
44 59
45 void SetParentPipeHandle(ScopedPlatformHandle pipe) { 60 void SetParentPipeHandle(ScopedPlatformHandle pipe) {
46 CHECK(internal::g_core); 61 CHECK(internal::g_core);
47 internal::g_core->InitChild(std::move(pipe)); 62 #if defined(OS_ANDROID)
63 base::android::GlobalObjectRegistry* object_registry =
64 base::android::GlobalObjectRegistry::GetInstance();
65
66 base::android::ParcelableChannelClient parcelable_channel_client(
67 object_registry->Take(kParcelableChannelClientID));
68 base::android::ParcelableChannelServer parcelable_channel_server(
69 object_registry->Take(kParcelableChannelServerID));
70
71 ConnectionParam connection_param(std::move(pipe),
72 std::move(parcelable_channel_client),
73 std::move(parcelable_channel_server));
74 #else
75 ConnectionParam connection_param(std::move(pipe));
76 #endif
77 internal::g_core->InitChild(std::move(connection_param));
48 } 78 }
49 79
50 void SetParentPipeHandleFromCommandLine() { 80 void SetParentPipeHandleFromCommandLine() {
51 ScopedPlatformHandle platform_channel = 81 ScopedPlatformHandle platform_channel =
52 PlatformChannelPair::PassClientHandleFromParentProcess( 82 PlatformChannelPair::PassClientHandleFromParentProcess(
53 *base::CommandLine::ForCurrentProcess()); 83 *base::CommandLine::ForCurrentProcess());
54 CHECK(platform_channel.is_valid()); 84 CHECK(platform_channel.is_valid());
55 SetParentPipeHandle(std::move(platform_channel)); 85 SetParentPipeHandle(std::move(platform_channel));
56 } 86 }
57 87
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return base::HexEncode(random_bytes, 16); 179 return base::HexEncode(random_bytes, 16);
150 } 180 }
151 181
152 MojoResult SetProperty(MojoPropertyType type, const void* value) { 182 MojoResult SetProperty(MojoPropertyType type, const void* value) {
153 CHECK(internal::g_core); 183 CHECK(internal::g_core);
154 return internal::g_core->SetProperty(type, value); 184 return internal::g_core->SetProperty(type, value);
155 } 185 }
156 186
157 } // namespace edk 187 } // namespace edk
158 } // namespace mojo 188 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/embedder/connection_param.cc ('k') | mojo/edk/embedder/embedder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698