| 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 "base/atomicops.h" | 7 #include "base/atomicops.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "mojo/edk/system/child_broker.h" | 21 #include "mojo/edk/system/child_broker.h" |
| 22 #include "mojo/edk/system/child_broker_host.h" | 22 #include "mojo/edk/system/child_broker_host.h" |
| 23 #include "mojo/edk/system/configuration.h" | 23 #include "mojo/edk/system/configuration.h" |
| 24 #include "mojo/edk/system/core.h" | 24 #include "mojo/edk/system/core.h" |
| 25 #include "mojo/edk/system/message_pipe_dispatcher.h" | 25 #include "mojo/edk/system/message_pipe_dispatcher.h" |
| 26 #include "mojo/edk/system/platform_handle_dispatcher.h" | 26 #include "mojo/edk/system/platform_handle_dispatcher.h" |
| 27 | 27 |
| 28 namespace mojo { | 28 namespace mojo { |
| 29 namespace edk { | 29 namespace edk { |
| 30 | 30 |
| 31 namespace { | |
| 32 | |
| 33 // Note: Called on the I/O thread. | |
| 34 void ShutdownIPCSupportHelper() { | |
| 35 } | |
| 36 | |
| 37 } // namespace | |
| 38 | |
| 39 namespace internal { | 31 namespace internal { |
| 40 | 32 |
| 41 // Declared in embedder_internal.h. | 33 // Declared in embedder_internal.h. |
| 42 Broker* g_broker = nullptr; | 34 Broker* g_broker = nullptr; |
| 43 PlatformSupport* g_platform_support = nullptr; | 35 PlatformSupport* g_platform_support = nullptr; |
| 44 Core* g_core = nullptr; | 36 Core* g_core = nullptr; |
| 45 | 37 |
| 46 ProcessDelegate* g_process_delegate; | 38 ProcessDelegate* g_process_delegate; |
| 47 base::TaskRunner* g_io_thread_task_runner = nullptr; | 39 base::TaskRunner* g_io_thread_task_runner = nullptr; |
| 48 | 40 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // |Init()| must have already been called. | 135 // |Init()| must have already been called. |
| 144 DCHECK(internal::g_core); | 136 DCHECK(internal::g_core); |
| 145 internal::g_process_delegate = process_delegate; | 137 internal::g_process_delegate = process_delegate; |
| 146 internal::g_io_thread_task_runner = io_thread_task_runner.get(); | 138 internal::g_io_thread_task_runner = io_thread_task_runner.get(); |
| 147 } | 139 } |
| 148 | 140 |
| 149 void ShutdownIPCSupportOnIOThread() { | 141 void ShutdownIPCSupportOnIOThread() { |
| 150 } | 142 } |
| 151 | 143 |
| 152 void ShutdownIPCSupport() { | 144 void ShutdownIPCSupport() { |
| 153 internal::g_io_thread_task_runner->PostTaskAndReply( | 145 // TODO(jam): remove ProcessDelegate from new EDK once the old EDK is gone. |
| 154 FROM_HERE, | 146 internal::g_process_delegate->OnShutdownComplete(); |
| 155 base::Bind(&ShutdownIPCSupportHelper), | |
| 156 base::Bind(&ProcessDelegate::OnShutdownComplete, | |
| 157 base::Unretained(internal::g_process_delegate))); | |
| 158 } | 147 } |
| 159 | 148 |
| 160 ScopedMessagePipeHandle CreateMessagePipe( | 149 ScopedMessagePipeHandle CreateMessagePipe( |
| 161 ScopedPlatformHandle platform_handle) { | 150 ScopedPlatformHandle platform_handle) { |
| 162 MojoCreateMessagePipeOptions options = { | 151 MojoCreateMessagePipeOptions options = { |
| 163 static_cast<uint32_t>(sizeof(MojoCreateMessagePipeOptions)), | 152 static_cast<uint32_t>(sizeof(MojoCreateMessagePipeOptions)), |
| 164 MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_TRANSFERABLE}; | 153 MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_TRANSFERABLE}; |
| 165 scoped_refptr<MessagePipeDispatcher> dispatcher = | 154 scoped_refptr<MessagePipeDispatcher> dispatcher = |
| 166 MessagePipeDispatcher::Create(options); | 155 MessagePipeDispatcher::Create(options); |
| 167 | 156 |
| 168 ScopedMessagePipeHandle rv( | 157 ScopedMessagePipeHandle rv( |
| 169 MessagePipeHandle(internal::g_core->AddDispatcher(dispatcher))); | 158 MessagePipeHandle(internal::g_core->AddDispatcher(dispatcher))); |
| 170 CHECK(rv.is_valid()); | 159 CHECK(rv.is_valid()); |
| 171 dispatcher->Init(platform_handle.Pass(), nullptr, 0, nullptr, 0, nullptr, | 160 dispatcher->Init(platform_handle.Pass(), nullptr, 0, nullptr, 0, nullptr, |
| 172 nullptr); | 161 nullptr); |
| 173 // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it | 162 // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it |
| 174 // once that's fixed. | 163 // once that's fixed. |
| 175 return rv.Pass(); | 164 return rv.Pass(); |
| 176 } | 165 } |
| 177 | 166 |
| 178 } // namespace edk | 167 } // namespace edk |
| 179 } // namespace mojo | 168 } // namespace mojo |
| OLD | NEW |