| 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/location.h" | 11 #include "base/location.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 14 #include "base/task_runner.h" | 15 #include "base/task_runner.h" |
| 15 #include "mojo/edk/embedder/embedder_internal.h" | 16 #include "mojo/edk/embedder/embedder_internal.h" |
| 16 #include "mojo/edk/embedder/platform_channel_pair.h" | 17 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 17 #include "mojo/edk/embedder/process_delegate.h" | 18 #include "mojo/edk/embedder/process_delegate.h" |
| 18 #include "mojo/edk/embedder/simple_platform_support.h" | 19 #include "mojo/edk/embedder/simple_platform_support.h" |
| 19 #include "mojo/edk/system/broker_state.h" | 20 #include "mojo/edk/system/broker_state.h" |
| 20 #include "mojo/edk/system/child_broker.h" | 21 #include "mojo/edk/system/child_broker.h" |
| 21 #include "mojo/edk/system/child_broker_host.h" | 22 #include "mojo/edk/system/child_broker_host.h" |
| 22 #include "mojo/edk/system/configuration.h" | 23 #include "mojo/edk/system/configuration.h" |
| 23 #include "mojo/edk/system/core.h" | 24 #include "mojo/edk/system/core.h" |
| 24 #include "mojo/edk/system/message_pipe_dispatcher.h" | 25 #include "mojo/edk/system/message_pipe_dispatcher.h" |
| 25 #include "mojo/edk/system/platform_handle_dispatcher.h" | 26 #include "mojo/edk/system/platform_handle_dispatcher.h" |
| 26 #include "mojo/edk/system/simple_broker.h" | |
| 27 | 27 |
| 28 namespace mojo { | 28 namespace mojo { |
| 29 namespace edk { | 29 namespace edk { |
| 30 | 30 |
| 31 // TODO(jam): move into annonymous namespace. Keep outside for debugging in VS | 31 // TODO(jam): move into annonymous namespace. Keep outside for debugging in VS |
| 32 // temporarily. | 32 // temporarily. |
| 33 int g_channel_count = 0; | 33 int g_channel_count = 0; |
| 34 bool g_wait_for_no_more_channels = false; | 34 bool g_wait_for_no_more_channels = false; |
| 35 base::TaskRunner* g_delegate_task_runner = nullptr; // Used at shutdown. | 35 base::TaskRunner* g_delegate_task_runner = nullptr; // Used at shutdown. |
| 36 | 36 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 void ChildProcessLaunched(base::ProcessHandle child_process, | 111 void ChildProcessLaunched(base::ProcessHandle child_process, |
| 112 ScopedPlatformHandle server_pipe) { | 112 ScopedPlatformHandle server_pipe) { |
| 113 new ChildBrokerHost(child_process, server_pipe.Pass()); | 113 new ChildBrokerHost(child_process, server_pipe.Pass()); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void SetParentPipeHandle(ScopedPlatformHandle pipe) { | 116 void SetParentPipeHandle(ScopedPlatformHandle pipe) { |
| 117 ChildBroker::GetInstance()->SetChildBrokerHostHandle(pipe.Pass()); | 117 ChildBroker::GetInstance()->SetChildBrokerHostHandle(pipe.Pass()); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void Init() { | 120 void Init() { |
| 121 if (!internal::g_broker) | 121 const base::CommandLine& command_line = |
| 122 internal::g_broker = new SimpleBroker; | 122 *base::CommandLine::ForCurrentProcess(); |
| 123 if (command_line.HasSwitch("use-new-edk") && !internal::g_broker) |
| 124 BrokerState::GetInstance(); |
| 123 | 125 |
| 124 DCHECK(!internal::g_platform_support); | 126 DCHECK(!internal::g_platform_support); |
| 125 internal::g_platform_support = new SimplePlatformSupport(); | 127 internal::g_platform_support = new SimplePlatformSupport(); |
| 126 | 128 |
| 127 DCHECK(!internal::g_core); | 129 DCHECK(!internal::g_core); |
| 128 internal::g_core = new Core(internal::g_platform_support); | 130 internal::g_core = new Core(internal::g_platform_support); |
| 129 } | 131 } |
| 130 | 132 |
| 131 MojoResult AsyncWait(MojoHandle handle, | 133 MojoResult AsyncWait(MojoHandle handle, |
| 132 MojoHandleSignals signals, | 134 MojoHandleSignals signals, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 CHECK(rv.is_valid()); | 210 CHECK(rv.is_valid()); |
| 209 dispatcher->Init(platform_handle.Pass(), nullptr, 0, nullptr, 0, nullptr, | 211 dispatcher->Init(platform_handle.Pass(), nullptr, 0, nullptr, 0, nullptr, |
| 210 nullptr); | 212 nullptr); |
| 211 // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it | 213 // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it |
| 212 // once that's fixed. | 214 // once that's fixed. |
| 213 return rv.Pass(); | 215 return rv.Pass(); |
| 214 } | 216 } |
| 215 | 217 |
| 216 } // namespace edk | 218 } // namespace edk |
| 217 } // namespace mojo | 219 } // namespace mojo |
| OLD | NEW |