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" |
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/channel.h" |
21 #include "mojo/edk/system/core.h" | 22 #include "mojo/edk/system/core.h" |
22 #include "mojo/edk/system/node_controller.h" | 23 #include "mojo/edk/system/node_controller.h" |
23 | 24 |
24 #if !defined(OS_NACL) | 25 #if !defined(OS_NACL) |
25 #include "crypto/random.h" | 26 #include "crypto/random.h" |
26 #endif | 27 #endif |
27 | 28 |
28 namespace mojo { | 29 namespace mojo { |
29 namespace edk { | 30 namespace edk { |
30 | 31 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 68 } |
68 | 69 |
69 void ClosePeerConnection(const std::string& peer_token) { | 70 void ClosePeerConnection(const std::string& peer_token) { |
70 return internal::g_core->ClosePeerConnection(peer_token); | 71 return internal::g_core->ClosePeerConnection(peer_token); |
71 } | 72 } |
72 | 73 |
73 void Init() { | 74 void Init() { |
74 MojoSystemThunks thunks = MakeSystemThunks(); | 75 MojoSystemThunks thunks = MakeSystemThunks(); |
75 size_t expected_size = MojoEmbedderSetSystemThunks(&thunks); | 76 size_t expected_size = MojoEmbedderSetSystemThunks(&thunks); |
76 DCHECK_EQ(expected_size, sizeof(thunks)); | 77 DCHECK_EQ(expected_size, sizeof(thunks)); |
77 | 78 #if defined(MOJO_EDK_LEGACY_PROTOCOL) |
| 79 SetUseLegacyTransportProtocol(true); |
| 80 #endif |
78 internal::g_core = new Core(); | 81 internal::g_core = new Core(); |
79 } | 82 } |
80 | 83 |
81 void SetDefaultProcessErrorCallback(const ProcessErrorCallback& callback) { | 84 void SetDefaultProcessErrorCallback(const ProcessErrorCallback& callback) { |
82 internal::g_core->SetDefaultProcessErrorCallback(callback); | 85 internal::g_core->SetDefaultProcessErrorCallback(callback); |
83 } | 86 } |
84 | 87 |
| 88 void SetUseLegacyTransportProtocol(bool use_legacy_protocol) { |
| 89 Channel::Message::SetUseLegacyTransportProtocol(use_legacy_protocol); |
| 90 } |
| 91 |
85 MojoResult CreatePlatformHandleWrapper( | 92 MojoResult CreatePlatformHandleWrapper( |
86 ScopedPlatformHandle platform_handle, | 93 ScopedPlatformHandle platform_handle, |
87 MojoHandle* platform_handle_wrapper_handle) { | 94 MojoHandle* platform_handle_wrapper_handle) { |
88 return internal::g_core->CreatePlatformHandleWrapper( | 95 return internal::g_core->CreatePlatformHandleWrapper( |
89 std::move(platform_handle), platform_handle_wrapper_handle); | 96 std::move(platform_handle), platform_handle_wrapper_handle); |
90 } | 97 } |
91 | 98 |
92 MojoResult PassWrappedPlatformHandle(MojoHandle platform_handle_wrapper_handle, | 99 MojoResult PassWrappedPlatformHandle(MojoHandle platform_handle_wrapper_handle, |
93 ScopedPlatformHandle* platform_handle) { | 100 ScopedPlatformHandle* platform_handle) { |
94 return internal::g_core->PassWrappedPlatformHandle( | 101 return internal::g_core->PassWrappedPlatformHandle( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 return base::HexEncode(random_bytes, 16); | 156 return base::HexEncode(random_bytes, 16); |
150 } | 157 } |
151 | 158 |
152 MojoResult SetProperty(MojoPropertyType type, const void* value) { | 159 MojoResult SetProperty(MojoPropertyType type, const void* value) { |
153 CHECK(internal::g_core); | 160 CHECK(internal::g_core); |
154 return internal::g_core->SetProperty(type, value); | 161 return internal::g_core->SetProperty(type, value); |
155 } | 162 } |
156 | 163 |
157 } // namespace edk | 164 } // namespace edk |
158 } // namespace mojo | 165 } // namespace mojo |
OLD | NEW |