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

Side by Side Diff: chrome/gpu/chrome_content_gpu_client.cc

Issue 2819903004: Migrate GpuChildThread to use ConnectionFilter instead of the ChildThread's InterfaceRegistry to exp (Closed)
Patch Set: . Created 3 years, 8 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 | « chrome/gpu/chrome_content_gpu_client.h ('k') | content/gpu/gpu_child_thread.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/gpu/chrome_content_gpu_client.h" 5 #include "chrome/gpu/chrome_content_gpu_client.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/common/stack_sampling_configuration.h" 14 #include "chrome/common/stack_sampling_configuration.h"
15 #include "components/metrics/child_call_stack_profile_collector.h" 15 #include "components/metrics/child_call_stack_profile_collector.h"
16 #include "content/public/child/child_thread.h"
16 #include "content/public/common/content_switches.h" 17 #include "content/public/common/content_switches.h"
17 #include "content/public/common/service_names.mojom.h" 18 #include "content/public/common/service_names.mojom.h"
18 #include "mojo/public/cpp/bindings/strong_binding.h" 19 #include "mojo/public/cpp/bindings/strong_binding.h"
19 #include "services/service_manager/public/cpp/connector.h" 20 #include "services/service_manager/public/cpp/connector.h"
20 21
21 #if defined(OS_CHROMEOS) 22 #if defined(OS_CHROMEOS)
22 #include "chrome/gpu/gpu_arc_video_service.h" 23 #include "chrome/gpu/gpu_arc_video_service.h"
23 #include "services/service_manager/public/cpp/interface_registry.h" 24 #include "content/public/common/service_manager_connection.h"
25 #include "services/service_manager/public/cpp/binder_registry.h"
24 #endif 26 #endif
25 27
26 namespace { 28 namespace {
27 29
28 #if defined(OS_CHROMEOS)
29 void CreateGpuArcVideoService(
30 const gpu::GpuPreferences& gpu_preferences,
31 ::arc::mojom::VideoAcceleratorServiceRequest request) {
32 mojo::MakeStrongBinding(
33 base::MakeUnique<chromeos::arc::GpuArcVideoService>(gpu_preferences),
34 std::move(request));
35 }
36 #endif
37
38 base::LazyInstance<metrics::ChildCallStackProfileCollector>::Leaky 30 base::LazyInstance<metrics::ChildCallStackProfileCollector>::Leaky
39 g_call_stack_profile_collector = LAZY_INSTANCE_INITIALIZER; 31 g_call_stack_profile_collector = LAZY_INSTANCE_INITIALIZER;
40 32
41 } // namespace 33 } // namespace
42 34
43 ChromeContentGpuClient::ChromeContentGpuClient() 35 ChromeContentGpuClient::ChromeContentGpuClient()
44 : stack_sampling_profiler_( 36 : stack_sampling_profiler_(
45 base::PlatformThread::CurrentId(), 37 base::PlatformThread::CurrentId(),
46 StackSamplingConfiguration::Get()->GetSamplingParamsForCurrentProcess(), 38 StackSamplingConfiguration::Get()
47 g_call_stack_profile_collector.Get().GetProfilerCallback( 39 ->GetSamplingParamsForCurrentProcess(),
48 metrics::CallStackProfileParams( 40 g_call_stack_profile_collector.Get().GetProfilerCallback(
49 metrics::CallStackProfileParams::GPU_PROCESS, 41 metrics::CallStackProfileParams(
50 metrics::CallStackProfileParams::GPU_MAIN_THREAD, 42 metrics::CallStackProfileParams::GPU_PROCESS,
51 metrics::CallStackProfileParams::PROCESS_STARTUP, 43 metrics::CallStackProfileParams::GPU_MAIN_THREAD,
52 metrics::CallStackProfileParams::MAY_SHUFFLE))) { 44 metrics::CallStackProfileParams::PROCESS_STARTUP,
45 metrics::CallStackProfileParams::MAY_SHUFFLE))) {
53 if (StackSamplingConfiguration::Get()->IsProfilerEnabledForCurrentProcess()) 46 if (StackSamplingConfiguration::Get()->IsProfilerEnabledForCurrentProcess())
54 stack_sampling_profiler_.Start(); 47 stack_sampling_profiler_.Start();
55 } 48 }
56 49
57 ChromeContentGpuClient::~ChromeContentGpuClient() {} 50 ChromeContentGpuClient::~ChromeContentGpuClient() {}
58 51
59 void ChromeContentGpuClient::Initialize( 52 void ChromeContentGpuClient::Initialize(
60 base::FieldTrialList::Observer* observer) { 53 base::FieldTrialList::Observer* observer,
54 service_manager::BinderRegistry* registry) {
61 DCHECK(!field_trial_syncer_); 55 DCHECK(!field_trial_syncer_);
62 const base::CommandLine& command_line = 56 const base::CommandLine& command_line =
63 *base::CommandLine::ForCurrentProcess(); 57 *base::CommandLine::ForCurrentProcess();
64 // No need for field trial syncer if we're in the browser process. 58 // No need for field trial syncer if we're in the browser process.
65 if (!command_line.HasSwitch(switches::kInProcessGPU)) { 59 if (!command_line.HasSwitch(switches::kInProcessGPU)) {
66 field_trial_syncer_.reset( 60 field_trial_syncer_.reset(
67 new variations::ChildProcessFieldTrialSyncer(observer)); 61 new variations::ChildProcessFieldTrialSyncer(observer));
68 field_trial_syncer_->InitFieldTrialObserving(command_line, 62 field_trial_syncer_->InitFieldTrialObserving(command_line,
69 switches::kSingleProcess); 63 switches::kSingleProcess);
70 } 64 }
71 }
72 65
73 void ChromeContentGpuClient::ExposeInterfacesToBrowser(
74 service_manager::InterfaceRegistry* registry,
75 const gpu::GpuPreferences& gpu_preferences) {
76 #if defined(OS_CHROMEOS) 66 #if defined(OS_CHROMEOS)
77 registry->AddInterface( 67 registry->AddInterface(
78 base::Bind(&CreateGpuArcVideoService, gpu_preferences)); 68 base::Bind(&ChromeContentGpuClient::CreateArcVideoAcceleratorService,
69 base::Unretained(this)),
70 base::ThreadTaskRunnerHandle::Get());
79 #endif 71 #endif
80 } 72 }
81 73
82 void ChromeContentGpuClient::ConsumeInterfacesFromBrowser( 74 void ChromeContentGpuClient::GpuServiceInitialized(
83 service_manager::Connector* connector) { 75 const gpu::GpuPreferences& gpu_preferences) {
76 #if defined(OS_CHROMEOS)
77 gpu_preferences_ = gpu_preferences;
78 #endif
79
84 metrics::mojom::CallStackProfileCollectorPtr browser_interface; 80 metrics::mojom::CallStackProfileCollectorPtr browser_interface;
85 connector->BindInterface(content::mojom::kBrowserServiceName, 81 content::ChildThread::Get()->GetConnector()->BindInterface(
86 &browser_interface); 82 content::mojom::kBrowserServiceName, &browser_interface);
87 g_call_stack_profile_collector.Get().SetParentProfileCollector( 83 g_call_stack_profile_collector.Get().SetParentProfileCollector(
88 std::move(browser_interface)); 84 std::move(browser_interface));
89 } 85 }
86
87 #if defined(OS_CHROMEOS)
88
89 void ChromeContentGpuClient::CreateArcVideoAcceleratorService(
90 ::arc::mojom::VideoAcceleratorServiceRequest request) {
91 mojo::MakeStrongBinding(
92 base::MakeUnique<chromeos::arc::GpuArcVideoService>(gpu_preferences_),
93 std::move(request));
94 }
95
96 #endif
OLDNEW
« no previous file with comments | « chrome/gpu/chrome_content_gpu_client.h ('k') | content/gpu/gpu_child_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698