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

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

Issue 2111353002: Move content's shell connections to the IO thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert some gpu changes Created 4 years, 5 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 (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/callback_helpers.h" 11 #include "base/callback_helpers.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/threading/thread_local.h" 14 #include "base/threading/thread_local.h"
15 #include "base/threading/worker_pool.h" 15 #include "base/threading/worker_pool.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "content/child/child_process.h" 17 #include "content/child/child_process.h"
18 #include "content/child/thread_safe_sender.h" 18 #include "content/child/thread_safe_sender.h"
19 #include "content/common/establish_channel_params.h" 19 #include "content/common/establish_channel_params.h"
20 #include "content/common/gpu_host_messages.h" 20 #include "content/common/gpu_host_messages.h"
21 #include "content/gpu/gpu_process_control_impl.h" 21 #include "content/gpu/gpu_process_control_impl.h"
22 #include "content/gpu/gpu_watchdog_thread.h" 22 #include "content/gpu/gpu_watchdog_thread.h"
23 #include "content/public/common/content_client.h" 23 #include "content/public/common/content_client.h"
24 #include "content/public/common/content_switches.h" 24 #include "content/public/common/content_switches.h"
25 #include "content/public/common/mojo_shell_connection.h"
25 #include "content/public/gpu/content_gpu_client.h" 26 #include "content/public/gpu/content_gpu_client.h"
26 #include "gpu/command_buffer/service/gpu_switches.h" 27 #include "gpu/command_buffer/service/gpu_switches.h"
27 #include "gpu/command_buffer/service/sync_point_manager.h" 28 #include "gpu/command_buffer/service/sync_point_manager.h"
28 #include "gpu/config/gpu_info_collector.h" 29 #include "gpu/config/gpu_info_collector.h"
29 #include "gpu/config/gpu_switches.h" 30 #include "gpu/config/gpu_switches.h"
30 #include "gpu/config/gpu_util.h" 31 #include "gpu/config/gpu_util.h"
31 #include "gpu/ipc/common/memory_stats.h" 32 #include "gpu/ipc/common/memory_stats.h"
32 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" 33 #include "gpu/ipc/service/gpu_memory_buffer_factory.h"
33 #include "ipc/ipc_channel_handle.h" 34 #include "ipc/ipc_channel_handle.h"
34 #include "ipc/ipc_sync_message_filter.h" 35 #include "ipc/ipc_sync_message_filter.h"
35 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h" 36 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h"
36 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" 37 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h"
37 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" 38 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h"
38 #include "media/gpu/ipc/service/media_service.h" 39 #include "media/gpu/ipc/service/media_service.h"
40 #include "services/shell/public/cpp/interface_registry.h"
39 #include "ui/gl/gl_implementation.h" 41 #include "ui/gl/gl_implementation.h"
40 #include "ui/gl/gl_switches.h" 42 #include "ui/gl/gl_switches.h"
41 #include "ui/gl/gpu_switching_manager.h" 43 #include "ui/gl/gpu_switching_manager.h"
42 #include "ui/gl/init/gl_factory.h" 44 #include "ui/gl/init/gl_factory.h"
43 #include "url/gurl.h" 45 #include "url/gurl.h"
44 46
45 #if defined(USE_OZONE) 47 #if defined(USE_OZONE)
46 #include "ui/ozone/public/gpu_platform_support.h" 48 #include "ui/ozone/public/gpu_platform_support.h"
47 #include "ui/ozone/public/ozone_platform.h" 49 #include "ui/ozone/public/ozone_platform.h"
48 #endif 50 #endif
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 #if defined(OS_ANDROID) 216 #if defined(OS_ANDROID)
215 // When running in in-process mode, this has been set in the browser at 217 // When running in in-process mode, this has been set in the browser at
216 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun(). 218 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun().
217 if (!in_browser_process_) 219 if (!in_browser_process_)
218 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid()); 220 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid());
219 #endif 221 #endif
220 222
221 // Only set once per process instance. 223 // Only set once per process instance.
222 process_control_.reset(new GpuProcessControlImpl()); 224 process_control_.reset(new GpuProcessControlImpl());
223 225
226 GetInterfaceRegistry()->AddInterface(base::Bind(
227 &GpuChildThread::BindProcessControlRequest, base::Unretained(this)));
228
229 if (GetContentClient()->gpu()) { // NULL in tests.
230 GetContentClient()->gpu()->ExposeInterfacesToBrowser(
231 GetInterfaceRegistry());
232 }
233
234 // We don't want to process any incoming interface requests until
235 // OnInitialize() is invoked.
236 GetInterfaceRegistry()->PauseBinding();
237
224 if (GetContentClient()->gpu()) // NULL in tests. 238 if (GetContentClient()->gpu()) // NULL in tests.
225 GetContentClient()->gpu()->Initialize(this); 239 GetContentClient()->gpu()->Initialize(this);
226 } 240 }
227 241
228 void GpuChildThread::OnFieldTrialGroupFinalized(const std::string& trial_name, 242 void GpuChildThread::OnFieldTrialGroupFinalized(const std::string& trial_name,
229 const std::string& group_name) { 243 const std::string& group_name) {
230 Send(new GpuHostMsg_FieldTrialActivated(trial_name)); 244 Send(new GpuHostMsg_FieldTrialActivated(trial_name));
231 } 245 }
232 246
233 bool GpuChildThread::Send(IPC::Message* msg) { 247 bool GpuChildThread::Send(IPC::Message* msg) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 OnDestroyingVideoSurface); 297 OnDestroyingVideoSurface);
284 #endif 298 #endif
285 IPC_MESSAGE_UNHANDLED(handled = false) 299 IPC_MESSAGE_UNHANDLED(handled = false)
286 IPC_END_MESSAGE_MAP() 300 IPC_END_MESSAGE_MAP()
287 if (handled) 301 if (handled)
288 return true; 302 return true;
289 303
290 return false; 304 return false;
291 } 305 }
292 306
293 bool GpuChildThread::OnConnect(shell::Connection* connection) {
294 // Use of base::Unretained(this) is safe here because |service_registry()|
295 // will be destroyed before GpuChildThread is destructed.
296 connection->GetInterfaceRegistry()->AddInterface(base::Bind(
297 &GpuChildThread::BindProcessControlRequest, base::Unretained(this)));
298
299 if (GetContentClient()->gpu()) { // NULL in tests.
300 GetContentClient()->gpu()->ExposeInterfacesToBrowser(
301 connection->GetInterfaceRegistry());
302 }
303
304 // We don't want to process any incoming interface requests until
305 // OnInitialize().
306 if (!gpu_channel_manager_) {
307 connection->GetInterfaceRegistry()->PauseBinding();
308 resume_interface_bindings_callback_ = base::Bind(
309 &shell::InterfaceRegistry::ResumeBinding,
310 connection->GetInterfaceRegistry()->GetWeakPtr());
311 }
312
313 return true;
314 }
315
316 shell::InterfaceRegistry* GpuChildThread::GetInterfaceRegistryForConnection() {
317 return nullptr;
318 }
319
320 shell::InterfaceProvider* GpuChildThread::GetInterfaceProviderForConnection() {
321 return nullptr;
322 }
323
324 void GpuChildThread::SetActiveURL(const GURL& url) { 307 void GpuChildThread::SetActiveURL(const GURL& url) {
325 GetContentClient()->SetActiveURL(url); 308 GetContentClient()->SetActiveURL(url);
326 } 309 }
327 310
328 void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) { 311 void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) {
329 Send(new GpuHostMsg_DidCreateOffscreenContext(active_url)); 312 Send(new GpuHostMsg_DidCreateOffscreenContext(active_url));
330 } 313 }
331 314
332 void GpuChildThread::DidDestroyChannel(int client_id) { 315 void GpuChildThread::DidDestroyChannel(int client_id) {
333 media_service_->RemoveChannel(client_id); 316 media_service_->RemoveChannel(client_id);
(...skipping 23 matching lines...) Expand all
357 } 340 }
358 #endif 341 #endif
359 342
360 void GpuChildThread::StoreShaderToDisk(int32_t client_id, 343 void GpuChildThread::StoreShaderToDisk(int32_t client_id,
361 const std::string& key, 344 const std::string& key,
362 const std::string& shader) { 345 const std::string& shader) {
363 Send(new GpuHostMsg_CacheShader(client_id, key, shader)); 346 Send(new GpuHostMsg_CacheShader(client_id, key, shader));
364 } 347 }
365 348
366 void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) { 349 void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) {
367 if (!resume_interface_bindings_callback_.is_null()) 350 GetInterfaceRegistry()->ResumeBinding();
368 base::ResetAndReturn(&resume_interface_bindings_callback_).Run();
369 351
370 gpu_preferences_ = gpu_preferences; 352 gpu_preferences_ = gpu_preferences;
371 353
372 gpu_info_.video_decode_accelerator_capabilities = 354 gpu_info_.video_decode_accelerator_capabilities =
373 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_); 355 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_);
374 gpu_info_.video_encode_accelerator_supported_profiles = 356 gpu_info_.video_encode_accelerator_supported_profiles =
375 media::GpuVideoEncodeAccelerator::GetSupportedProfiles( 357 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(
376 gpu_preferences_); 358 gpu_preferences_);
377 gpu_info_.jpeg_decode_accelerator_supported = 359 gpu_info_.jpeg_decode_accelerator_supported =
378 media::GpuJpegDecodeAccelerator::IsSupported(); 360 media::GpuJpegDecodeAccelerator::IsSupported();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 #endif 559 #endif
578 560
579 void GpuChildThread::OnLoseAllContexts() { 561 void GpuChildThread::OnLoseAllContexts() {
580 if (gpu_channel_manager_) { 562 if (gpu_channel_manager_) {
581 gpu_channel_manager_->DestroyAllChannels(); 563 gpu_channel_manager_->DestroyAllChannels();
582 media_service_->DestroyAllChannels(); 564 media_service_->DestroyAllChannels();
583 } 565 }
584 } 566 }
585 567
586 void GpuChildThread::BindProcessControlRequest( 568 void GpuChildThread::BindProcessControlRequest(
587 mojo::InterfaceRequest<mojom::ProcessControl> request) { 569 mojom::ProcessControlRequest request) {
588 DVLOG(1) << "GPU: Binding ProcessControl request"; 570 DVLOG(1) << "GPU: Binding ProcessControl request";
589 DCHECK(process_control_); 571 DCHECK(process_control_);
590 process_control_bindings_.AddBinding(process_control_.get(), 572 process_control_bindings_.AddBinding(process_control_.get(),
591 std::move(request)); 573 std::move(request));
592 } 574 }
593 575
594 } // namespace content 576 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698