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