Chromium Code Reviews| 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 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "content/public/browser/utility_process_host.h" | 23 #include "content/public/browser/utility_process_host.h" |
| 24 #include "content/public/browser/utility_process_host_client.h" | 24 #include "content/public/browser/utility_process_host_client.h" |
| 25 #include "content/public/common/content_client.h" | 25 #include "content/public/common/content_client.h" |
| 26 #include "content/public/common/service_manager_connection.h" | 26 #include "content/public/common/service_manager_connection.h" |
| 27 #include "content/public/common/service_names.h" | 27 #include "content/public/common/service_names.h" |
| 28 #include "mojo/edk/embedder/embedder.h" | 28 #include "mojo/edk/embedder/embedder.h" |
| 29 #include "services/catalog/catalog.h" | 29 #include "services/catalog/catalog.h" |
| 30 #include "services/catalog/manifest_provider.h" | 30 #include "services/catalog/manifest_provider.h" |
| 31 #include "services/catalog/public/interfaces/constants.mojom.h" | 31 #include "services/catalog/public/interfaces/constants.mojom.h" |
| 32 #include "services/catalog/store.h" | 32 #include "services/catalog/store.h" |
| 33 #include "services/device/device_service.h" | |
| 34 #include "services/device/public/cpp/constants.h" | |
| 33 #include "services/file/public/interfaces/constants.mojom.h" | 35 #include "services/file/public/interfaces/constants.mojom.h" |
| 34 #include "services/service_manager/connect_params.h" | 36 #include "services/service_manager/connect_params.h" |
| 35 #include "services/service_manager/native_runner.h" | 37 #include "services/service_manager/native_runner.h" |
| 36 #include "services/service_manager/public/cpp/connector.h" | 38 #include "services/service_manager/public/cpp/connector.h" |
| 37 #include "services/service_manager/public/cpp/service.h" | 39 #include "services/service_manager/public/cpp/service.h" |
| 38 #include "services/service_manager/public/interfaces/service.mojom.h" | 40 #include "services/service_manager/public/interfaces/service.mojom.h" |
| 39 #include "services/service_manager/runner/common/client_util.h" | 41 #include "services/service_manager/runner/common/client_util.h" |
| 40 #include "services/service_manager/runner/host/in_process_native_runner.h" | 42 #include "services/service_manager/runner/host/in_process_native_runner.h" |
| 41 #include "services/service_manager/service_manager.h" | 43 #include "services/service_manager/service_manager.h" |
| 42 | 44 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 manifest_provider->AddManifestValue(kManifests[i].name, | 250 manifest_provider->AddManifestValue(kManifests[i].name, |
| 249 std::move(manifest_value)); | 251 std::move(manifest_value)); |
| 250 } | 252 } |
| 251 in_process_context_ = new InProcessServiceManagerContext; | 253 in_process_context_ = new InProcessServiceManagerContext; |
| 252 request = in_process_context_->Start(std::move(manifest_provider)); | 254 request = in_process_context_->Start(std::move(manifest_provider)); |
| 253 } | 255 } |
| 254 ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create( | 256 ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create( |
| 255 std::move(request), | 257 std::move(request), |
| 256 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); | 258 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); |
| 257 | 259 |
| 260 // Serves processes other than renderer, such as gpu, plugin, utility etc. | |
|
leonhsl(Using Gerrit)
2016/11/17 10:28:03
Maybe we should let the device service here also s
blundell
2016/11/22 16:46:44
Sorry, I didn't understand this question. Could yo
| |
| 261 ServiceInfo device_info; | |
| 262 device_info.factory = | |
| 263 base::Bind(&device::CreateDeviceService, | |
| 264 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); | |
| 265 ServiceManagerConnection::GetForProcess()->AddEmbeddedService( | |
| 266 device::kDeviceServiceName, device_info); | |
| 267 | |
| 258 ContentBrowserClient::StaticServiceMap services; | 268 ContentBrowserClient::StaticServiceMap services; |
| 259 GetContentClient()->browser()->RegisterInProcessServices(&services); | 269 GetContentClient()->browser()->RegisterInProcessServices(&services); |
| 260 for (const auto& entry : services) { | 270 for (const auto& entry : services) { |
| 261 ServiceManagerConnection::GetForProcess()->AddEmbeddedService(entry.first, | 271 ServiceManagerConnection::GetForProcess()->AddEmbeddedService(entry.first, |
| 262 entry.second); | 272 entry.second); |
| 263 } | 273 } |
| 264 | 274 |
| 265 // This is safe to assign directly from any thread, because | 275 // This is safe to assign directly from any thread, because |
| 266 // ServiceManagerContext must be constructed before anyone can call | 276 // ServiceManagerContext must be constructed before anyone can call |
| 267 // GetConnectorForIOThread(). | 277 // GetConnectorForIOThread(). |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 base::Bind(&DestroyConnectorOnIOThread)); | 321 base::Bind(&DestroyConnectorOnIOThread)); |
| 312 } | 322 } |
| 313 | 323 |
| 314 // static | 324 // static |
| 315 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { | 325 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { |
| 316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 326 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 317 return g_io_thread_connector.Get().get(); | 327 return g_io_thread_connector.Get().get(); |
| 318 } | 328 } |
| 319 | 329 |
| 320 } // namespace content | 330 } // namespace content |
| OLD | NEW |