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

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

Issue 2734943003: Device Service: Decouple Wake Lock from //content (Closed)
Patch Set: Rebase Created 3 years, 9 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 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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/process/process_handle.h" 16 #include "base/process/process_handle.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "content/browser/child_process_launcher.h" 19 #include "content/browser/child_process_launcher.h"
20 #include "content/browser/gpu/gpu_process_host.h" 20 #include "content/browser/gpu/gpu_process_host.h"
21 #include "content/browser/service_manager/merge_dictionary.h" 21 #include "content/browser/service_manager/merge_dictionary.h"
22 #include "content/browser/wake_lock/wake_lock_context_host.h"
22 #include "content/common/service_manager/service_manager_connection_impl.h" 23 #include "content/common/service_manager/service_manager_connection_impl.h"
23 #include "content/grit/content_resources.h" 24 #include "content/grit/content_resources.h"
24 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/content_browser_client.h" 26 #include "content/public/browser/content_browser_client.h"
26 #include "content/public/browser/utility_process_host.h" 27 #include "content/public/browser/utility_process_host.h"
27 #include "content/public/browser/utility_process_host_client.h" 28 #include "content/public/browser/utility_process_host_client.h"
28 #include "content/public/common/content_client.h" 29 #include "content/public/common/content_client.h"
29 #include "content/public/common/service_manager_connection.h" 30 #include "content/public/common/service_manager_connection.h"
30 #include "content/public/common/service_names.mojom.h" 31 #include "content/public/common/service_names.mojom.h"
31 #include "mojo/edk/embedder/embedder.h" 32 #include "mojo/edk/embedder/embedder.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 277
277 service_manager::mojom::PIDReceiverPtr pid_receiver; 278 service_manager::mojom::PIDReceiverPtr pid_receiver;
278 packaged_services_connection_->GetConnector()->StartService( 279 packaged_services_connection_->GetConnector()->StartService(
279 service_manager::Identity(mojom::kBrowserServiceName, 280 service_manager::Identity(mojom::kBrowserServiceName,
280 service_manager::mojom::kRootUserID), 281 service_manager::mojom::kRootUserID),
281 std::move(root_browser_service), mojo::MakeRequest(&pid_receiver)); 282 std::move(root_browser_service), mojo::MakeRequest(&pid_receiver));
282 pid_receiver->SetPID(base::GetCurrentProcId()); 283 pid_receiver->SetPID(base::GetCurrentProcId());
283 284
284 285
285 ServiceInfo device_info; 286 ServiceInfo device_info;
287 #if defined(OS_ANDROID)
288 // See the comments on wake_lock_context_host.h for details on this
289 // callback.
290 device_info.factory =
291 base::Bind(&device::CreateDeviceService,
292 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
293 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
294 base::Bind(&WakeLockContextHost::GetNativeViewForContext));
295 #else
286 device_info.factory = 296 device_info.factory =
287 base::Bind(&device::CreateDeviceService, 297 base::Bind(&device::CreateDeviceService,
288 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), 298 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
289 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); 299 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO));
300 #endif
290 device_info.task_runner = base::ThreadTaskRunnerHandle::Get(); 301 device_info.task_runner = base::ThreadTaskRunnerHandle::Get();
291 packaged_services_connection_->AddEmbeddedService(device::mojom::kServiceName, 302 packaged_services_connection_->AddEmbeddedService(device::mojom::kServiceName,
292 device_info); 303 device_info);
293 304
294 ContentBrowserClient::StaticServiceMap services; 305 ContentBrowserClient::StaticServiceMap services;
295 GetContentClient()->browser()->RegisterInProcessServices(&services); 306 GetContentClient()->browser()->RegisterInProcessServices(&services);
296 for (const auto& entry : services) { 307 for (const auto& entry : services) {
297 packaged_services_connection_->AddEmbeddedService(entry.first, 308 packaged_services_connection_->AddEmbeddedService(entry.first,
298 entry.second); 309 entry.second);
299 } 310 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 base::Bind(&DestroyConnectorOnIOThread)); 362 base::Bind(&DestroyConnectorOnIOThread));
352 } 363 }
353 364
354 // static 365 // static
355 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { 366 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() {
356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
357 return g_io_thread_connector.Get().get(); 368 return g_io_thread_connector.Get().get();
358 } 369 }
359 370
360 } // namespace content 371 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698