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