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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/task_runner.h" | 15 #include "base/task_runner.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
17 #include "mojo/edk/embedder/embedder_internal.h" | 17 #include "mojo/edk/embedder/embedder_internal.h" |
| 18 #include "mojo/edk/embedder/entrypoints.h" |
18 #include "mojo/edk/embedder/platform_channel_pair.h" | 19 #include "mojo/edk/embedder/platform_channel_pair.h" |
19 #include "mojo/edk/embedder/process_delegate.h" | 20 #include "mojo/edk/embedder/process_delegate.h" |
20 #include "mojo/edk/system/core.h" | 21 #include "mojo/edk/system/core.h" |
21 | 22 |
22 #if !defined(OS_NACL) | 23 #if !defined(OS_NACL) |
23 #include "crypto/random.h" | 24 #include "crypto/random.h" |
24 #endif | 25 #endif |
25 | 26 |
26 namespace mojo { | 27 namespace mojo { |
27 namespace edk { | 28 namespace edk { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 62 |
62 void SetParentPipeHandleFromCommandLine() { | 63 void SetParentPipeHandleFromCommandLine() { |
63 ScopedPlatformHandle platform_channel = | 64 ScopedPlatformHandle platform_channel = |
64 PlatformChannelPair::PassClientHandleFromParentProcess( | 65 PlatformChannelPair::PassClientHandleFromParentProcess( |
65 *base::CommandLine::ForCurrentProcess()); | 66 *base::CommandLine::ForCurrentProcess()); |
66 CHECK(platform_channel.is_valid()); | 67 CHECK(platform_channel.is_valid()); |
67 SetParentPipeHandle(std::move(platform_channel)); | 68 SetParentPipeHandle(std::move(platform_channel)); |
68 } | 69 } |
69 | 70 |
70 void Init() { | 71 void Init() { |
| 72 MojoSystemThunks thunks = MakeSystemThunks(); |
| 73 size_t expected_size = MojoEmbedderSetSystemThunks(&thunks); |
| 74 DCHECK_EQ(expected_size, sizeof(thunks)); |
| 75 |
71 internal::g_core = new Core(); | 76 internal::g_core = new Core(); |
72 } | 77 } |
73 | 78 |
74 MojoResult AsyncWait(MojoHandle handle, | 79 MojoResult AsyncWait(MojoHandle handle, |
75 MojoHandleSignals signals, | 80 MojoHandleSignals signals, |
76 const base::Callback<void(MojoResult)>& callback) { | 81 const base::Callback<void(MojoResult)>& callback) { |
77 CHECK(internal::g_core); | 82 CHECK(internal::g_core); |
78 return internal::g_core->AsyncWait(handle, signals, callback); | 83 return internal::g_core->AsyncWait(handle, signals, callback); |
79 } | 84 } |
80 | 85 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // Not secure. For NaCl only! | 159 // Not secure. For NaCl only! |
155 base::RandBytes(random_bytes, 16); | 160 base::RandBytes(random_bytes, 16); |
156 #else | 161 #else |
157 crypto::RandBytes(random_bytes, 16); | 162 crypto::RandBytes(random_bytes, 16); |
158 #endif | 163 #endif |
159 return base::HexEncode(random_bytes, 16); | 164 return base::HexEncode(random_bytes, 16); |
160 } | 165 } |
161 | 166 |
162 } // namespace edk | 167 } // namespace edk |
163 } // namespace mojo | 168 } // namespace mojo |
OLD | NEW |