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

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

Issue 2756793002: RELAND: Shape Detection: move the Mac service to the sandboxed GPU process (Closed)
Patch Set: moved shapedetection-security-test.html to non-fast LayoutTests to use the mock mojo service Created 3 years, 9 months 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
« no previous file with comments | « no previous file | content/gpu/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 process_host->SetName(process_name); 64 process_host->SetName(process_name);
65 if (!use_sandbox) 65 if (!use_sandbox)
66 process_host->DisableSandbox(); 66 process_host->DisableSandbox();
67 process_host->Start(); 67 process_host->Start();
68 service_manager::mojom::ServiceFactoryPtr service_factory; 68 service_manager::mojom::ServiceFactoryPtr service_factory;
69 process_host->GetRemoteInterfaces()->GetInterface( 69 process_host->GetRemoteInterfaces()->GetInterface(
70 mojo::MakeRequest(&service_factory)); 70 mojo::MakeRequest(&service_factory));
71 service_factory->CreateService(std::move(request), service_name); 71 service_factory->CreateService(std::move(request), service_name);
72 } 72 }
73 73
74 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS)
75
76 // Request service_manager::mojom::ServiceFactory from GPU process host. Must be 74 // Request service_manager::mojom::ServiceFactory from GPU process host. Must be
77 // called on IO thread. 75 // called on IO thread.
78 void StartServiceInGpuProcess(const std::string& service_name, 76 void StartServiceInGpuProcess(const std::string& service_name,
79 service_manager::mojom::ServiceRequest request) { 77 service_manager::mojom::ServiceRequest request) {
80 DCHECK_CURRENTLY_ON(BrowserThread::IO); 78 DCHECK_CURRENTLY_ON(BrowserThread::IO);
81 GpuProcessHost* process_host = 79 GpuProcessHost* process_host =
82 GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED); 80 GpuProcessHost::Get(GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED);
83 if (!process_host) { 81 if (!process_host) {
84 DLOG(ERROR) << "GPU process host not available."; 82 DLOG(ERROR) << "GPU process host not available.";
85 return; 83 return;
86 } 84 }
87 85
88 service_manager::mojom::ServiceFactoryPtr service_factory; 86 service_manager::mojom::ServiceFactoryPtr service_factory;
89 // TODO(xhwang): It's possible that |process_host| is non-null, but the actual 87 // TODO(xhwang): It's possible that |process_host| is non-null, but the actual
90 // process is dead. In that case, |request| will be dropped and application 88 // process is dead. In that case, |request| will be dropped and application
91 // load requests through ServiceFactory will also fail. Make sure we handle 89 // load requests through ServiceFactory will also fail. Make sure we handle
92 // these cases correctly. 90 // these cases correctly.
93 process_host->GetRemoteInterfaces()->GetInterface( 91 process_host->GetRemoteInterfaces()->GetInterface(
94 mojo::MakeRequest(&service_factory)); 92 mojo::MakeRequest(&service_factory));
95 service_factory->CreateService(std::move(request), service_name); 93 service_factory->CreateService(std::move(request), service_name);
96 } 94 }
97 95
98 #endif // ENABLE_MOJO_MEDIA_IN_GPU_PROCESS
99
100 // A ManifestProvider which resolves application names to builtin manifest 96 // A ManifestProvider which resolves application names to builtin manifest
101 // resources for the catalog service to consume. 97 // resources for the catalog service to consume.
102 class BuiltinManifestProvider : public catalog::ManifestProvider { 98 class BuiltinManifestProvider : public catalog::ManifestProvider {
103 public: 99 public:
104 BuiltinManifestProvider() {} 100 BuiltinManifestProvider() {}
105 ~BuiltinManifestProvider() override {} 101 ~BuiltinManifestProvider() override {}
106 102
107 void AddServiceManifest(base::StringPiece name, int resource_id) { 103 void AddServiceManifest(base::StringPiece name, int resource_id) {
108 std::string contents = 104 std::string contents =
109 GetContentClient() 105 GetContentClient()
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 for (const auto& service : sandboxed_services) { 311 for (const auto& service : sandboxed_services) {
316 packaged_services_connection_->AddServiceRequestHandler( 312 packaged_services_connection_->AddServiceRequestHandler(
317 service.first, base::Bind(&StartServiceInUtilityProcess, service.first, 313 service.first, base::Bind(&StartServiceInUtilityProcess, service.first,
318 service.second, true /* use_sandbox */)); 314 service.second, true /* use_sandbox */));
319 } 315 }
320 316
321 ContentBrowserClient::OutOfProcessServiceMap unsandboxed_services; 317 ContentBrowserClient::OutOfProcessServiceMap unsandboxed_services;
322 GetContentClient() 318 GetContentClient()
323 ->browser() 319 ->browser()
324 ->RegisterUnsandboxedOutOfProcessServices(&unsandboxed_services); 320 ->RegisterUnsandboxedOutOfProcessServices(&unsandboxed_services);
325 unsandboxed_services.insert(
326 std::make_pair(shape_detection::mojom::kServiceName,
327 base::ASCIIToUTF16("Shape Detection Service")));
328 for (const auto& service : unsandboxed_services) { 321 for (const auto& service : unsandboxed_services) {
329 packaged_services_connection_->AddServiceRequestHandler( 322 packaged_services_connection_->AddServiceRequestHandler(
330 service.first, base::Bind(&StartServiceInUtilityProcess, service.first, 323 service.first, base::Bind(&StartServiceInUtilityProcess, service.first,
331 service.second, false /* use_sandbox */)); 324 service.second, false /* use_sandbox */));
332 } 325 }
333 326
334 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) 327 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS)
335 packaged_services_connection_->AddServiceRequestHandler( 328 packaged_services_connection_->AddServiceRequestHandler(
336 "media", base::Bind(&StartServiceInGpuProcess, "media")); 329 "media", base::Bind(&StartServiceInGpuProcess, "media"));
337 #endif 330 #endif
331
332 packaged_services_connection_->AddServiceRequestHandler(
333 shape_detection::mojom::kServiceName,
334 base::Bind(&StartServiceInGpuProcess,
335 shape_detection::mojom::kServiceName));
336
338 packaged_services_connection_->Start(); 337 packaged_services_connection_->Start();
339 ServiceManagerConnection::GetForProcess()->Start(); 338 ServiceManagerConnection::GetForProcess()->Start();
340 } 339 }
341 340
342 ServiceManagerContext::~ServiceManagerContext() { 341 ServiceManagerContext::~ServiceManagerContext() {
343 // NOTE: The in-process ServiceManager MUST be destroyed before the browser 342 // NOTE: The in-process ServiceManager MUST be destroyed before the browser
344 // process-wide ServiceManagerConnection. Otherwise it's possible for the 343 // process-wide ServiceManagerConnection. Otherwise it's possible for the
345 // ServiceManager to receive connection requests for service:content_browser 344 // ServiceManager to receive connection requests for service:content_browser
346 // which it may attempt to service by launching a new instance of the browser. 345 // which it may attempt to service by launching a new instance of the browser.
347 if (in_process_context_) 346 if (in_process_context_)
348 in_process_context_->ShutDown(); 347 in_process_context_->ShutDown();
349 if (ServiceManagerConnection::GetForProcess()) 348 if (ServiceManagerConnection::GetForProcess())
350 ServiceManagerConnection::DestroyForProcess(); 349 ServiceManagerConnection::DestroyForProcess();
351 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 350 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
352 base::Bind(&DestroyConnectorOnIOThread)); 351 base::Bind(&DestroyConnectorOnIOThread));
353 } 352 }
354 353
355 // static 354 // static
356 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { 355 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() {
357 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
358 return g_io_thread_connector.Get().get(); 357 return g_io_thread_connector.Get().get();
359 } 358 }
360 359
361 } // namespace content 360 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/gpu/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698