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

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
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 "content/public/common/simple_connection_filter.h"
26 #include "services/service_manager/public/cpp/binder_registry.h"
24 #endif 27 #endif
25 28
26 namespace { 29 namespace {
27 30
28 #if defined(OS_CHROMEOS) 31 #if defined(OS_CHROMEOS)
29 void CreateGpuArcVideoService( 32
30 const gpu::GpuPreferences& gpu_preferences, 33 class GpuArcVideoServiceFactory {
31 ::arc::mojom::VideoAcceleratorServiceRequest request) { 34 public:
32 mojo::MakeStrongBinding( 35 GpuArcVideoServiceFactory() {}
33 base::MakeUnique<chromeos::arc::GpuArcVideoService>(gpu_preferences), 36 ~GpuArcVideoServiceFactory() {}
34 std::move(request)); 37
38 void Create(::arc::mojom::VideoAcceleratorServiceRequest request) {
39 mojo::MakeStrongBinding(
40 base::MakeUnique<chromeos::arc::GpuArcVideoService>(gpu_preferences_),
41 std::move(request));
42 }
43
44 void set_gpu_preferences(const gpu::GpuPreferences& gpu_preferences) {
45 gpu_preferences_ = gpu_preferences;
46 }
47
48 private:
49 gpu::GpuPreferences gpu_preferences_;
50
51 DISALLOW_COPY_AND_ASSIGN(GpuArcVideoServiceFactory);
35 } 52 }
53
36 #endif 54 #endif
37 55
38 base::LazyInstance<metrics::ChildCallStackProfileCollector>::Leaky 56 base::LazyInstance<metrics::ChildCallStackProfileCollector>::Leaky
39 g_call_stack_profile_collector = LAZY_INSTANCE_INITIALIZER; 57 g_call_stack_profile_collector = LAZY_INSTANCE_INITIALIZER;
40 58
41 } // namespace 59 } // namespace
42 60
43 ChromeContentGpuClient::ChromeContentGpuClient() 61 ChromeContentGpuClient::ChromeContentGpuClient()
44 : stack_sampling_profiler_( 62 : stack_sampling_profiler_(
45 base::PlatformThread::CurrentId(), 63 base::PlatformThread::CurrentId(),
46 StackSamplingConfiguration::Get()->GetSamplingParamsForCurrentProcess(), 64 StackSamplingConfiguration::Get()->GetSamplingParamsForCurrentProcess(),
47 g_call_stack_profile_collector.Get().GetProfilerCallback( 65 g_call_stack_profile_collector.Get().GetProfilerCallback(
48 metrics::CallStackProfileParams( 66 metrics::CallStackProfileParams(
49 metrics::CallStackProfileParams::GPU_PROCESS, 67 metrics::CallStackProfileParams::GPU_PROCESS,
50 metrics::CallStackProfileParams::GPU_MAIN_THREAD, 68 metrics::CallStackProfileParams::GPU_MAIN_THREAD,
51 metrics::CallStackProfileParams::PROCESS_STARTUP, 69 metrics::CallStackProfileParams::PROCESS_STARTUP,
52 metrics::CallStackProfileParams::MAY_SHUFFLE))) { 70 metrics::CallStackProfileParams::MAY_SHUFFLE))) {
53 if (StackSamplingConfiguration::Get()->IsProfilerEnabledForCurrentProcess()) 71 if (StackSamplingConfiguration::Get()->IsProfilerEnabledForCurrentProcess())
54 stack_sampling_profiler_.Start(); 72 stack_sampling_profiler_.Start();
55 } 73 }
56 74
57 ChromeContentGpuClient::~ChromeContentGpuClient() {} 75 ChromeContentGpuClient::~ChromeContentGpuClient() {}
58 76
59 void ChromeContentGpuClient::Initialize( 77 void ChromeContentGpuClient::Initialize(
60 base::FieldTrialList::Observer* observer) { 78 base::FieldTrialList::Observer* observer,
79 service_manager::BinderRegistry* registry) {
61 DCHECK(!field_trial_syncer_); 80 DCHECK(!field_trial_syncer_);
62 const base::CommandLine& command_line = 81 const base::CommandLine& command_line =
63 *base::CommandLine::ForCurrentProcess(); 82 *base::CommandLine::ForCurrentProcess();
64 // No need for field trial syncer if we're in the browser process. 83 // No need for field trial syncer if we're in the browser process.
65 if (!command_line.HasSwitch(switches::kInProcessGPU)) { 84 if (!command_line.HasSwitch(switches::kInProcessGPU)) {
66 field_trial_syncer_.reset( 85 field_trial_syncer_.reset(
67 new variations::ChildProcessFieldTrialSyncer(observer)); 86 new variations::ChildProcessFieldTrialSyncer(observer));
68 field_trial_syncer_->InitFieldTrialObserving(command_line, 87 field_trial_syncer_->InitFieldTrialObserving(command_line,
69 switches::kSingleProcess); 88 switches::kSingleProcess);
70 } 89 }
71 }
72 90
73 void ChromeContentGpuClient::ExposeInterfacesToBrowser(
74 service_manager::InterfaceRegistry* registry,
75 const gpu::GpuPreferences& gpu_preferences) {
76 #if defined(OS_CHROMEOS) 91 #if defined(OS_CHROMEOS)
92 gpu_arc_video_service_factory_ =
93 base::MakeUnique<GpuArcVideoServiceFactory>();
77 registry->AddInterface( 94 registry->AddInterface(
78 base::Bind(&CreateGpuArcVideoService, gpu_preferences)); 95 base::Bind(&GpuArcVideoServiceFactory::Create,
96 base::Unretained(gpu_arc_video_service_factory_)),
97 base::ThreadTaskRunnerHandle::Get());
79 #endif 98 #endif
80 } 99 }
81 100
82 void ChromeContentGpuClient::ConsumeInterfacesFromBrowser( 101 void ChromeContentGpuClient::GpuServiceInitialized(
83 service_manager::Connector* connector) { 102 const gpu::GpuPreferences& gpu_preferences) {
103 #if defined(OS_CHROMEOS)
104 gpu_arc_video_service_factory_->set_gpu_preferences(gpu_preferences);
105 #endif
106
84 metrics::mojom::CallStackProfileCollectorPtr browser_interface; 107 metrics::mojom::CallStackProfileCollectorPtr browser_interface;
85 connector->BindInterface(content::mojom::kBrowserServiceName, 108 content::ChildThread::Get()->GetConnector()->BindInterface(
86 &browser_interface); 109 content::mojom::kBrowserServiceName, &browser_interface);
87 g_call_stack_profile_collector.Get().SetParentProfileCollector( 110 g_call_stack_profile_collector.Get().SetParentProfileCollector(
88 std::move(browser_interface)); 111 std::move(browser_interface));
89 } 112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698