| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 namespace mojo { | 23 namespace mojo { |
| 24 namespace edk { | 24 namespace edk { |
| 25 | 25 |
| 26 class Core; | 26 class Core; |
| 27 class PlatformSupport; | 27 class PlatformSupport; |
| 28 | 28 |
| 29 namespace internal { | 29 namespace internal { |
| 30 | 30 |
| 31 Core* g_core; | 31 Core* g_core; |
| 32 base::TaskRunner* g_io_thread_task_runner; | |
| 33 PlatformSupport* g_platform_support; | 32 PlatformSupport* g_platform_support; |
| 34 ProcessDelegate* g_process_delegate; | 33 ProcessDelegate* g_process_delegate; |
| 35 | 34 |
| 36 // This is used to help negotiate message pipe connections over arbitrary | 35 // This is used to help negotiate message pipe connections over arbitrary |
| 37 // platform channels. The embedder needs to know which end of the pipe it's on | 36 // platform channels. The embedder needs to know which end of the pipe it's on |
| 38 // so it can do the right thing. | 37 // so it can do the right thing. |
| 39 // | 38 // |
| 40 // TODO: Remove this when people stop using mojo::embedder::CreateChannel() | 39 // TODO: Remove this when people stop using mojo::embedder::CreateChannel() |
| 41 // and thus mojo::edk::CreateMessagePipe(ScopedPlatformHandle). | 40 // and thus mojo::edk::CreateMessagePipe(ScopedPlatformHandle). |
| 42 bool g_is_parent_process = true; | 41 bool g_is_parent_process = true; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 93 |
| 95 MojoResult PassWrappedPlatformHandle(MojoHandle platform_handle_wrapper_handle, | 94 MojoResult PassWrappedPlatformHandle(MojoHandle platform_handle_wrapper_handle, |
| 96 ScopedPlatformHandle* platform_handle) { | 95 ScopedPlatformHandle* platform_handle) { |
| 97 return internal::g_core->PassWrappedPlatformHandle( | 96 return internal::g_core->PassWrappedPlatformHandle( |
| 98 platform_handle_wrapper_handle, platform_handle); | 97 platform_handle_wrapper_handle, platform_handle); |
| 99 } | 98 } |
| 100 | 99 |
| 101 void InitIPCSupport(ProcessDelegate* process_delegate, | 100 void InitIPCSupport(ProcessDelegate* process_delegate, |
| 102 scoped_refptr<base::TaskRunner> io_thread_task_runner) { | 101 scoped_refptr<base::TaskRunner> io_thread_task_runner) { |
| 103 CHECK(internal::g_core); | 102 CHECK(internal::g_core); |
| 104 CHECK(!internal::g_io_thread_task_runner); | |
| 105 internal::g_io_thread_task_runner = io_thread_task_runner.get(); | |
| 106 internal::g_io_thread_task_runner->AddRef(); | |
| 107 | |
| 108 internal::g_core->SetIOTaskRunner(io_thread_task_runner); | 103 internal::g_core->SetIOTaskRunner(io_thread_task_runner); |
| 109 internal::g_process_delegate = process_delegate; | 104 internal::g_process_delegate = process_delegate; |
| 110 } | 105 } |
| 111 | 106 |
| 112 void ShutdownIPCSupportOnIOThread() { | 107 void ShutdownIPCSupportOnIOThread() { |
| 113 } | 108 } |
| 114 | 109 |
| 115 void ShutdownIPCSupport() { | 110 void ShutdownIPCSupport() { |
| 116 CHECK(internal::g_process_delegate); | 111 CHECK(internal::g_process_delegate); |
| 117 CHECK(internal::g_core); | 112 CHECK(internal::g_core); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 149 } |
| 155 | 150 |
| 156 std::string GenerateRandomToken() { | 151 std::string GenerateRandomToken() { |
| 157 char random_bytes[16]; | 152 char random_bytes[16]; |
| 158 crypto::RandBytes(random_bytes, 16); | 153 crypto::RandBytes(random_bytes, 16); |
| 159 return base::HexEncode(random_bytes, 16); | 154 return base::HexEncode(random_bytes, 16); |
| 160 } | 155 } |
| 161 | 156 |
| 162 } // namespace edk | 157 } // namespace edk |
| 163 } // namespace mojo | 158 } // namespace mojo |
| OLD | NEW |