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

Side by Side Diff: content/browser/gpu/gpu_process_host.cc

Issue 1297953004: Support mojo applications in GPU process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 2 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/browser/gpu/gpu_process_host.h ('k') | content/browser/mojo/mojo_shell_context.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/browser/gpu/gpu_process_host.h" 5 #include "content/browser/gpu/gpu_process_host.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/base_switches.h" 8 #include "base/base_switches.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
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/command_line.h" 12 #include "base/command_line.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/sha1.h" 16 #include "base/sha1.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
19 #include "components/tracing/tracing_switches.h" 19 #include "components/tracing/tracing_switches.h"
20 #include "content/browser/browser_child_process_host_impl.h" 20 #include "content/browser/browser_child_process_host_impl.h"
21 #include "content/browser/gpu/compositor_util.h" 21 #include "content/browser/gpu/compositor_util.h"
22 #include "content/browser/gpu/gpu_data_manager_impl.h" 22 #include "content/browser/gpu/gpu_data_manager_impl.h"
23 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 23 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
24 #include "content/browser/gpu/gpu_surface_tracker.h" 24 #include "content/browser/gpu/gpu_surface_tracker.h"
25 #include "content/browser/gpu/shader_disk_cache.h" 25 #include "content/browser/gpu/shader_disk_cache.h"
26 #include "content/browser/mojo/mojo_application_host.h"
26 #include "content/browser/renderer_host/render_widget_host_impl.h" 27 #include "content/browser/renderer_host/render_widget_host_impl.h"
27 #include "content/common/child_process_host_impl.h" 28 #include "content/common/child_process_host_impl.h"
28 #include "content/common/gpu/gpu_messages.h" 29 #include "content/common/gpu/gpu_messages.h"
29 #include "content/common/in_process_child_thread_params.h" 30 #include "content/common/in_process_child_thread_params.h"
30 #include "content/common/view_messages.h" 31 #include "content/common/view_messages.h"
31 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/content_browser_client.h" 33 #include "content/public/browser/content_browser_client.h"
33 #include "content/public/browser/render_process_host.h" 34 #include "content/public/browser/render_process_host.h"
34 #include "content/public/browser/render_widget_host_view.h" 35 #include "content/public/browser/render_widget_host_view.h"
35 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 36 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 537
537 bool GpuProcessHost::Init() { 538 bool GpuProcessHost::Init() {
538 init_start_time_ = base::TimeTicks::Now(); 539 init_start_time_ = base::TimeTicks::Now();
539 540
540 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD); 541 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD);
541 542
542 std::string channel_id = process_->GetHost()->CreateChannel(); 543 std::string channel_id = process_->GetHost()->CreateChannel();
543 if (channel_id.empty()) 544 if (channel_id.empty())
544 return false; 545 return false;
545 546
547 if (!SetupMojo())
548 return false;
549
546 if (in_process_) { 550 if (in_process_) {
547 DCHECK_CURRENTLY_ON(BrowserThread::IO); 551 DCHECK_CURRENTLY_ON(BrowserThread::IO);
548 DCHECK(g_gpu_main_thread_factory); 552 DCHECK(g_gpu_main_thread_factory);
549 in_process_gpu_thread_.reset( 553 in_process_gpu_thread_.reset(
550 g_gpu_main_thread_factory(InProcessChildThreadParams( 554 g_gpu_main_thread_factory(InProcessChildThreadParams(
551 channel_id, base::MessageLoop::current()->task_runner()))); 555 channel_id, base::MessageLoop::current()->task_runner())));
552 base::Thread::Options options; 556 base::Thread::Options options;
553 #if defined(OS_WIN) 557 #if defined(OS_WIN)
554 // WGL needs to create its own window and pump messages on it. 558 // WGL needs to create its own window and pump messages on it.
555 options.message_loop_type = base::MessageLoop::TYPE_UI; 559 options.message_loop_type = base::MessageLoop::TYPE_UI;
(...skipping 12 matching lines...) Expand all
568 io_surface_manager_token_ = 572 io_surface_manager_token_ =
569 BrowserIOSurfaceManager::GetInstance()->GenerateGpuProcessToken(); 573 BrowserIOSurfaceManager::GetInstance()->GenerateGpuProcessToken();
570 // Note: A valid IOSurface manager token needs to be sent to the Gpu process 574 // Note: A valid IOSurface manager token needs to be sent to the Gpu process
571 // before any GpuMemoryBuffer allocation requests can be sent. 575 // before any GpuMemoryBuffer allocation requests can be sent.
572 Send(new ChildProcessMsg_SetIOSurfaceManagerToken(io_surface_manager_token_)); 576 Send(new ChildProcessMsg_SetIOSurfaceManagerToken(io_surface_manager_token_));
573 #endif 577 #endif
574 578
575 return true; 579 return true;
576 } 580 }
577 581
582 bool GpuProcessHost::SetupMojo() {
583 DCHECK(!mojo_application_host_);
584 mojo_application_host_.reset(new MojoApplicationHost);
585 return mojo_application_host_->Init();
586 }
587
578 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) { 588 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) {
579 BrowserThread::PostTask( 589 BrowserThread::PostTask(
580 BrowserThread::UI, 590 BrowserThread::UI,
581 FROM_HERE, 591 FROM_HERE,
582 base::Bind(&RouteToGpuProcessHostUIShimTask, host_id_, message)); 592 base::Bind(&RouteToGpuProcessHostUIShimTask, host_id_, message));
583 } 593 }
584 594
585 bool GpuProcessHost::Send(IPC::Message* msg) { 595 bool GpuProcessHost::Send(IPC::Message* msg) {
586 DCHECK(CalledOnValidThread()); 596 DCHECK(CalledOnValidThread());
587 if (process_->GetHost()->IsChannelOpening()) { 597 if (process_->GetHost()->IsChannelOpening()) {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 #if defined(OS_MACOSX) 895 #if defined(OS_MACOSX)
886 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( 896 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped(
887 const IPC::Message& message) { 897 const IPC::Message& message) {
888 RenderWidgetResizeHelper::PostGpuProcessMsg(host_id_, message); 898 RenderWidgetResizeHelper::PostGpuProcessMsg(host_id_, message);
889 } 899 }
890 #endif 900 #endif
891 901
892 void GpuProcessHost::OnProcessLaunched() { 902 void GpuProcessHost::OnProcessLaunched() {
893 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", 903 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime",
894 base::TimeTicks::Now() - init_start_time_); 904 base::TimeTicks::Now() - init_start_time_);
905
906 base::ProcessHandle handle;
907 if (in_process_)
908 handle = base::GetCurrentProcessHandle();
909 else
910 handle = process_->GetData().handle;
911
912 mojo_application_host_->Activate(this, handle);
895 } 913 }
896 914
897 void GpuProcessHost::OnProcessLaunchFailed() { 915 void GpuProcessHost::OnProcessLaunchFailed() {
898 RecordProcessCrash(); 916 RecordProcessCrash();
899 } 917 }
900 918
901 void GpuProcessHost::OnProcessCrashed(int exit_code) { 919 void GpuProcessHost::OnProcessCrashed(int exit_code) {
902 SendOutstandingReplies(); 920 SendOutstandingReplies();
903 RecordProcessCrash(); 921 RecordProcessCrash();
904 GpuDataManagerImpl::GetInstance()->ProcessCrashed( 922 GpuDataManagerImpl::GetInstance()->ProcessCrashed(
905 process_->GetTerminationStatus(true /* known_dead */, NULL)); 923 process_->GetTerminationStatus(true /* known_dead */, NULL));
906 } 924 }
907 925
926 ServiceRegistry* GpuProcessHost::GetServiceRegistry() {
927 return mojo_application_host_->service_registry();
928 }
929
908 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { 930 GpuProcessHost::GpuProcessKind GpuProcessHost::kind() {
909 return kind_; 931 return kind_;
910 } 932 }
911 933
912 void GpuProcessHost::ForceShutdown() { 934 void GpuProcessHost::ForceShutdown() {
913 // This is only called on the IO thread so no race against the constructor 935 // This is only called on the IO thread so no race against the constructor
914 // for another GpuProcessHost. 936 // for another GpuProcessHost.
915 if (g_gpu_process_hosts[kind_] == this) 937 if (g_gpu_process_hosts[kind_] == this)
916 g_gpu_process_hosts[kind_] = NULL; 938 g_gpu_process_hosts[kind_] = NULL;
917 939
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); 1172 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader");
1151 ClientIdToShaderCacheMap::iterator iter = 1173 ClientIdToShaderCacheMap::iterator iter =
1152 client_id_to_shader_cache_.find(client_id); 1174 client_id_to_shader_cache_.find(client_id);
1153 // If the cache doesn't exist then this is an off the record profile. 1175 // If the cache doesn't exist then this is an off the record profile.
1154 if (iter == client_id_to_shader_cache_.end()) 1176 if (iter == client_id_to_shader_cache_.end())
1155 return; 1177 return;
1156 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); 1178 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader);
1157 } 1179 }
1158 1180
1159 } // namespace content 1181 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | content/browser/mojo/mojo_shell_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698