diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-02 20:24:49 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-02 20:24:49 +0000 |
commit | 4cb4310995f3b92adceb1e44b792726f7fc8249c (patch) | |
tree | 1b8217ee615f97dee3e42aa5794488fb6e31f058 /content/browser/gpu | |
parent | 9d43955551544e2954c4e085c8b34c866543f38e (diff) | |
download | chromium_src-4cb4310995f3b92adceb1e44b792726f7fc8249c.zip chromium_src-4cb4310995f3b92adceb1e44b792726f7fc8249c.tar.gz chromium_src-4cb4310995f3b92adceb1e44b792726f7fc8249c.tar.bz2 |
Don't make classes derive from ChildProcessHost, and instead have them use it through composition. This cleans up the code and makes it easier to understand (as well as more closely conform to the Google C++ style guide). It also makes it possible to add an interface around ChildProcessHost in a future change.
BUG=98716
Review URL: http://codereview.chromium.org/8774040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112769 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/gpu')
-rw-r--r-- | content/browser/gpu/gpu_process_host.cc | 58 | ||||
-rw-r--r-- | content/browser/gpu/gpu_process_host.h | 2 |
2 files changed, 26 insertions, 34 deletions
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index cdaac3e..3b18d38 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -17,6 +17,7 @@ #include "content/browser/gpu/gpu_process_host_ui_shim.h" #include "content/browser/renderer_host/render_widget_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" +#include "content/common/child_process_host.h" #include "content/common/gpu/gpu_messages.h" #include "content/gpu/gpu_child_thread.h" #include "content/gpu/gpu_process.h" @@ -279,6 +280,25 @@ GpuProcessHost::GpuProcessHost(int host_id) GpuProcessHost::~GpuProcessHost() { DCHECK(CalledOnValidThread()); + + SendOutstandingReplies(); + UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", + DIED_FIRST_TIME + g_gpu_crash_count, + GPU_PROCESS_LIFETIME_EVENT_MAX); + + int exit_code; + base::TerminationStatus status = GetChildTerminationStatus(&exit_code); + UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessTerminationStatus", + status, + base::TERMINATION_STATUS_MAX_ENUM); + + if (status == base::TERMINATION_STATUS_NORMAL_TERMINATION || + status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { + UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessExitCode", + exit_code, + content::RESULT_CODE_LAST_CODE); + } + #if defined(OS_WIN) if (gpu_process_) CloseHandle(gpu_process_); @@ -299,14 +319,15 @@ GpuProcessHost::~GpuProcessHost() { } bool GpuProcessHost::Init() { - if (!CreateChannel()) + if (!child_process_host()->CreateChannel()) return false; if (in_process_) { CommandLine::ForCurrentProcess()->AppendSwitch( switches::kDisableGpuWatchdog); - in_process_gpu_thread_.reset(new GpuMainThread(channel_id())); + in_process_gpu_thread_.reset(new GpuMainThread( + child_process_host()->channel_id())); base::Thread::Options options; #if defined(OS_WIN) @@ -337,7 +358,7 @@ void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) { bool GpuProcessHost::Send(IPC::Message* msg) { DCHECK(CalledOnValidThread()); - if (opening_channel()) { + if (child_process_host()->opening_channel()) { queued_messages_.push(msg); return true; } @@ -488,10 +509,6 @@ void GpuProcessHost::OnGraphicsInfoCollected(const content::GPUInfo& gpu_info) { GpuDataManager::GetInstance()->UpdateGpuInfo(gpu_info); } -bool GpuProcessHost::CanShutdown() { - return true; -} - void GpuProcessHost::OnProcessLaunched() { // Send the GPU process handle to the UI thread before it has to // respond to any requests to establish a GPU channel. The response @@ -513,30 +530,6 @@ void GpuProcessHost::OnProcessLaunched() { #endif } -void GpuProcessHost::OnChildDied() { - SendOutstandingReplies(); - // Located in OnChildDied because OnProcessCrashed suffers from a race - // condition on Linux. - UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", - DIED_FIRST_TIME + g_gpu_crash_count, - GPU_PROCESS_LIFETIME_EVENT_MAX); - - int exit_code; - base::TerminationStatus status = GetChildTerminationStatus(&exit_code); - UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessTerminationStatus", - status, - base::TERMINATION_STATUS_MAX_ENUM); - - if (status == base::TERMINATION_STATUS_NORMAL_TERMINATION || - status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { - UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessExitCode", - exit_code, - content::RESULT_CODE_LAST_CODE); - } - - ChildProcessHost::OnChildDied(); -} - void GpuProcessHost::OnProcessCrashed(int exit_code) { SendOutstandingReplies(); if (++g_gpu_crash_count >= kGpuMaxCrashCount) { @@ -575,7 +568,8 @@ bool GpuProcessHost::LaunchGpuProcess() { CommandLine* cmd_line = new CommandLine(exe_path); cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kGpuProcess); - cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id()); + cmd_line->AppendSwitchASCII(switches::kProcessChannelID, + child_process_host()->channel_id()); // Propagate relevant command line switches. static const char* const kSwitchNames[] = { diff --git a/content/browser/gpu/gpu_process_host.h b/content/browser/gpu/gpu_process_host.h index e6ba2c0..073e8fd 100644 --- a/content/browser/gpu/gpu_process_host.h +++ b/content/browser/gpu/gpu_process_host.h @@ -92,9 +92,7 @@ class GpuProcessHost : public BrowserChildProcessHost, // Post an IPC message to the UI shim's message handler on the UI thread. void RouteOnUIThread(const IPC::Message& message); - virtual bool CanShutdown() OVERRIDE; virtual void OnProcessLaunched() OVERRIDE; - virtual void OnChildDied() OVERRIDE; virtual void OnProcessCrashed(int exit_code) OVERRIDE; // Message handlers. |