| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "mojo/edk/embedder/embedder_internal.h" | 11 #include "mojo/edk/embedder/embedder_internal.h" |
| 12 #include "mojo/edk/embedder/master_process_delegate.h" | 12 #include "mojo/edk/embedder/master_process_delegate.h" |
| 13 #include "mojo/edk/embedder/platform_support.h" | 13 #include "mojo/edk/embedder/platform_support.h" |
| 14 #include "mojo/edk/embedder/process_delegate.h" | 14 #include "mojo/edk/embedder/process_delegate.h" |
| 15 #include "mojo/edk/embedder/slave_process_delegate.h" | 15 #include "mojo/edk/embedder/slave_process_delegate.h" |
| 16 #include "mojo/edk/system/channel.h" | 16 #include "mojo/edk/system/channel.h" |
| 17 #include "mojo/edk/system/channel_manager.h" | 17 #include "mojo/edk/system/channel_manager.h" |
| 18 #include "mojo/edk/system/configuration.h" | 18 #include "mojo/edk/system/configuration.h" |
| 19 #include "mojo/edk/system/core.h" | 19 #include "mojo/edk/system/core.h" |
| 20 #include "mojo/edk/system/ipc_support.h" | 20 #include "mojo/edk/system/ipc_support.h" |
| 21 #include "mojo/edk/system/message_pipe_dispatcher.h" | 21 #include "mojo/edk/system/message_pipe_dispatcher.h" |
| 22 #include "mojo/edk/system/platform_handle_dispatcher.h" | 22 #include "mojo/edk/system/platform_handle_dispatcher.h" |
| 23 #include "mojo/edk/system/raw_channel.h" | 23 #include "mojo/edk/system/raw_channel.h" |
| 24 #include "mojo/edk/util/ref_ptr.h" | 24 #include "mojo/edk/util/ref_ptr.h" |
| 25 | 25 |
| 26 using mojo::platform::PlatformHandleWatcher; |
| 26 using mojo::platform::ScopedPlatformHandle; | 27 using mojo::platform::ScopedPlatformHandle; |
| 27 using mojo::platform::TaskRunner; | 28 using mojo::platform::TaskRunner; |
| 28 using mojo::util::RefPtr; | 29 using mojo::util::RefPtr; |
| 29 | 30 |
| 30 namespace mojo { | 31 namespace mojo { |
| 31 namespace embedder { | 32 namespace embedder { |
| 32 | 33 |
| 33 namespace internal { | 34 namespace internal { |
| 34 | 35 |
| 35 // Declared in embedder_internal.h. | 36 // Declared in embedder_internal.h. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 120 |
| 120 *platform_handle = | 121 *platform_handle = |
| 121 static_cast<system::PlatformHandleDispatcher*>(dispatcher.get()) | 122 static_cast<system::PlatformHandleDispatcher*>(dispatcher.get()) |
| 122 ->PassPlatformHandle(); | 123 ->PassPlatformHandle(); |
| 123 return MOJO_RESULT_OK; | 124 return MOJO_RESULT_OK; |
| 124 } | 125 } |
| 125 | 126 |
| 126 void InitIPCSupport(ProcessType process_type, | 127 void InitIPCSupport(ProcessType process_type, |
| 127 RefPtr<TaskRunner>&& delegate_thread_task_runner, | 128 RefPtr<TaskRunner>&& delegate_thread_task_runner, |
| 128 ProcessDelegate* process_delegate, | 129 ProcessDelegate* process_delegate, |
| 129 RefPtr<TaskRunner>&& io_thread_task_runner, | 130 RefPtr<TaskRunner>&& io_task_runner, |
| 131 PlatformHandleWatcher* io_watcher, |
| 130 ScopedPlatformHandle platform_handle) { | 132 ScopedPlatformHandle platform_handle) { |
| 131 // |Init()| must have already been called. | 133 // |Init()| must have already been called. |
| 132 DCHECK(internal::g_core); | 134 DCHECK(internal::g_core); |
| 133 // And not |InitIPCSupport()| (without |ShutdownIPCSupport()|). | 135 // And not |InitIPCSupport()| (without |ShutdownIPCSupport()|). |
| 134 DCHECK(!internal::g_ipc_support); | 136 DCHECK(!internal::g_ipc_support); |
| 135 | 137 |
| 138 // TODO(vtl): Make IPCSUpport also take |io_watcher|. |
| 136 internal::g_ipc_support = new system::IPCSupport( | 139 internal::g_ipc_support = new system::IPCSupport( |
| 137 internal::g_platform_support, process_type, | 140 internal::g_platform_support, process_type, |
| 138 std::move(delegate_thread_task_runner), process_delegate, | 141 std::move(delegate_thread_task_runner), process_delegate, |
| 139 std::move(io_thread_task_runner), platform_handle.Pass()); | 142 std::move(io_task_runner), platform_handle.Pass()); |
| 140 } | 143 } |
| 141 | 144 |
| 142 void ShutdownIPCSupportOnIOThread() { | 145 void ShutdownIPCSupportOnIOThread() { |
| 143 DCHECK(internal::g_ipc_support); | 146 DCHECK(internal::g_ipc_support); |
| 144 | 147 |
| 145 internal::g_ipc_support->ShutdownOnIOThread(); | 148 internal::g_ipc_support->ShutdownOnIOThread(); |
| 146 delete internal::g_ipc_support; | 149 delete internal::g_ipc_support; |
| 147 internal::g_ipc_support = nullptr; | 150 internal::g_ipc_support = nullptr; |
| 148 } | 151 } |
| 149 | 152 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 DCHECK(channel_info); | 304 DCHECK(channel_info); |
| 302 DCHECK(internal::g_ipc_support); | 305 DCHECK(internal::g_ipc_support); |
| 303 | 306 |
| 304 system::ChannelManager* channel_manager = | 307 system::ChannelManager* channel_manager = |
| 305 internal::g_ipc_support->channel_manager(); | 308 internal::g_ipc_support->channel_manager(); |
| 306 channel_manager->WillShutdownChannel(channel_info->channel_id); | 309 channel_manager->WillShutdownChannel(channel_info->channel_id); |
| 307 } | 310 } |
| 308 | 311 |
| 309 } // namespace embedder | 312 } // namespace embedder |
| 310 } // namespace mojo | 313 } // namespace mojo |
| OLD | NEW |