OLD | NEW |
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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 278 |
278 service_manager::mojom::PIDReceiverPtr pid_receiver; | 279 service_manager::mojom::PIDReceiverPtr pid_receiver; |
279 packaged_services_connection_->GetConnector()->StartService( | 280 packaged_services_connection_->GetConnector()->StartService( |
280 service_manager::Identity(mojom::kBrowserServiceName, | 281 service_manager::Identity(mojom::kBrowserServiceName, |
281 service_manager::mojom::kRootUserID), | 282 service_manager::mojom::kRootUserID), |
282 std::move(root_browser_service), mojo::MakeRequest(&pid_receiver)); | 283 std::move(root_browser_service), mojo::MakeRequest(&pid_receiver)); |
283 pid_receiver->SetPID(base::GetCurrentProcId()); | 284 pid_receiver->SetPID(base::GetCurrentProcId()); |
284 | 285 |
285 | 286 |
286 ServiceInfo device_info; | 287 ServiceInfo device_info; |
| 288 #if defined(OS_ANDROID) |
| 289 // See the comments on wake_lock_context_host.h for details on this |
| 290 // callback. |
| 291 device_info.factory = |
| 292 base::Bind(&device::CreateDeviceService, |
| 293 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), |
| 294 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), |
| 295 base::Bind(&WakeLockContextHost::GetNativeViewForContext)); |
| 296 #else |
287 device_info.factory = | 297 device_info.factory = |
288 base::Bind(&device::CreateDeviceService, | 298 base::Bind(&device::CreateDeviceService, |
289 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), | 299 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), |
290 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); | 300 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); |
| 301 #endif |
291 device_info.task_runner = base::ThreadTaskRunnerHandle::Get(); | 302 device_info.task_runner = base::ThreadTaskRunnerHandle::Get(); |
292 packaged_services_connection_->AddEmbeddedService(device::mojom::kServiceName, | 303 packaged_services_connection_->AddEmbeddedService(device::mojom::kServiceName, |
293 device_info); | 304 device_info); |
294 | 305 |
295 ContentBrowserClient::StaticServiceMap services; | 306 ContentBrowserClient::StaticServiceMap services; |
296 GetContentClient()->browser()->RegisterInProcessServices(&services); | 307 GetContentClient()->browser()->RegisterInProcessServices(&services); |
297 for (const auto& entry : services) { | 308 for (const auto& entry : services) { |
298 packaged_services_connection_->AddEmbeddedService(entry.first, | 309 packaged_services_connection_->AddEmbeddedService(entry.first, |
299 entry.second); | 310 entry.second); |
300 } | 311 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 base::Bind(&DestroyConnectorOnIOThread)); | 366 base::Bind(&DestroyConnectorOnIOThread)); |
356 } | 367 } |
357 | 368 |
358 // static | 369 // static |
359 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { | 370 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { |
360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
361 return g_io_thread_connector.Get().get(); | 372 return g_io_thread_connector.Get().get(); |
362 } | 373 } |
363 | 374 |
364 } // namespace content | 375 } // namespace content |
OLD | NEW |