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

Side by Side Diff: content/browser/service_manager/service_manager_context.cc

Issue 2510033002: [Device Service] Move PowerMonitor into the Device Service (Closed)
Patch Set: Rebase only 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
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/child/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/service_manager/service_manager_context.h" 5 #include "content/browser/service_manager/service_manager_context.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 12 matching lines...) Expand all
23 #include "content/public/browser/utility_process_host.h" 23 #include "content/public/browser/utility_process_host.h"
24 #include "content/public/browser/utility_process_host_client.h" 24 #include "content/public/browser/utility_process_host_client.h"
25 #include "content/public/common/content_client.h" 25 #include "content/public/common/content_client.h"
26 #include "content/public/common/service_manager_connection.h" 26 #include "content/public/common/service_manager_connection.h"
27 #include "content/public/common/service_names.mojom.h" 27 #include "content/public/common/service_names.mojom.h"
28 #include "mojo/edk/embedder/embedder.h" 28 #include "mojo/edk/embedder/embedder.h"
29 #include "services/catalog/catalog.h" 29 #include "services/catalog/catalog.h"
30 #include "services/catalog/manifest_provider.h" 30 #include "services/catalog/manifest_provider.h"
31 #include "services/catalog/public/interfaces/constants.mojom.h" 31 #include "services/catalog/public/interfaces/constants.mojom.h"
32 #include "services/catalog/store.h" 32 #include "services/catalog/store.h"
33 #include "services/device/device_service.h"
34 #include "services/device/public/interfaces/constants.mojom.h"
33 #include "services/service_manager/connect_params.h" 35 #include "services/service_manager/connect_params.h"
34 #include "services/service_manager/public/cpp/connector.h" 36 #include "services/service_manager/public/cpp/connector.h"
35 #include "services/service_manager/public/cpp/service.h" 37 #include "services/service_manager/public/cpp/service.h"
36 #include "services/service_manager/public/interfaces/service.mojom.h" 38 #include "services/service_manager/public/interfaces/service.mojom.h"
37 #include "services/service_manager/runner/common/client_util.h" 39 #include "services/service_manager/runner/common/client_util.h"
38 #include "services/service_manager/service_manager.h" 40 #include "services/service_manager/service_manager.h"
39 41
40 namespace content { 42 namespace content {
41 43
42 namespace { 44 namespace {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 manifest_provider->AddServiceManifest(manifest.name, 267 manifest_provider->AddServiceManifest(manifest.name,
266 manifest.resource_id); 268 manifest.resource_id);
267 } 269 }
268 in_process_context_ = new InProcessServiceManagerContext; 270 in_process_context_ = new InProcessServiceManagerContext;
269 request = in_process_context_->Start(std::move(manifest_provider)); 271 request = in_process_context_->Start(std::move(manifest_provider));
270 } 272 }
271 ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create( 273 ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create(
272 std::move(request), 274 std::move(request),
273 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); 275 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)));
274 276
277 ServiceInfo device_info;
278 device_info.factory =
279 base::Bind(&device::CreateDeviceService,
280 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE));
281 ServiceManagerConnection::GetForProcess()->AddEmbeddedService(
282 device::mojom::kServiceName, device_info);
283
275 ContentBrowserClient::StaticServiceMap services; 284 ContentBrowserClient::StaticServiceMap services;
276 GetContentClient()->browser()->RegisterInProcessServices(&services); 285 GetContentClient()->browser()->RegisterInProcessServices(&services);
277 for (const auto& entry : services) { 286 for (const auto& entry : services) {
278 ServiceManagerConnection::GetForProcess()->AddEmbeddedService(entry.first, 287 ServiceManagerConnection::GetForProcess()->AddEmbeddedService(entry.first,
279 entry.second); 288 entry.second);
280 } 289 }
281 290
282 // This is safe to assign directly from any thread, because 291 // This is safe to assign directly from any thread, because
283 // ServiceManagerContext must be constructed before anyone can call 292 // ServiceManagerContext must be constructed before anyone can call
284 // GetConnectorForIOThread(). 293 // GetConnectorForIOThread().
(...skipping 21 matching lines...) Expand all
306 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler( 315 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler(
307 service.first, 316 service.first,
308 base::Bind(&StartServiceInUtilityProcess, service.first, service.second, 317 base::Bind(&StartServiceInUtilityProcess, service.first, service.second,
309 false /* use_sandbox */)); 318 false /* use_sandbox */));
310 } 319 }
311 320
312 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) 321 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS)
313 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler( 322 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler(
314 "media", base::Bind(&StartServiceInGpuProcess, "media")); 323 "media", base::Bind(&StartServiceInGpuProcess, "media"));
315 #endif 324 #endif
325
326 // Initiates the first connection to device service to create the singleton
327 // instance, later the same instance will serve all the clients wanting to
328 // connect to device service.
329 // TODO(rockot): http://crbug.com/679407 Eliminate this connection once
330 // content_browser is itself a singleton service.
331 std::unique_ptr<service_manager::Connection> device_connection =
332 ServiceManagerConnection::GetForProcess()->GetConnector()->Connect(
333 device::mojom::kServiceName);
316 } 334 }
317 335
318 ServiceManagerContext::~ServiceManagerContext() { 336 ServiceManagerContext::~ServiceManagerContext() {
319 // NOTE: The in-process ServiceManager MUST be destroyed before the browser 337 // NOTE: The in-process ServiceManager MUST be destroyed before the browser
320 // process-wide ServiceManagerConnection. Otherwise it's possible for the 338 // process-wide ServiceManagerConnection. Otherwise it's possible for the
321 // ServiceManager to receive connection requests for service:content_browser 339 // ServiceManager to receive connection requests for service:content_browser
322 // which it may attempt to service by launching a new instance of the browser. 340 // which it may attempt to service by launching a new instance of the browser.
323 if (in_process_context_) 341 if (in_process_context_)
324 in_process_context_->ShutDown(); 342 in_process_context_->ShutDown();
325 if (ServiceManagerConnection::GetForProcess()) 343 if (ServiceManagerConnection::GetForProcess())
326 ServiceManagerConnection::DestroyForProcess(); 344 ServiceManagerConnection::DestroyForProcess();
327 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 345 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
328 base::Bind(&DestroyConnectorOnIOThread)); 346 base::Bind(&DestroyConnectorOnIOThread));
329 } 347 }
330 348
331 // static 349 // static
332 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { 350 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() {
333 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 351 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
334 return g_io_thread_connector.Get().get(); 352 return g_io_thread_connector.Get().get();
335 } 353 }
336 354
337 } // namespace content 355 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/child/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698