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

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

Issue 2867213004: [Mojo Video Capture] Hook up video capture service behind a feature flag (Closed)
Patch Set: Incorporate suggestions from PatchSet 5 Created 3 years, 7 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
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/command_line.h" 12 #include "base/command_line.h"
13 #include "base/feature_list.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"
17 #include "base/process/process_handle.h" 18 #include "base/process/process_handle.h"
18 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
19 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
20 #include "content/browser/child_process_launcher.h" 21 #include "content/browser/child_process_launcher.h"
21 #include "content/browser/gpu/gpu_process_host.h" 22 #include "content/browser/gpu/gpu_process_host.h"
22 #include "content/browser/service_manager/common_browser_interfaces.h" 23 #include "content/browser/service_manager/common_browser_interfaces.h"
(...skipping 19 matching lines...) Expand all
42 #include "services/data_decoder/public/interfaces/constants.mojom.h" 43 #include "services/data_decoder/public/interfaces/constants.mojom.h"
43 #include "services/device/device_service.h" 44 #include "services/device/device_service.h"
44 #include "services/device/public/interfaces/constants.mojom.h" 45 #include "services/device/public/interfaces/constants.mojom.h"
45 #include "services/service_manager/connect_params.h" 46 #include "services/service_manager/connect_params.h"
46 #include "services/service_manager/public/cpp/connector.h" 47 #include "services/service_manager/public/cpp/connector.h"
47 #include "services/service_manager/public/cpp/service.h" 48 #include "services/service_manager/public/cpp/service.h"
48 #include "services/service_manager/public/interfaces/service.mojom.h" 49 #include "services/service_manager/public/interfaces/service.mojom.h"
49 #include "services/service_manager/runner/common/client_util.h" 50 #include "services/service_manager/runner/common/client_util.h"
50 #include "services/service_manager/service_manager.h" 51 #include "services/service_manager/service_manager.h"
51 #include "services/shape_detection/public/interfaces/constants.mojom.h" 52 #include "services/shape_detection/public/interfaces/constants.mojom.h"
53 #include "services/video_capture/public/cpp/constants.h"
54 #include "services/video_capture/public/interfaces/constants.mojom.h"
52 55
53 namespace content { 56 namespace content {
54 57
55 namespace { 58 namespace {
56 59
57 base::LazyInstance<std::unique_ptr<service_manager::Connector>>::Leaky 60 base::LazyInstance<std::unique_ptr<service_manager::Connector>>::Leaky
58 g_io_thread_connector = LAZY_INSTANCE_INITIALIZER; 61 g_io_thread_connector = LAZY_INSTANCE_INITIALIZER;
59 62
60 void DestroyConnectorOnIOThread() { g_io_thread_connector.Get().reset(); } 63 void DestroyConnectorOnIOThread() { g_io_thread_connector.Get().reset(); }
61 64
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 ->RegisterUnsandboxedOutOfProcessServices(&unsandboxed_services); 339 ->RegisterUnsandboxedOutOfProcessServices(&unsandboxed_services);
337 340
338 bool network_service_enabled = 341 bool network_service_enabled =
339 base::CommandLine::ForCurrentProcess()->HasSwitch( 342 base::CommandLine::ForCurrentProcess()->HasSwitch(
340 switches::kEnableNetworkService); 343 switches::kEnableNetworkService);
341 if (network_service_enabled) { 344 if (network_service_enabled) {
342 unsandboxed_services.insert( 345 unsandboxed_services.insert(
343 std::make_pair(content::mojom::kNetworkServiceName, 346 std::make_pair(content::mojom::kNetworkServiceName,
344 base::ASCIIToUTF16("Network Service"))); 347 base::ASCIIToUTF16("Network Service")));
345 } 348 }
349 if (base::FeatureList::IsEnabled(video_capture::kMojoVideoCapture)) {
350 unsandboxed_services.insert(
351 std::make_pair(video_capture::mojom::kServiceName,
352 base::ASCIIToUTF16("Video Capture Service")));
353 }
346 354
347 for (const auto& service : unsandboxed_services) { 355 for (const auto& service : unsandboxed_services) {
348 packaged_services_connection_->AddServiceRequestHandler( 356 packaged_services_connection_->AddServiceRequestHandler(
349 service.first, base::Bind(&StartServiceInUtilityProcess, service.first, 357 service.first, base::Bind(&StartServiceInUtilityProcess, service.first,
350 service.second, false /* use_sandbox */)); 358 service.second, false /* use_sandbox */));
351 } 359 }
352 360
353 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) 361 #if (ENABLE_MOJO_MEDIA_IN_GPU_PROCESS)
354 packaged_services_connection_->AddServiceRequestHandler( 362 packaged_services_connection_->AddServiceRequestHandler(
355 "media", base::Bind(&StartServiceInGpuProcess, "media")); 363 "media", base::Bind(&StartServiceInGpuProcess, "media"));
(...skipping 30 matching lines...) Expand all
386 base::Bind(&DestroyConnectorOnIOThread)); 394 base::Bind(&DestroyConnectorOnIOThread));
387 } 395 }
388 396
389 // static 397 // static
390 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() { 398 service_manager::Connector* ServiceManagerContext::GetConnectorForIOThread() {
391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 399 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
392 return g_io_thread_connector.Get().get(); 400 return g_io_thread_connector.Get().get();
393 } 401 }
394 402
395 } // namespace content 403 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698