From 92b35138bdeb1b4bc7cb0498e2ce742115e7e811 Mon Sep 17 00:00:00 2001 From: "apatrick@chromium.org" Date: Tue, 10 Aug 2010 00:18:24 +0000 Subject: Prelaunch GPU process after 10 seconds. This will happen if the --prelaunch-gpu-process command line switch is present or for 5% of users in a field trial. This is so we can collect some stats of GPU capabilities. TEST=try, check --prelaunch-gpu-process works BUG=none Review URL: http://codereview.chromium.org/3119002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55510 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/render_thread.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'chrome/renderer') diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index 8ea6c08..cefea46 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -10,6 +10,7 @@ #include #include "base/command_line.h" +#include "base/field_trial.h" #include "base/lazy_instance.h" #include "base/logging.h" #include "base/nullable_string16.h" @@ -116,6 +117,9 @@ static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */; static const double kInitialExtensionIdleHandlerDelayS = 5.0 /* seconds */; static const int64 kMaxExtensionIdleHandlerDelayS = 5*60 /* seconds */; +static const int kPrelauchGpuPercentage = 5; +static const int kPrelauchGpuProcessDelayMS = 10000; + // Keep the global RenderThread in a TLS slot so it is impossible to access // incorrectly from the wrong thread. static base::LazyInstance > lazy_tls( @@ -268,10 +272,19 @@ void RenderThread::Init() { // Establish a channel to the GPU process asynchronously if requested. If the // channel is established in time, EstablishGpuChannelSync will not block when - // it is later called. - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kPrelaunchGpuProcess)) { - EstablishGpuChannel(); + // it is later called. Delays by a fixed period of time to avoid loading the + // GPU immediately in an attempt to not slow startup time. + scoped_refptr prelaunch_trial( + new FieldTrial("PrelaunchGpuProcessExperiment", 100)); + int prelaunch_group = prelaunch_trial->AppendGroup("prelaunch_gpu_process", + kPrelauchGpuPercentage); + if (prelaunch_group == prelaunch_trial->group() || + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kPrelaunchGpuProcess)) { + message_loop()->PostDelayedTask(FROM_HERE, + task_factory_->NewRunnableMethod( + &RenderThread::EstablishGpuChannel), + kPrelauchGpuProcessDelayMS); } } -- cgit v1.1