Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: content/browser/service_manager/service_manager_context.cc

Issue 2528743002: Shape Detection: Implement FaceDetection on Mac as out-of-process service (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/strings/utf_string_conversions.h"
17 #include "content/browser/gpu/gpu_process_host.h" 18 #include "content/browser/gpu/gpu_process_host.h"
18 #include "content/browser/service_manager/merge_dictionary.h" 19 #include "content/browser/service_manager/merge_dictionary.h"
19 #include "content/common/service_manager/service_manager_connection_impl.h" 20 #include "content/common/service_manager/service_manager_connection_impl.h"
20 #include "content/grit/content_resources.h" 21 #include "content/grit/content_resources.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/content_browser_client.h" 23 #include "content/public/browser/content_browser_client.h"
23 #include "content/public/browser/utility_process_host.h" 24 #include "content/public/browser/utility_process_host.h"
24 #include "content/public/browser/utility_process_host_client.h" 25 #include "content/public/browser/utility_process_host_client.h"
25 #include "content/public/common/content_client.h" 26 #include "content/public/common/content_client.h"
26 #include "content/public/common/service_manager_connection.h" 27 #include "content/public/common/service_manager_connection.h"
27 #include "content/public/common/service_names.mojom.h" 28 #include "content/public/common/service_names.mojom.h"
28 #include "mojo/edk/embedder/embedder.h" 29 #include "mojo/edk/embedder/embedder.h"
29 #include "services/catalog/catalog.h" 30 #include "services/catalog/catalog.h"
30 #include "services/catalog/manifest_provider.h" 31 #include "services/catalog/manifest_provider.h"
31 #include "services/catalog/public/interfaces/constants.mojom.h" 32 #include "services/catalog/public/interfaces/constants.mojom.h"
32 #include "services/catalog/store.h" 33 #include "services/catalog/store.h"
33 #include "services/file/public/interfaces/constants.mojom.h" 34 #include "services/file/public/interfaces/constants.mojom.h"
34 #include "services/service_manager/connect_params.h" 35 #include "services/service_manager/connect_params.h"
35 #include "services/service_manager/native_runner.h" 36 #include "services/service_manager/native_runner.h"
36 #include "services/service_manager/public/cpp/connector.h" 37 #include "services/service_manager/public/cpp/connector.h"
37 #include "services/service_manager/public/cpp/service.h" 38 #include "services/service_manager/public/cpp/service.h"
38 #include "services/service_manager/public/interfaces/service.mojom.h" 39 #include "services/service_manager/public/interfaces/service.mojom.h"
39 #include "services/service_manager/runner/common/client_util.h" 40 #include "services/service_manager/runner/common/client_util.h"
40 #include "services/service_manager/runner/host/in_process_native_runner.h" 41 #include "services/service_manager/runner/host/in_process_native_runner.h"
41 #include "services/service_manager/service_manager.h" 42 #include "services/service_manager/service_manager.h"
43 #include "services/shape_detection/public/interfaces/constants.mojom.h"
44 #include "services/shape_detection/shape_detection_service.h"
42 45
43 namespace content { 46 namespace content {
44 47
45 namespace { 48 namespace {
46 49
47 base::LazyInstance<std::unique_ptr<service_manager::Connector>>::Leaky 50 base::LazyInstance<std::unique_ptr<service_manager::Connector>>::Leaky
48 g_io_thread_connector = LAZY_INSTANCE_INITIALIZER; 51 g_io_thread_connector = LAZY_INSTANCE_INITIALIZER;
49 52
50 void DestroyConnectorOnIOThread() { g_io_thread_connector.Get().reset(); } 53 void DestroyConnectorOnIOThread() { g_io_thread_connector.Get().reset(); }
51 54
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 253 }
251 in_process_context_ = new InProcessServiceManagerContext; 254 in_process_context_ = new InProcessServiceManagerContext;
252 request = in_process_context_->Start(std::move(manifest_provider)); 255 request = in_process_context_->Start(std::move(manifest_provider));
253 } 256 }
254 ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create( 257 ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create(
255 std::move(request), 258 std::move(request),
256 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); 259 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)));
257 260
258 ContentBrowserClient::StaticServiceMap services; 261 ContentBrowserClient::StaticServiceMap services;
259 GetContentClient()->browser()->RegisterInProcessServices(&services); 262 GetContentClient()->browser()->RegisterInProcessServices(&services);
263 // Put Shape Detection Service in browser process for now. if we see crashes
264 // in the future, consider moving it to a utility process.
265
266 // TODO(xianglu): The code below does not seem to register shape_detection
267 // service? browser_context.cc is where registration actually happens.
268 ServiceInfo shape_detection_info;
Ken Rockot(use gerrit already) 2016/12/01 17:54:30 You can remove this registration for now. We aren'
xianglu 2016/12/02 18:11:23 Done.
269 shape_detection_info.factory =
270 base::Bind(&shape_detection::CreateShapeDetectionService);
271 services.insert(std::make_pair(shape_detection::mojom::kServiceName,
272 shape_detection_info));
260 for (const auto& entry : services) { 273 for (const auto& entry : services) {
261 ServiceManagerConnection::GetForProcess()->AddEmbeddedService(entry.first, 274 ServiceManagerConnection::GetForProcess()->AddEmbeddedService(entry.first,
262 entry.second); 275 entry.second);
263 } 276 }
264 277
265 // This is safe to assign directly from any thread, because 278 // This is safe to assign directly from any thread, because
266 // ServiceManagerContext must be constructed before anyone can call 279 // ServiceManagerContext must be constructed before anyone can call
267 // GetConnectorForIOThread(). 280 // GetConnectorForIOThread().
268 g_io_thread_connector.Get() = 281 g_io_thread_connector.Get() =
269 ServiceManagerConnection::GetForProcess()->GetConnector()->Clone(); 282 ServiceManagerConnection::GetForProcess()->GetConnector()->Clone();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 base::Bind(&DestroyConnectorOnIOThread)); 324 base::Bind(&DestroyConnectorOnIOThread));
312 } 325 }
313 326
314 // static 327 // static
315 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { 328 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() {
316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
317 return g_io_thread_connector.Get().get(); 330 return g_io_thread_connector.Get().get();
318 } 331 }
319 332
320 } // namespace content 333 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698