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

Side by Side Diff: content/gpu/gpu_child_thread.cc

Issue 1845563005: Refactor content/common/gpu into gpu/ipc/service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop ref to deleted content_tests_gypi_values.content_unittests_ozone_sources Created 4 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 | « content/gpu/gpu_child_thread.h ('k') | content/gpu/gpu_main.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/gpu/gpu_child_thread.h" 5 #include "content/gpu/gpu_child_thread.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/threading/worker_pool.h" 13 #include "base/threading/worker_pool.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "content/child/child_process.h" 15 #include "content/child/child_process.h"
16 #include "content/child/thread_safe_sender.h" 16 #include "content/child/thread_safe_sender.h"
17 #include "content/common/establish_channel_params.h" 17 #include "content/common/establish_channel_params.h"
18 #include "content/common/gpu/gpu_memory_buffer_factory.h"
19 #include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h" 18 #include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h"
20 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" 19 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
21 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" 20 #include "content/common/gpu/media/gpu_video_encode_accelerator.h"
22 #include "content/common/gpu/media/media_service.h" 21 #include "content/common/gpu/media/media_service.h"
23 #include "content/common/gpu_host_messages.h" 22 #include "content/common/gpu_host_messages.h"
24 #include "content/gpu/gpu_process_control_impl.h" 23 #include "content/gpu/gpu_process_control_impl.h"
25 #include "content/gpu/gpu_watchdog_thread.h" 24 #include "content/gpu/gpu_watchdog_thread.h"
26 #include "content/public/common/content_client.h" 25 #include "content/public/common/content_client.h"
27 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
28 #include "content/public/gpu/content_gpu_client.h" 27 #include "content/public/gpu/content_gpu_client.h"
29 #include "gpu/command_buffer/service/gpu_switches.h" 28 #include "gpu/command_buffer/service/gpu_switches.h"
30 #include "gpu/config/gpu_info_collector.h" 29 #include "gpu/config/gpu_info_collector.h"
31 #include "gpu/config/gpu_switches.h" 30 #include "gpu/config/gpu_switches.h"
32 #include "gpu/config/gpu_util.h" 31 #include "gpu/config/gpu_util.h"
33 #include "gpu/ipc/common/memory_stats.h" 32 #include "gpu/ipc/common/memory_stats.h"
33 #include "gpu/ipc/service/gpu_memory_buffer_factory.h"
34 #include "ipc/ipc_channel_handle.h" 34 #include "ipc/ipc_channel_handle.h"
35 #include "ipc/ipc_sync_message_filter.h" 35 #include "ipc/ipc_sync_message_filter.h"
36 #include "ui/gl/gl_implementation.h" 36 #include "ui/gl/gl_implementation.h"
37 #include "ui/gl/gl_switches.h" 37 #include "ui/gl/gl_switches.h"
38 #include "ui/gl/gpu_switching_manager.h" 38 #include "ui/gl/gpu_switching_manager.h"
39 #include "url/gurl.h" 39 #include "url/gurl.h"
40 40
41 #if defined(USE_OZONE) 41 #if defined(USE_OZONE)
42 #include "ui/ozone/public/gpu_platform_support.h" 42 #include "ui/ozone/public/gpu_platform_support.h"
43 #include "ui/ozone/public/ozone_platform.h" 43 #include "ui/ozone/public/ozone_platform.h"
(...skipping 21 matching lines...) Expand all
65 65
66 return false; 66 return false;
67 } 67 }
68 68
69 // Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages 69 // Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages
70 // on the IO thread. This allows the UI thread in the browser process to remain 70 // on the IO thread. This allows the UI thread in the browser process to remain
71 // fast at all times. 71 // fast at all times.
72 class GpuMemoryBufferMessageFilter : public IPC::MessageFilter { 72 class GpuMemoryBufferMessageFilter : public IPC::MessageFilter {
73 public: 73 public:
74 explicit GpuMemoryBufferMessageFilter( 74 explicit GpuMemoryBufferMessageFilter(
75 GpuMemoryBufferFactory* gpu_memory_buffer_factory) 75 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory)
76 : gpu_memory_buffer_factory_(gpu_memory_buffer_factory), 76 : gpu_memory_buffer_factory_(gpu_memory_buffer_factory),
77 sender_(nullptr) {} 77 sender_(nullptr) {}
78 78
79 // Overridden from IPC::MessageFilter: 79 // Overridden from IPC::MessageFilter:
80 void OnFilterAdded(IPC::Sender* sender) override { 80 void OnFilterAdded(IPC::Sender* sender) override {
81 DCHECK(!sender_); 81 DCHECK(!sender_);
82 sender_ = sender; 82 sender_ = sender;
83 } 83 }
84 void OnFilterRemoved() override { 84 void OnFilterRemoved() override {
85 DCHECK(sender_); 85 DCHECK(sender_);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 TRACE_EVENT2( 117 TRACE_EVENT2(
118 "gpu", 118 "gpu",
119 "GpuMemoryBufferMessageFilter::OnCreateGpuMemoryBufferFromHandle", "id", 119 "GpuMemoryBufferMessageFilter::OnCreateGpuMemoryBufferFromHandle", "id",
120 params.id.id, "client_id", params.client_id); 120 params.id.id, "client_id", params.client_id);
121 sender_->Send(new GpuHostMsg_GpuMemoryBufferCreated( 121 sender_->Send(new GpuHostMsg_GpuMemoryBufferCreated(
122 gpu_memory_buffer_factory_->CreateGpuMemoryBufferFromHandle( 122 gpu_memory_buffer_factory_->CreateGpuMemoryBufferFromHandle(
123 params.handle, params.id, params.size, params.format, 123 params.handle, params.id, params.size, params.format,
124 params.client_id))); 124 params.client_id)));
125 } 125 }
126 126
127 GpuMemoryBufferFactory* const gpu_memory_buffer_factory_; 127 gpu::GpuMemoryBufferFactory* const gpu_memory_buffer_factory_;
128 IPC::Sender* sender_; 128 IPC::Sender* sender_;
129 }; 129 };
130 130
131 ChildThreadImpl::Options GetOptions( 131 ChildThreadImpl::Options GetOptions(
132 GpuMemoryBufferFactory* gpu_memory_buffer_factory) { 132 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory) {
133 ChildThreadImpl::Options::Builder builder; 133 ChildThreadImpl::Options::Builder builder;
134 134
135 builder.AddStartupFilter( 135 builder.AddStartupFilter(
136 new GpuMemoryBufferMessageFilter(gpu_memory_buffer_factory)); 136 new GpuMemoryBufferMessageFilter(gpu_memory_buffer_factory));
137 137
138 #if defined(USE_OZONE) 138 #if defined(USE_OZONE)
139 IPC::MessageFilter* message_filter = ui::OzonePlatform::GetInstance() 139 IPC::MessageFilter* message_filter = ui::OzonePlatform::GetInstance()
140 ->GetGpuPlatformSupport() 140 ->GetGpuPlatformSupport()
141 ->GetMessageFilter(); 141 ->GetMessageFilter();
142 if (message_filter) 142 if (message_filter)
143 builder.AddStartupFilter(message_filter); 143 builder.AddStartupFilter(message_filter);
144 #endif 144 #endif
145 145
146 return builder.Build(); 146 return builder.Build();
147 } 147 }
148 148
149 } // namespace 149 } // namespace
150 150
151 GpuChildThread::GpuChildThread( 151 GpuChildThread::GpuChildThread(
152 GpuWatchdogThread* watchdog_thread, 152 GpuWatchdogThread* watchdog_thread,
153 bool dead_on_arrival, 153 bool dead_on_arrival,
154 const gpu::GPUInfo& gpu_info, 154 const gpu::GPUInfo& gpu_info,
155 const DeferredMessages& deferred_messages, 155 const DeferredMessages& deferred_messages,
156 GpuMemoryBufferFactory* gpu_memory_buffer_factory, 156 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory,
157 gpu::SyncPointManager* sync_point_manager) 157 gpu::SyncPointManager* sync_point_manager)
158 : ChildThreadImpl(GetOptions(gpu_memory_buffer_factory)), 158 : ChildThreadImpl(GetOptions(gpu_memory_buffer_factory)),
159 dead_on_arrival_(dead_on_arrival), 159 dead_on_arrival_(dead_on_arrival),
160 sync_point_manager_(sync_point_manager), 160 sync_point_manager_(sync_point_manager),
161 gpu_info_(gpu_info), 161 gpu_info_(gpu_info),
162 deferred_messages_(deferred_messages), 162 deferred_messages_(deferred_messages),
163 in_browser_process_(false), 163 in_browser_process_(false),
164 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { 164 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) {
165 watchdog_thread_ = watchdog_thread; 165 watchdog_thread_ = watchdog_thread;
166 #if defined(OS_WIN) 166 #if defined(OS_WIN)
167 target_services_ = NULL; 167 target_services_ = NULL;
168 #endif 168 #endif
169 g_thread_safe_sender.Get() = thread_safe_sender(); 169 g_thread_safe_sender.Get() = thread_safe_sender();
170 } 170 }
171 171
172 GpuChildThread::GpuChildThread( 172 GpuChildThread::GpuChildThread(
173 const gpu::GpuPreferences& gpu_preferences, 173 const gpu::GpuPreferences& gpu_preferences,
174 const InProcessChildThreadParams& params, 174 const InProcessChildThreadParams& params,
175 GpuMemoryBufferFactory* gpu_memory_buffer_factory, 175 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory,
176 gpu::SyncPointManager* sync_point_manager) 176 gpu::SyncPointManager* sync_point_manager)
177 : ChildThreadImpl(ChildThreadImpl::Options::Builder() 177 : ChildThreadImpl(ChildThreadImpl::Options::Builder()
178 .InBrowserProcess(params) 178 .InBrowserProcess(params)
179 .AddStartupFilter(new GpuMemoryBufferMessageFilter( 179 .AddStartupFilter(new GpuMemoryBufferMessageFilter(
180 gpu_memory_buffer_factory)) 180 gpu_memory_buffer_factory))
181 .Build()), 181 .Build()),
182 gpu_preferences_(gpu_preferences), 182 gpu_preferences_(gpu_preferences),
183 dead_on_arrival_(false), 183 dead_on_arrival_(false),
184 sync_point_manager_(sync_point_manager), 184 sync_point_manager_(sync_point_manager),
185 in_browser_process_(true), 185 in_browser_process_(true),
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 389
390 // We don't need to pipe log messages if we are running the GPU thread in 390 // We don't need to pipe log messages if we are running the GPU thread in
391 // the browser process. 391 // the browser process.
392 if (!in_browser_process_) 392 if (!in_browser_process_)
393 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); 393 logging::SetLogMessageHandler(GpuProcessLogMessageHandler);
394 394
395 // Defer creation of the render thread. This is to prevent it from handling 395 // Defer creation of the render thread. This is to prevent it from handling
396 // IPC messages before the sandbox has been enabled and all other necessary 396 // IPC messages before the sandbox has been enabled and all other necessary
397 // initialization has succeeded. 397 // initialization has succeeded.
398 gpu_channel_manager_.reset( 398 gpu_channel_manager_.reset(
399 new GpuChannelManager(gpu_preferences_, this, watchdog_thread_.get(), 399 new gpu::GpuChannelManager(gpu_preferences_, this, watchdog_thread_.get(),
400 base::ThreadTaskRunnerHandle::Get().get(), 400 base::ThreadTaskRunnerHandle::Get().get(),
401 ChildProcess::current()->io_task_runner(), 401 ChildProcess::current()->io_task_runner(),
402 ChildProcess::current()->GetShutDownEvent(), 402 ChildProcess::current()->GetShutDownEvent(),
403 sync_point_manager_, gpu_memory_buffer_factory_)); 403 sync_point_manager_, gpu_memory_buffer_factory_));
404 404
405 media_service_.reset(new MediaService(gpu_channel_manager_.get())); 405 media_service_.reset(new MediaService(gpu_channel_manager_.get()));
406 406
407 #if defined(USE_OZONE) 407 #if defined(USE_OZONE)
408 ui::OzonePlatform::GetInstance() 408 ui::OzonePlatform::GetInstance()
409 ->GetGpuPlatformSupport() 409 ->GetGpuPlatformSupport()
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 576
577 void GpuChildThread::BindProcessControlRequest( 577 void GpuChildThread::BindProcessControlRequest(
578 mojo::InterfaceRequest<mojom::ProcessControl> request) { 578 mojo::InterfaceRequest<mojom::ProcessControl> request) {
579 DVLOG(1) << "GPU: Binding ProcessControl request"; 579 DVLOG(1) << "GPU: Binding ProcessControl request";
580 DCHECK(process_control_); 580 DCHECK(process_control_);
581 process_control_bindings_.AddBinding(process_control_.get(), 581 process_control_bindings_.AddBinding(process_control_.get(),
582 std::move(request)); 582 std::move(request));
583 } 583 }
584 584
585 } // namespace content 585 } // namespace content
OLDNEW
« no previous file with comments | « content/gpu/gpu_child_thread.h ('k') | content/gpu/gpu_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698