OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shell/standalone/context.h" | 5 #include "mojo/shell/standalone/context.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 "mojo_runner.trace"); | 133 "mojo_runner.trace"); |
134 } | 134 } |
135 | 135 |
136 if (!init_params || init_params->init_edk) | 136 if (!init_params || init_params->init_edk) |
137 EnsureEmbedderIsInitialized(); | 137 EnsureEmbedderIsInitialized(); |
138 | 138 |
139 shell_runner_ = base::MessageLoop::current()->task_runner(); | 139 shell_runner_ = base::MessageLoop::current()->task_runner(); |
140 blocking_pool_ = | 140 blocking_pool_ = |
141 new base::SequencedWorkerPool(kMaxBlockingPoolThreads, "blocking_pool"); | 141 new base::SequencedWorkerPool(kMaxBlockingPoolThreads, "blocking_pool"); |
142 | 142 |
143 if (!init_params || init_params->init_edk) { | 143 init_edk_ = !init_params || init_params->init_edk; |
| 144 if (init_edk_) { |
144 edk::InitIPCSupport(this, io_thread_->task_runner().get()); | 145 edk::InitIPCSupport(this, io_thread_->task_runner().get()); |
145 #if defined(OS_MACOSX) | 146 #if defined(OS_MACOSX) |
146 edk::SetMachPortProvider(MachBroker::GetInstance()->port_provider()); | 147 edk::SetMachPortProvider(MachBroker::GetInstance()->port_provider()); |
147 #endif | 148 #endif |
148 } | 149 } |
149 | 150 |
150 scoped_ptr<NativeRunnerFactory> runner_factory; | 151 scoped_ptr<NativeRunnerFactory> runner_factory; |
151 if (command_line.HasSwitch(switches::kSingleProcess)) { | 152 if (command_line.HasSwitch(switches::kSingleProcess)) { |
152 #if defined(COMPONENT_BUILD) | 153 #if defined(COMPONENT_BUILD) |
153 LOG(ERROR) << "Running Mojo in single process component build, which isn't " | 154 LOG(ERROR) << "Running Mojo in single process component build, which isn't " |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 collector->SetShellMainEntryPointTime(main_entry_time_.ToInternalValue()); | 204 collector->SetShellMainEntryPointTime(main_entry_time_.ToInternalValue()); |
204 } | 205 } |
205 } | 206 } |
206 | 207 |
207 void Context::Shutdown() { | 208 void Context::Shutdown() { |
208 // Actions triggered by Shell's destructor may require a current message loop, | 209 // Actions triggered by Shell's destructor may require a current message loop, |
209 // so we should destruct it explicitly now as ~Context() occurs post message | 210 // so we should destruct it explicitly now as ~Context() occurs post message |
210 // loop shutdown. | 211 // loop shutdown. |
211 shell_.reset(); | 212 shell_.reset(); |
212 | 213 |
| 214 DCHECK_EQ(base::MessageLoop::current()->task_runner(), shell_runner_); |
| 215 |
| 216 // If we didn't initialize the edk we should not shut it down. |
| 217 if (!init_edk_) |
| 218 return; |
| 219 |
213 TRACE_EVENT0("mojo_shell", "Context::Shutdown"); | 220 TRACE_EVENT0("mojo_shell", "Context::Shutdown"); |
214 DCHECK_EQ(base::MessageLoop::current()->task_runner(), shell_runner_); | |
215 // Post a task in case OnShutdownComplete is called synchronously. | 221 // Post a task in case OnShutdownComplete is called synchronously. |
216 base::MessageLoop::current()->PostTask(FROM_HERE, | 222 base::MessageLoop::current()->PostTask(FROM_HERE, |
217 base::Bind(edk::ShutdownIPCSupport)); | 223 base::Bind(edk::ShutdownIPCSupport)); |
218 // We'll quit when we get OnShutdownComplete(). | 224 // We'll quit when we get OnShutdownComplete(). |
219 base::MessageLoop::current()->Run(); | 225 base::MessageLoop::current()->Run(); |
220 } | 226 } |
221 | 227 |
222 void Context::OnShutdownComplete() { | 228 void Context::OnShutdownComplete() { |
223 DCHECK_EQ(base::MessageLoop::current()->task_runner(), shell_runner_); | 229 DCHECK_EQ(base::MessageLoop::current()->task_runner(), shell_runner_); |
224 base::MessageLoop::current()->QuitWhenIdle(); | 230 base::MessageLoop::current()->QuitWhenIdle(); |
(...skipping 24 matching lines...) Expand all Loading... |
249 scoped_ptr<ConnectParams> params(new ConnectParams); | 255 scoped_ptr<ConnectParams> params(new ConnectParams); |
250 params->set_source(CreateShellIdentity()); | 256 params->set_source(CreateShellIdentity()); |
251 params->set_target(Identity(name, mojom::kRootUserID)); | 257 params->set_target(Identity(name, mojom::kRootUserID)); |
252 params->set_remote_interfaces(GetProxy(&remote_interfaces)); | 258 params->set_remote_interfaces(GetProxy(&remote_interfaces)); |
253 params->set_local_interfaces(std::move(local_interfaces)); | 259 params->set_local_interfaces(std::move(local_interfaces)); |
254 shell_->Connect(std::move(params)); | 260 shell_->Connect(std::move(params)); |
255 } | 261 } |
256 | 262 |
257 } // namespace shell | 263 } // namespace shell |
258 } // namespace mojo | 264 } // namespace mojo |
OLD | NEW |