Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: services/service_manager/standalone/context.cc

Issue 2620633004: Remove mojo::edk::test::ScopedIPCSupport (Closed)
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "services/service_manager/standalone/context.h" 5 #include "services/service_manager/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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 if (!init_params || init_params->init_edk) 143 if (!init_params || init_params->init_edk)
144 EnsureEmbedderIsInitialized(); 144 EnsureEmbedderIsInitialized();
145 145
146 service_manager_runner_ = base::ThreadTaskRunnerHandle::Get(); 146 service_manager_runner_ = base::ThreadTaskRunnerHandle::Get();
147 blocking_pool_ = new base::SequencedWorkerPool( 147 blocking_pool_ = new base::SequencedWorkerPool(
148 kThreadPoolMaxThreads, "blocking_pool", base::TaskPriority::USER_VISIBLE); 148 kThreadPoolMaxThreads, "blocking_pool", base::TaskPriority::USER_VISIBLE);
149 149
150 init_edk_ = !init_params || init_params->init_edk; 150 init_edk_ = !init_params || init_params->init_edk;
151 if (init_edk_) { 151 if (init_edk_) {
152 mojo::edk::InitIPCSupport(this, io_thread_->task_runner().get()); 152 mojo::edk::InitIPCSupport(io_thread_->task_runner().get());
153 #if defined(OS_MACOSX) 153 #if defined(OS_MACOSX)
154 mojo::edk::SetMachPortProvider(MachBroker::GetInstance()->port_provider()); 154 mojo::edk::SetMachPortProvider(MachBroker::GetInstance()->port_provider());
155 #endif 155 #endif
156 } 156 }
157 157
158 std::unique_ptr<ServiceProcessLauncherFactory> 158 std::unique_ptr<ServiceProcessLauncherFactory>
159 service_process_launcher_factory = 159 service_process_launcher_factory =
160 base::MakeUnique<ServiceProcessLauncherFactoryImpl>( 160 base::MakeUnique<ServiceProcessLauncherFactoryImpl>(
161 blocking_pool_.get(), 161 blocking_pool_.get(),
162 init_params ? init_params->service_process_launcher_delegate 162 init_params ? init_params->service_process_launcher_delegate
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // loop shutdown. 236 // loop shutdown.
237 service_manager_.reset(); 237 service_manager_.reset();
238 238
239 DCHECK_EQ(base::ThreadTaskRunnerHandle::Get(), service_manager_runner_); 239 DCHECK_EQ(base::ThreadTaskRunnerHandle::Get(), service_manager_runner_);
240 240
241 // If we didn't initialize the edk we should not shut it down. 241 // If we didn't initialize the edk we should not shut it down.
242 if (!init_edk_) 242 if (!init_edk_)
243 return; 243 return;
244 244
245 TRACE_EVENT0("service_manager", "Context::Shutdown"); 245 TRACE_EVENT0("service_manager", "Context::Shutdown");
246 // Post a task in case OnShutdownComplete is called synchronously. 246 mojo::edk::ShutdownIPCSupport(
247 base::ThreadTaskRunnerHandle::Get()->PostTask( 247 base::Bind(IgnoreResult(&base::TaskRunner::PostTask),
248 FROM_HERE, base::Bind(mojo::edk::ShutdownIPCSupport)); 248 base::ThreadTaskRunnerHandle::Get(), FROM_HERE,
249 base::Bind(&Context::OnShutdownComplete,
250 base::Unretained(this))));
249 // We'll quit when we get OnShutdownComplete(). 251 // We'll quit when we get OnShutdownComplete().
250 base::RunLoop().Run(); 252 base::RunLoop().Run();
251 } 253 }
252 254
253 void Context::OnShutdownComplete() { 255 void Context::OnShutdownComplete() {
254 DCHECK_EQ(base::ThreadTaskRunnerHandle::Get(), service_manager_runner_); 256 DCHECK_EQ(base::ThreadTaskRunnerHandle::Get(), service_manager_runner_);
255 base::MessageLoop::current()->QuitWhenIdle(); 257 base::MessageLoop::current()->QuitWhenIdle();
256 } 258 }
257 259
258 void Context::RunCommandLineApplication() { 260 void Context::RunCommandLineApplication() {
259 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 261 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
260 if (command_line->HasSwitch(kService)) 262 if (command_line->HasSwitch(kService))
261 Run(command_line->GetSwitchValueASCII(kService)); 263 Run(command_line->GetSwitchValueASCII(kService));
262 } 264 }
263 265
264 void Context::Run(const std::string& name) { 266 void Context::Run(const std::string& name) {
265 service_manager_->SetInstanceQuitCallback(base::Bind(&OnInstanceQuit, name)); 267 service_manager_->SetInstanceQuitCallback(base::Bind(&OnInstanceQuit, name));
266 268
267 mojom::InterfaceProviderPtr remote_interfaces; 269 mojom::InterfaceProviderPtr remote_interfaces;
268 mojom::InterfaceProviderPtr local_interfaces; 270 mojom::InterfaceProviderPtr local_interfaces;
269 271
270 std::unique_ptr<ConnectParams> params(new ConnectParams); 272 std::unique_ptr<ConnectParams> params(new ConnectParams);
271 params->set_source(CreateServiceManagerIdentity()); 273 params->set_source(CreateServiceManagerIdentity());
272 params->set_target(Identity(name, mojom::kRootUserID)); 274 params->set_target(Identity(name, mojom::kRootUserID));
273 params->set_remote_interfaces(mojo::MakeRequest(&remote_interfaces)); 275 params->set_remote_interfaces(mojo::MakeRequest(&remote_interfaces));
274 service_manager_->Connect(std::move(params)); 276 service_manager_->Connect(std::move(params));
275 } 277 }
276 278
277 } // namespace service_manager 279 } // namespace service_manager
OLDNEW
« no previous file with comments | « services/service_manager/standalone/context.h ('k') | third_party/WebKit/Source/platform/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698