diff options
author | gavinp@chromium.org <gavinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 15:47:08 +0000 |
---|---|---|
committer | gavinp@chromium.org <gavinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 15:47:08 +0000 |
commit | 665acb177ed2c3ce59ec2c1f70597856eebeae45 (patch) | |
tree | d54b85e333fd2438e9ea92e5bf204aa4a8b3b701 /chrome | |
parent | d8a58e44578fa646480cec37db3ddb40a5b673b7 (diff) | |
download | chromium_src-665acb177ed2c3ce59ec2c1f70597856eebeae45.zip chromium_src-665acb177ed2c3ce59ec2c1f70597856eebeae45.tar.gz chromium_src-665acb177ed2c3ce59ec2c1f70597856eebeae45.tar.bz2 |
Add histogram to track prerender sessions
BUG=70401
TEST=nope
Review URL: http://codereview.chromium.org/6340013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72800 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_main.cc | 16 | ||||
-rw-r--r-- | chrome/browser/browser_main.h | 5 | ||||
-rw-r--r-- | chrome/browser/prerender/prerender_manager.cc | 19 | ||||
-rw-r--r-- | chrome/browser/prerender/prerender_manager.h | 10 |
4 files changed, 41 insertions, 9 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index df290e3..f937f3f 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -56,6 +56,7 @@ #include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/pref_value_store.h" +#include "chrome/browser/prerender/prerender_manager.h" #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" #include "chrome/browser/printing/print_dialog_cloud.h" #include "chrome/browser/process_singleton.h" @@ -224,7 +225,7 @@ void BrowserMainParts::SetupFieldTrials() { ConnectionFieldTrial(); SocketTimeoutFieldTrial(); ProxyConnectionsFieldTrial(); - PrefetchFieldTrial(); + PrefetchAndPrerenderFieldTrial(); SpdyFieldTrial(); ConnectBackupJobsFieldTrial(); } @@ -429,7 +430,7 @@ void BrowserMainParts::SpdyFieldTrial() { // --disable-content-prefetch are set, use those to determine if // prefetch is enabled. Otherwise, randomly assign users to an A/B test for // prefetching. -void BrowserMainParts::PrefetchFieldTrial() { +void BrowserMainParts::PrefetchAndPrerenderFieldTrial() { if (parsed_command_line().HasSwitch(switches::kEnableContentPrefetch) || parsed_command_line().HasSwitch(switches::kEnablePagePrerender)) ResourceDispatcherHost::set_is_prefetch_enabled(true); @@ -448,6 +449,17 @@ void BrowserMainParts::PrefetchFieldTrial() { ResourceDispatcherHost::set_is_prefetch_enabled( trial_grp == yes_prefetch_grp); } + + PrerenderManager::PrerenderManagerMode prerender_mode = + PrerenderManager::PRERENDER_MODE_DISABLED; + if (parsed_command_line().HasSwitch(switches::kEnablePagePrerender)) + prerender_mode = PrerenderManager::PRERENDER_MODE_ENABLED; + else + prerender_mode = PrerenderManager::PRERENDER_MODE_DISABLED; + PrerenderManager::SetMode(prerender_mode); + + UMA_HISTOGRAM_ENUMERATION("Prerender.Sessions", prerender_mode, + PrerenderManager::PRERENDER_MODE_MAX); } // If neither --enable-connect-backup-jobs or --disable-connect-backup-jobs is diff --git a/chrome/browser/browser_main.h b/chrome/browser/browser_main.h index a8f5442..1c0b3711c 100644 --- a/chrome/browser/browser_main.h +++ b/chrome/browser/browser_main.h @@ -118,8 +118,9 @@ class BrowserMainParts { // A/B test for spdy when --use-spdy not set. void SpdyFieldTrial(); - // A/B test for prefetching with --(enable|disable)-prefetch not set. - void PrefetchFieldTrial(); + // A/B test for prefetching with --(enable|disable)-prefetch not set, + // some histograms tracking prerender sessions. + void PrefetchAndPrerenderFieldTrial(); // A/B test for automatically establishing a backup TCP connection when a // specified timeout value is reached. diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc index 0459058..9b90ef88 100644 --- a/chrome/browser/prerender/prerender_manager.cc +++ b/chrome/browser/prerender/prerender_manager.cc @@ -15,6 +15,20 @@ #include "chrome/browser/tab_contents/render_view_host_manager.h" #include "chrome/common/render_messages.h" +// static +PrerenderManager::PrerenderManagerMode PrerenderManager::mode_ = + PRERENDER_MODE_ENABLED; + +// static +PrerenderManager::PrerenderManagerMode PrerenderManager::GetMode() { + return mode_; +} + +// static +void PrerenderManager::SetMode(PrerenderManagerMode mode) { + mode_ = mode; +} + struct PrerenderManager::PrerenderContentsData { PrerenderContents* contents_; base::Time start_time_; @@ -33,8 +47,7 @@ PrerenderManager::PrerenderManager(Profile* profile) max_prerender_age_(base::TimeDelta::FromSeconds( kDefaultMaxPrerenderAgeSeconds)), max_elements_(kDefaultMaxPrerenderElements), - prerender_contents_factory_(PrerenderContents::CreateFactory()), - mode_(PRERENDER_MODE_ENABLED) { + prerender_contents_factory_(PrerenderContents::CreateFactory()) { } PrerenderManager::~PrerenderManager() { @@ -154,7 +167,7 @@ PrerenderContents* PrerenderManager::CreatePrerenderContents( } void PrerenderManager::RecordPerceivedPageLoadTime(base::TimeDelta pplt) { - switch(mode_) { + switch (mode_) { case PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP: UMA_HISTOGRAM_TIMES("PLT.PerceivedPageLoadTime_PrerenderControl", pplt); break; diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h index 62967d8..bb65b44 100644 --- a/chrome/browser/prerender/prerender_manager.h +++ b/chrome/browser/prerender/prerender_manager.h @@ -22,11 +22,14 @@ class TabContents; // views of webpages. class PrerenderManager : public base::RefCounted<PrerenderManager> { public: + // PrerenderManagerMode is used in a UMA_HISTOGRAM, so please do not + // add in the middle. enum PrerenderManagerMode { PRERENDER_MODE_DISABLED, PRERENDER_MODE_ENABLED, PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP, - PRERENDER_MODE_EXPERIMENT_PRERENDER_GROUP + PRERENDER_MODE_EXPERIMENT_PRERENDER_GROUP, + PRERENDER_MODE_MAX }; // Owned by a Profile object for the lifetime of the profile. @@ -59,6 +62,9 @@ class PrerenderManager : public base::RefCounted<PrerenderManager> { unsigned int max_elements() const { return max_elements_; } void set_max_elements(unsigned int num) { max_elements_ = num; } + static PrerenderManagerMode GetMode(); + static void SetMode(PrerenderManagerMode mode); + protected: virtual ~PrerenderManager(); @@ -100,7 +106,7 @@ class PrerenderManager : public base::RefCounted<PrerenderManager> { scoped_ptr<PrerenderContents::Factory> prerender_contents_factory_; - PrerenderManagerMode mode_; + static PrerenderManagerMode mode_; DISALLOW_COPY_AND_ASSIGN(PrerenderManager); }; |