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

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: ServiceManagerContext does not hold the connection to device service 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/file/public/interfaces/constants.mojom.h" 35 #include "services/file/public/interfaces/constants.mojom.h"
34 #include "services/service_manager/connect_params.h" 36 #include "services/service_manager/connect_params.h"
35 #include "services/service_manager/public/cpp/connector.h" 37 #include "services/service_manager/public/cpp/connector.h"
36 #include "services/service_manager/public/cpp/service.h" 38 #include "services/service_manager/public/cpp/service.h"
37 #include "services/service_manager/public/interfaces/service.mojom.h" 39 #include "services/service_manager/public/interfaces/service.mojom.h"
38 #include "services/service_manager/runner/common/client_util.h" 40 #include "services/service_manager/runner/common/client_util.h"
39 #include "services/service_manager/service_manager.h" 41 #include "services/service_manager/service_manager.h"
40 42
41 namespace content { 43 namespace content {
42 44
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 manifest_provider->AddServiceManifest(manifest.name, 269 manifest_provider->AddServiceManifest(manifest.name,
268 manifest.resource_id); 270 manifest.resource_id);
269 } 271 }
270 in_process_context_ = new InProcessServiceManagerContext; 272 in_process_context_ = new InProcessServiceManagerContext;
271 request = in_process_context_->Start(std::move(manifest_provider)); 273 request = in_process_context_->Start(std::move(manifest_provider));
272 } 274 }
273 ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create( 275 ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create(
274 std::move(request), 276 std::move(request),
275 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); 277 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)));
276 278
279 // Registers the singletion device service to be embedded by browser service
280 // for now.
blundell 2017/01/06 12:28:09 I would eliminate this comment; I don't think it a
leonhsl(Using Gerrit) 2017/01/06 14:36:00 Done.
281 ServiceInfo device_info;
282 device_info.factory =
283 base::Bind(&device::CreateDeviceService,
284 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE));
285 ServiceManagerConnection::GetForProcess()->AddEmbeddedService(
286 device::mojom::kServiceName, device_info);
287
277 ContentBrowserClient::StaticServiceMap services; 288 ContentBrowserClient::StaticServiceMap services;
278 GetContentClient()->browser()->RegisterInProcessServices(&services); 289 GetContentClient()->browser()->RegisterInProcessServices(&services);
279 for (const auto& entry : services) { 290 for (const auto& entry : services) {
280 ServiceManagerConnection::GetForProcess()->AddEmbeddedService(entry.first, 291 ServiceManagerConnection::GetForProcess()->AddEmbeddedService(entry.first,
281 entry.second); 292 entry.second);
282 } 293 }
283 294
284 // This is safe to assign directly from any thread, because 295 // This is safe to assign directly from any thread, because
285 // ServiceManagerContext must be constructed before anyone can call 296 // ServiceManagerContext must be constructed before anyone can call
286 // GetConnectorForIOThread(). 297 // GetConnectorForIOThread().
(...skipping 21 matching lines...) Expand all
308 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler( 319 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler(
309 service.first, 320 service.first,
310 base::Bind(&StartServiceInUtilityProcess, service.first, service.second, 321 base::Bind(&StartServiceInUtilityProcess, service.first, service.second,
311 false /* use_sandbox */)); 322 false /* use_sandbox */));
312 } 323 }
313 324
314 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) 325 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS)
315 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler( 326 ServiceManagerConnection::GetForProcess()->AddServiceRequestHandler(
316 "media", base::Bind(&StartServiceInGpuProcess, "media")); 327 "media", base::Bind(&StartServiceInGpuProcess, "media"));
317 #endif 328 #endif
329
330 // Initiates the first connection to device service to create the singleton
331 // instance, later the same instance will serve all the clients wanting to
blundell 2017/01/06 12:28:09 Add below this: TODO(rockot): Eliminate this conn
leonhsl(Using Gerrit) 2017/01/06 14:36:00 OK I added a task to Ken :) Done.
332 // connect to device service.
333 std::unique_ptr<service_manager::Connection> device_connection =
334 ServiceManagerConnection::GetForProcess()->GetConnector()->Connect(
335 device::mojom::kServiceName);
318 } 336 }
319 337
320 ServiceManagerContext::~ServiceManagerContext() { 338 ServiceManagerContext::~ServiceManagerContext() {
321 // NOTE: The in-process ServiceManager MUST be destroyed before the browser 339 // NOTE: The in-process ServiceManager MUST be destroyed before the browser
322 // process-wide ServiceManagerConnection. Otherwise it's possible for the 340 // process-wide ServiceManagerConnection. Otherwise it's possible for the
323 // ServiceManager to receive connection requests for service:content_browser 341 // ServiceManager to receive connection requests for service:content_browser
324 // which it may attempt to service by launching a new instance of the browser. 342 // which it may attempt to service by launching a new instance of the browser.
325 if (in_process_context_) 343 if (in_process_context_)
326 in_process_context_->ShutDown(); 344 in_process_context_->ShutDown();
327 if (ServiceManagerConnection::GetForProcess()) 345 if (ServiceManagerConnection::GetForProcess())
328 ServiceManagerConnection::DestroyForProcess(); 346 ServiceManagerConnection::DestroyForProcess();
329 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 347 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
330 base::Bind(&DestroyConnectorOnIOThread)); 348 base::Bind(&DestroyConnectorOnIOThread));
331 } 349 }
332 350
333 // static 351 // static
334 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { 352 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() {
335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
336 return g_io_thread_connector.Get().get(); 354 return g_io_thread_connector.Get().get();
337 } 355 }
338 356
339 } // namespace content 357 } // 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