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/web_contents/web_contents_impl.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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 packaged_services_connection_->GetConnector()->StartService( | 299 packaged_services_connection_->GetConnector()->StartService( |
299 service_manager::Identity(mojom::kBrowserServiceName, | 300 service_manager::Identity(mojom::kBrowserServiceName, |
300 service_manager::mojom::kRootUserID), | 301 service_manager::mojom::kRootUserID), |
301 std::move(root_browser_service), mojo::MakeRequest(&pid_receiver)); | 302 std::move(root_browser_service), mojo::MakeRequest(&pid_receiver)); |
302 pid_receiver->SetPID(base::GetCurrentProcId()); | 303 pid_receiver->SetPID(base::GetCurrentProcId()); |
303 | 304 |
304 packaged_services_connection_->Start(); | 305 packaged_services_connection_->Start(); |
305 ServiceManagerConnection::GetForProcess()->Start(); | 306 ServiceManagerConnection::GetForProcess()->Start(); |
306 | 307 |
307 ServiceInfo device_info; | 308 ServiceInfo device_info; |
| 309 #if defined(OS_ANDROID) |
| 310 device_info.factory = |
| 311 base::Bind(&device::CreateDeviceService, |
| 312 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), |
| 313 base::Bind(&WebContentsImpl::GetNativeViewForWebContents)); |
| 314 #else |
308 device_info.factory = | 315 device_info.factory = |
309 base::Bind(&device::CreateDeviceService, | 316 base::Bind(&device::CreateDeviceService, |
310 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); | 317 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); |
| 318 #endif |
311 packaged_services_connection_->AddEmbeddedService(device::mojom::kServiceName, | 319 packaged_services_connection_->AddEmbeddedService(device::mojom::kServiceName, |
312 device_info); | 320 device_info); |
313 | 321 |
314 ContentBrowserClient::StaticServiceMap services; | 322 ContentBrowserClient::StaticServiceMap services; |
315 GetContentClient()->browser()->RegisterInProcessServices(&services); | 323 GetContentClient()->browser()->RegisterInProcessServices(&services); |
316 for (const auto& entry : services) { | 324 for (const auto& entry : services) { |
317 packaged_services_connection_->AddEmbeddedService(entry.first, | 325 packaged_services_connection_->AddEmbeddedService(entry.first, |
318 entry.second); | 326 entry.second); |
319 } | 327 } |
320 | 328 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 base::Bind(&DestroyConnectorOnIOThread)); | 374 base::Bind(&DestroyConnectorOnIOThread)); |
367 } | 375 } |
368 | 376 |
369 // static | 377 // static |
370 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { | 378 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { |
371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 379 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
372 return g_io_thread_connector.Get().get(); | 380 return g_io_thread_connector.Get().get(); |
373 } | 381 } |
374 | 382 |
375 } // namespace content | 383 } // namespace content |
OLD | NEW |