diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-22 21:48:08 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-22 21:48:08 +0000 |
commit | dfab861a44521b41d868a9749145026de2f0e245 (patch) | |
tree | a377fda01bb7f45e950248d810a2b1b5a8569a7e /chrome | |
parent | 212e68d1a025bea24cb2a3ca4f99f5206a871f99 (diff) | |
download | chromium_src-dfab861a44521b41d868a9749145026de2f0e245.zip chromium_src-dfab861a44521b41d868a9749145026de2f0e245.tar.gz chromium_src-dfab861a44521b41d868a9749145026de2f0e245.tar.bz2 |
Added GpuProcessHost::CanLaunchGpuProcess() and reorganized code to disble launching of GPU process based on crash rate.
BUG=61771
Review URL: http://codereview.chromium.org/5205006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67008 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/gpu_process_host.cc | 88 | ||||
-rw-r--r-- | chrome/browser/gpu_process_host.h | 3 |
2 files changed, 53 insertions, 38 deletions
diff --git a/chrome/browser/gpu_process_host.cc b/chrome/browser/gpu_process_host.cc index 0e4166a..639d100 100644 --- a/chrome/browser/gpu_process_host.cc +++ b/chrome/browser/gpu_process_host.cc @@ -83,46 +83,10 @@ bool GpuProcessHost::Init() { if (!CreateChannel()) return false; - const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); - CommandLine::StringType gpu_launcher = - browser_command_line.GetSwitchValueNative(switches::kGpuLauncher); - - FilePath exe_path = ChildProcessHost::GetChildPath(gpu_launcher.empty()); - if (exe_path.empty()) + if (!CanLaunchGpuProcess()) return false; - CommandLine* cmd_line = new CommandLine(exe_path); - cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kGpuProcess); - cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id()); - - // Propagate relevant command line switches. - static const char* const kSwitchNames[] = { - switches::kUseGL, - switches::kDisableGpuVsync, - switches::kDisableGpuWatchdog, - switches::kDisableLogging, - switches::kEnableAcceleratedDecoding, - switches::kEnableLogging, - switches::kGpuStartupDialog, - switches::kLoggingLevel, - }; - cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, - arraysize(kSwitchNames)); - - // If specified, prepend a launcher program to the command line. - if (!gpu_launcher.empty()) - cmd_line->PrependWrapper(gpu_launcher); - - Launch( -#if defined(OS_WIN) - FilePath(), -#elif defined(OS_POSIX) - false, // Never use the zygote (GPU plugin can't be sandboxed). - base::environment_vector(), -#endif - cmd_line); - - return true; + return LaunchGpuProcess(); } // static @@ -384,3 +348,51 @@ void GpuProcessHost::OnProcessCrashed() { BrowserChildProcessHost::OnProcessCrashed(); } +bool GpuProcessHost::CanLaunchGpuProcess() const { + // TODO(alokp): Answer based on crash rate. + return true; +} + +bool GpuProcessHost::LaunchGpuProcess() { + const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); + CommandLine::StringType gpu_launcher = + browser_command_line.GetSwitchValueNative(switches::kGpuLauncher); + + FilePath exe_path = ChildProcessHost::GetChildPath(gpu_launcher.empty()); + if (exe_path.empty()) + return false; + + CommandLine* cmd_line = new CommandLine(exe_path); + cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kGpuProcess); + cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id()); + + // Propagate relevant command line switches. + static const char* const kSwitchNames[] = { + switches::kUseGL, + switches::kDisableGpuVsync, + switches::kDisableGpuWatchdog, + switches::kDisableLogging, + switches::kEnableAcceleratedDecoding, + switches::kEnableLogging, + switches::kGpuStartupDialog, + switches::kLoggingLevel, + }; + cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, + arraysize(kSwitchNames)); + + // If specified, prepend a launcher program to the command line. + if (!gpu_launcher.empty()) + cmd_line->PrependWrapper(gpu_launcher); + + Launch( +#if defined(OS_WIN) + FilePath(), +#elif defined(OS_POSIX) + false, // Never use the zygote (GPU plugin can't be sandboxed). + base::environment_vector(), +#endif + cmd_line); + + return true; +} + diff --git a/chrome/browser/gpu_process_host.h b/chrome/browser/gpu_process_host.h index 5def042..3ee2ba6 100644 --- a/chrome/browser/gpu_process_host.h +++ b/chrome/browser/gpu_process_host.h @@ -107,6 +107,9 @@ class GpuProcessHost : public BrowserChildProcessHost, public NonThreadSafe { virtual bool CanShutdown(); virtual void OnProcessCrashed(); + bool CanLaunchGpuProcess() const; + bool LaunchGpuProcess(); + bool initialized_; bool initialized_successfully_; |