| 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 <map> |
| 7 #include <memory> | 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <utility> | 10 #include <utility> |
| 10 | 11 |
| 11 #include "base/bind.h" | 12 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 13 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
| 14 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 const base::string16& process_name, | 65 const base::string16& process_name, |
| 65 bool use_sandbox, | 66 bool use_sandbox, |
| 66 service_manager::mojom::ServiceRequest request) { | 67 service_manager::mojom::ServiceRequest request) { |
| 67 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 68 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 68 UtilityProcessHost* process_host = | 69 UtilityProcessHost* process_host = |
| 69 UtilityProcessHost::Create(nullptr, nullptr); | 70 UtilityProcessHost::Create(nullptr, nullptr); |
| 70 process_host->SetName(process_name); | 71 process_host->SetName(process_name); |
| 71 if (!use_sandbox) | 72 if (!use_sandbox) |
| 72 process_host->DisableSandbox(); | 73 process_host->DisableSandbox(); |
| 73 process_host->Start(); | 74 process_host->Start(); |
| 75 // Register mojo interfaces on UI thread. |
| 76 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI) |
| 77 ->PostTask(FROM_HERE, |
| 78 base::Bind(&UtilityProcessHost::RegisterMojoServices, |
| 79 base::Unretained(process_host))); |
| 74 service_manager::mojom::ServiceFactoryPtr service_factory; | 80 service_manager::mojom::ServiceFactoryPtr service_factory; |
| 75 BindInterface(process_host, mojo::MakeRequest(&service_factory)); | 81 BindInterface(process_host, mojo::MakeRequest(&service_factory)); |
| 76 service_factory->CreateService(std::move(request), service_name); | 82 service_factory->CreateService(std::move(request), service_name); |
| 77 } | 83 } |
| 78 | 84 |
| 79 // Request service_manager::mojom::ServiceFactory from GPU process host. Must be | 85 // Request service_manager::mojom::ServiceFactory from GPU process host. Must be |
| 80 // called on IO thread. | 86 // called on IO thread. |
| 81 void StartServiceInGpuProcess(const std::string& service_name, | 87 void StartServiceInGpuProcess(const std::string& service_name, |
| 82 service_manager::mojom::ServiceRequest request) { | 88 service_manager::mojom::ServiceRequest request) { |
| 83 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 89 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 base::Bind(&DestroyConnectorOnIOThread)); | 392 base::Bind(&DestroyConnectorOnIOThread)); |
| 387 } | 393 } |
| 388 | 394 |
| 389 // static | 395 // static |
| 390 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { | 396 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { |
| 391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 397 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 392 return g_io_thread_connector.Get().get(); | 398 return g_io_thread_connector.Get().get(); |
| 393 } | 399 } |
| 394 | 400 |
| 395 } // namespace content | 401 } // namespace content |
| OLD | NEW |