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/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
14 #include "base/task_runner.h" | 15 #include "base/task_runner.h" |
15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
16 #include "crypto/random.h" | |
17 #include "mojo/edk/embedder/embedder_internal.h" | 17 #include "mojo/edk/embedder/embedder_internal.h" |
18 #include "mojo/edk/embedder/platform_channel_pair.h" | 18 #include "mojo/edk/embedder/platform_channel_pair.h" |
19 #include "mojo/edk/embedder/process_delegate.h" | 19 #include "mojo/edk/embedder/process_delegate.h" |
20 #include "mojo/edk/system/core.h" | 20 #include "mojo/edk/system/core.h" |
21 | 21 |
| 22 #if !defined(OS_NACL) |
| 23 #include "crypto/random.h" |
| 24 #endif |
| 25 |
22 namespace mojo { | 26 namespace mojo { |
23 namespace edk { | 27 namespace edk { |
24 | 28 |
25 class Core; | 29 class Core; |
26 class PlatformSupport; | 30 class PlatformSupport; |
27 | 31 |
28 namespace internal { | 32 namespace internal { |
29 | 33 |
30 Core* g_core; | 34 Core* g_core; |
31 ProcessDelegate* g_process_delegate; | 35 ProcessDelegate* g_process_delegate; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 return internal::g_core->CreateParentMessagePipe(token); | 135 return internal::g_core->CreateParentMessagePipe(token); |
132 } | 136 } |
133 | 137 |
134 ScopedMessagePipeHandle CreateChildMessagePipe(const std::string& token) { | 138 ScopedMessagePipeHandle CreateChildMessagePipe(const std::string& token) { |
135 CHECK(internal::g_process_delegate); | 139 CHECK(internal::g_process_delegate); |
136 return internal::g_core->CreateChildMessagePipe(token); | 140 return internal::g_core->CreateChildMessagePipe(token); |
137 } | 141 } |
138 | 142 |
139 std::string GenerateRandomToken() { | 143 std::string GenerateRandomToken() { |
140 char random_bytes[16]; | 144 char random_bytes[16]; |
| 145 #if defined(OS_NACL) |
| 146 // Not secure. For NaCl only! |
| 147 base::RandBytes(random_bytes, 16); |
| 148 #else |
141 crypto::RandBytes(random_bytes, 16); | 149 crypto::RandBytes(random_bytes, 16); |
| 150 #endif |
142 return base::HexEncode(random_bytes, 16); | 151 return base::HexEncode(random_bytes, 16); |
143 } | 152 } |
144 | 153 |
145 } // namespace edk | 154 } // namespace edk |
146 } // namespace mojo | 155 } // namespace mojo |
OLD | NEW |