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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 const base::string16& process_name, | 64 const base::string16& process_name, |
64 bool use_sandbox, | 65 bool use_sandbox, |
65 service_manager::mojom::ServiceRequest request) { | 66 service_manager::mojom::ServiceRequest request) { |
66 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 67 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
67 UtilityProcessHost* process_host = | 68 UtilityProcessHost* process_host = |
68 UtilityProcessHost::Create(nullptr, nullptr); | 69 UtilityProcessHost::Create(nullptr, nullptr); |
69 process_host->SetName(process_name); | 70 process_host->SetName(process_name); |
70 if (!use_sandbox) | 71 if (!use_sandbox) |
71 process_host->DisableSandbox(); | 72 process_host->DisableSandbox(); |
72 process_host->Start(); | 73 process_host->Start(); |
| 74 // Register mojo interfaces on UI thread. |
| 75 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI) |
| 76 ->PostTask(FROM_HERE, |
| 77 base::Bind(&UtilityProcessHost::RegisterMojoServices, |
| 78 base::Unretained(process_host))); |
73 service_manager::mojom::ServiceFactoryPtr service_factory; | 79 service_manager::mojom::ServiceFactoryPtr service_factory; |
74 BindInterface(process_host, mojo::MakeRequest(&service_factory)); | 80 BindInterface(process_host, mojo::MakeRequest(&service_factory)); |
75 service_factory->CreateService(std::move(request), service_name); | 81 service_factory->CreateService(std::move(request), service_name); |
76 } | 82 } |
77 | 83 |
78 // Request service_manager::mojom::ServiceFactory from GPU process host. Must be | 84 // Request service_manager::mojom::ServiceFactory from GPU process host. Must be |
79 // called on IO thread. | 85 // called on IO thread. |
80 void StartServiceInGpuProcess(const std::string& service_name, | 86 void StartServiceInGpuProcess(const std::string& service_name, |
81 service_manager::mojom::ServiceRequest request) { | 87 service_manager::mojom::ServiceRequest request) { |
82 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 88 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 base::Bind(&DestroyConnectorOnIOThread)); | 389 base::Bind(&DestroyConnectorOnIOThread)); |
384 } | 390 } |
385 | 391 |
386 // static | 392 // static |
387 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { | 393 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { |
388 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
389 return g_io_thread_connector.Get().get(); | 395 return g_io_thread_connector.Get().get(); |
390 } | 396 } |
391 | 397 |
392 } // namespace content | 398 } // namespace content |
OLD | NEW |