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

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

Issue 1736643005: Decouple Media Service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another try to fix Windows Created 4 years, 9 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/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/gpu/establish_channel_params.h" 17 #include "content/common/gpu/establish_channel_params.h"
18 #include "content/common/gpu/gpu_host_messages.h" 18 #include "content/common/gpu/gpu_host_messages.h"
19 #include "content/common/gpu/gpu_memory_buffer_factory.h" 19 #include "content/common/gpu/gpu_memory_buffer_factory.h"
20 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" 20 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
21 #include "content/common/gpu/media/media_service.h"
21 #include "content/gpu/gpu_process_control_impl.h" 22 #include "content/gpu/gpu_process_control_impl.h"
22 #include "content/gpu/gpu_watchdog_thread.h" 23 #include "content/gpu/gpu_watchdog_thread.h"
23 #include "content/public/common/content_client.h" 24 #include "content/public/common/content_client.h"
24 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.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/config/gpu_info_collector.h" 28 #include "gpu/config/gpu_info_collector.h"
28 #include "gpu/config/gpu_switches.h" 29 #include "gpu/config/gpu_switches.h"
29 #include "gpu/config/gpu_util.h" 30 #include "gpu/config/gpu_util.h"
30 #include "gpu/ipc/common/memory_stats.h" 31 #include "gpu/ipc/common/memory_stats.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 296
296 void GpuChildThread::AddSubscription(int32_t client_id, unsigned int target) { 297 void GpuChildThread::AddSubscription(int32_t client_id, unsigned int target) {
297 Send(new GpuHostMsg_AddSubscription(client_id, target)); 298 Send(new GpuHostMsg_AddSubscription(client_id, target));
298 } 299 }
299 300
300 void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) { 301 void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) {
301 Send(new GpuHostMsg_DidCreateOffscreenContext(active_url)); 302 Send(new GpuHostMsg_DidCreateOffscreenContext(active_url));
302 } 303 }
303 304
304 void GpuChildThread::DidDestroyChannel(int client_id) { 305 void GpuChildThread::DidDestroyChannel(int client_id) {
306 media_service_->RemoveChannel(client_id);
305 Send(new GpuHostMsg_DestroyChannel(client_id)); 307 Send(new GpuHostMsg_DestroyChannel(client_id));
306 } 308 }
307 309
308 void GpuChildThread::DidDestroyOffscreenContext(const GURL& active_url) { 310 void GpuChildThread::DidDestroyOffscreenContext(const GURL& active_url) {
309 Send(new GpuHostMsg_DidDestroyOffscreenContext(active_url)); 311 Send(new GpuHostMsg_DidDestroyOffscreenContext(active_url));
310 } 312 }
311 313
312 void GpuChildThread::DidLoseContext(bool offscreen, 314 void GpuChildThread::DidLoseContext(bool offscreen,
313 gpu::error::ContextLostReason reason, 315 gpu::error::ContextLostReason reason,
314 const GURL& active_url) { 316 const GURL& active_url) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // Defer creation of the render thread. This is to prevent it from handling 372 // Defer creation of the render thread. This is to prevent it from handling
371 // IPC messages before the sandbox has been enabled and all other necessary 373 // IPC messages before the sandbox has been enabled and all other necessary
372 // initialization has succeeded. 374 // initialization has succeeded.
373 gpu_channel_manager_.reset( 375 gpu_channel_manager_.reset(
374 new GpuChannelManager(gpu_preferences_, this, watchdog_thread_.get(), 376 new GpuChannelManager(gpu_preferences_, this, watchdog_thread_.get(),
375 base::ThreadTaskRunnerHandle::Get().get(), 377 base::ThreadTaskRunnerHandle::Get().get(),
376 ChildProcess::current()->io_task_runner(), 378 ChildProcess::current()->io_task_runner(),
377 ChildProcess::current()->GetShutDownEvent(), 379 ChildProcess::current()->GetShutDownEvent(),
378 sync_point_manager_, gpu_memory_buffer_factory_)); 380 sync_point_manager_, gpu_memory_buffer_factory_));
379 381
382 media_service_.reset(new MediaService(gpu_channel_manager_.get()));
383
380 #if defined(USE_OZONE) 384 #if defined(USE_OZONE)
381 ui::OzonePlatform::GetInstance() 385 ui::OzonePlatform::GetInstance()
382 ->GetGpuPlatformSupport() 386 ->GetGpuPlatformSupport()
383 ->OnChannelEstablished(this); 387 ->OnChannelEstablished(this);
384 #endif 388 #endif
385 } 389 }
386 390
387 void GpuChildThread::OnFinalize() { 391 void GpuChildThread::OnFinalize() {
388 // Quit the GPU process 392 // Quit the GPU process
389 base::MessageLoop::current()->QuitWhenIdle(); 393 base::MessageLoop::current()->QuitWhenIdle();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 gpu_channel_manager_->BufferPresented(params); 562 gpu_channel_manager_->BufferPresented(params);
559 } 563 }
560 #endif 564 #endif
561 565
562 void GpuChildThread::OnEstablishChannel(const EstablishChannelParams& params) { 566 void GpuChildThread::OnEstablishChannel(const EstablishChannelParams& params) {
563 if (!gpu_channel_manager_) 567 if (!gpu_channel_manager_)
564 return; 568 return;
565 569
566 IPC::ChannelHandle channel_handle = 570 IPC::ChannelHandle channel_handle =
567 gpu_channel_manager_->EstablishChannel(params); 571 gpu_channel_manager_->EstablishChannel(params);
572 media_service_->AddChannel(params.client_id);
568 Send(new GpuHostMsg_ChannelEstablished(channel_handle)); 573 Send(new GpuHostMsg_ChannelEstablished(channel_handle));
569 } 574 }
570 575
571 void GpuChildThread::OnCloseChannel(int32_t client_id) { 576 void GpuChildThread::OnCloseChannel(int32_t client_id) {
572 if (gpu_channel_manager_) 577 if (gpu_channel_manager_)
573 gpu_channel_manager_->RemoveChannel(client_id); 578 gpu_channel_manager_->RemoveChannel(client_id);
574 } 579 }
575 580
576 void GpuChildThread::OnLoadedShader(const std::string& shader) { 581 void GpuChildThread::OnLoadedShader(const std::string& shader) {
577 if (gpu_channel_manager_) 582 if (gpu_channel_manager_)
(...skipping 16 matching lines...) Expand all
594 } 599 }
595 600
596 #if defined(OS_ANDROID) 601 #if defined(OS_ANDROID)
597 void GpuChildThread::OnWakeUpGpu() { 602 void GpuChildThread::OnWakeUpGpu() {
598 if (gpu_channel_manager_) 603 if (gpu_channel_manager_)
599 gpu_channel_manager_->WakeUpGpu(); 604 gpu_channel_manager_->WakeUpGpu();
600 } 605 }
601 #endif 606 #endif
602 607
603 void GpuChildThread::OnLoseAllContexts() { 608 void GpuChildThread::OnLoseAllContexts() {
604 if (gpu_channel_manager_) 609 if (gpu_channel_manager_) {
605 gpu_channel_manager_->DestroyAllChannels(); 610 gpu_channel_manager_->DestroyAllChannels();
611 media_service_->DestroyAllChannels();
612 }
606 } 613 }
607 614
608 void GpuChildThread::BindProcessControlRequest( 615 void GpuChildThread::BindProcessControlRequest(
609 mojo::InterfaceRequest<ProcessControl> request) { 616 mojo::InterfaceRequest<ProcessControl> request) {
610 DVLOG(1) << "GPU: Binding ProcessControl request"; 617 DVLOG(1) << "GPU: Binding ProcessControl request";
611 DCHECK(process_control_); 618 DCHECK(process_control_);
612 process_control_bindings_.AddBinding(process_control_.get(), 619 process_control_bindings_.AddBinding(process_control_.get(),
613 std::move(request)); 620 std::move(request));
614 } 621 }
615 622
616 } // namespace content 623 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698