OLD | NEW |
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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 Core* g_core; | 36 Core* g_core; |
37 | 37 |
38 Core* GetCore() { return g_core; } | 38 Core* GetCore() { return g_core; } |
39 | 39 |
40 } // namespace internal | 40 } // namespace internal |
41 | 41 |
42 void SetMaxMessageSize(size_t bytes) { | 42 void SetMaxMessageSize(size_t bytes) { |
43 } | 43 } |
44 | 44 |
45 void ChildProcessLaunched(base::ProcessHandle child_process, | |
46 ScopedPlatformHandle server_pipe, | |
47 const std::string& child_token) { | |
48 ChildProcessLaunched(child_process, std::move(server_pipe), | |
49 child_token, ProcessErrorCallback()); | |
50 } | |
51 | |
52 void ChildProcessLaunched(base::ProcessHandle child_process, | |
53 ScopedPlatformHandle server_pipe, | |
54 const std::string& child_token, | |
55 const ProcessErrorCallback& process_error_callback) { | |
56 CHECK(internal::g_core); | |
57 internal::g_core->AddChild(child_process, std::move(server_pipe), | |
58 child_token, process_error_callback); | |
59 } | |
60 | |
61 void ChildProcessLaunchFailed(const std::string& child_token) { | |
62 CHECK(internal::g_core); | |
63 internal::g_core->ChildLaunchFailed(child_token); | |
64 } | |
65 | |
66 void SetParentPipeHandle(ScopedPlatformHandle pipe) { | 45 void SetParentPipeHandle(ScopedPlatformHandle pipe) { |
67 CHECK(internal::g_core); | 46 CHECK(internal::g_core); |
68 internal::g_core->InitChild(std::move(pipe)); | 47 internal::g_core->InitChild(std::move(pipe)); |
69 } | 48 } |
70 | 49 |
71 void SetParentPipeHandleFromCommandLine() { | 50 void SetParentPipeHandleFromCommandLine() { |
72 ScopedPlatformHandle platform_channel = | 51 ScopedPlatformHandle platform_channel = |
73 PlatformChannelPair::PassClientHandleFromParentProcess( | 52 PlatformChannelPair::PassClientHandleFromParentProcess( |
74 *base::CommandLine::ForCurrentProcess()); | 53 *base::CommandLine::ForCurrentProcess()); |
75 CHECK(platform_channel.is_valid()); | 54 CHECK(platform_channel.is_valid()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 internal::g_core->RequestShutdown(callback); | 127 internal::g_core->RequestShutdown(callback); |
149 } | 128 } |
150 | 129 |
151 #if defined(OS_MACOSX) && !defined(OS_IOS) | 130 #if defined(OS_MACOSX) && !defined(OS_IOS) |
152 void SetMachPortProvider(base::PortProvider* port_provider) { | 131 void SetMachPortProvider(base::PortProvider* port_provider) { |
153 DCHECK(port_provider); | 132 DCHECK(port_provider); |
154 internal::g_core->SetMachPortProvider(port_provider); | 133 internal::g_core->SetMachPortProvider(port_provider); |
155 } | 134 } |
156 #endif | 135 #endif |
157 | 136 |
158 ScopedMessagePipeHandle CreateParentMessagePipe( | |
159 const std::string& token, const std::string& child_token) { | |
160 return internal::g_core->CreateParentMessagePipe(token, child_token); | |
161 } | |
162 | |
163 ScopedMessagePipeHandle CreateChildMessagePipe(const std::string& token) { | 137 ScopedMessagePipeHandle CreateChildMessagePipe(const std::string& token) { |
164 return internal::g_core->CreateChildMessagePipe(token); | 138 return internal::g_core->CreateChildMessagePipe(token); |
165 } | 139 } |
166 | 140 |
167 std::string GenerateRandomToken() { | 141 std::string GenerateRandomToken() { |
168 char random_bytes[16]; | 142 char random_bytes[16]; |
169 #if defined(OS_NACL) | 143 #if defined(OS_NACL) |
170 // Not secure. For NaCl only! | 144 // Not secure. For NaCl only! |
171 base::RandBytes(random_bytes, 16); | 145 base::RandBytes(random_bytes, 16); |
172 #else | 146 #else |
173 crypto::RandBytes(random_bytes, 16); | 147 crypto::RandBytes(random_bytes, 16); |
174 #endif | 148 #endif |
175 return base::HexEncode(random_bytes, 16); | 149 return base::HexEncode(random_bytes, 16); |
176 } | 150 } |
177 | 151 |
178 MojoResult SetProperty(MojoPropertyType type, const void* value) { | 152 MojoResult SetProperty(MojoPropertyType type, const void* value) { |
179 CHECK(internal::g_core); | 153 CHECK(internal::g_core); |
180 return internal::g_core->SetProperty(type, value); | 154 return internal::g_core->SetProperty(type, value); |
181 } | 155 } |
182 | 156 |
183 } // namespace edk | 157 } // namespace edk |
184 } // namespace mojo | 158 } // namespace mojo |
OLD | NEW |