Commit 665acb17 authored by gavinp@chromium.org's avatar gavinp@chromium.org

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
parent d8a58e44
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/pref_value_store.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/cloud_print/cloud_print_proxy_service.h"
#include "chrome/browser/printing/print_dialog_cloud.h" #include "chrome/browser/printing/print_dialog_cloud.h"
#include "chrome/browser/process_singleton.h" #include "chrome/browser/process_singleton.h"
...@@ -224,7 +225,7 @@ void BrowserMainParts::SetupFieldTrials() { ...@@ -224,7 +225,7 @@ void BrowserMainParts::SetupFieldTrials() {
ConnectionFieldTrial(); ConnectionFieldTrial();
SocketTimeoutFieldTrial(); SocketTimeoutFieldTrial();
ProxyConnectionsFieldTrial(); ProxyConnectionsFieldTrial();
PrefetchFieldTrial(); PrefetchAndPrerenderFieldTrial();
SpdyFieldTrial(); SpdyFieldTrial();
ConnectBackupJobsFieldTrial(); ConnectBackupJobsFieldTrial();
} }
...@@ -429,7 +430,7 @@ void BrowserMainParts::SpdyFieldTrial() { ...@@ -429,7 +430,7 @@ void BrowserMainParts::SpdyFieldTrial() {
// --disable-content-prefetch are set, use those to determine if // --disable-content-prefetch are set, use those to determine if
// prefetch is enabled. Otherwise, randomly assign users to an A/B test for // prefetch is enabled. Otherwise, randomly assign users to an A/B test for
// prefetching. // prefetching.
void BrowserMainParts::PrefetchFieldTrial() { void BrowserMainParts::PrefetchAndPrerenderFieldTrial() {
if (parsed_command_line().HasSwitch(switches::kEnableContentPrefetch) || if (parsed_command_line().HasSwitch(switches::kEnableContentPrefetch) ||
parsed_command_line().HasSwitch(switches::kEnablePagePrerender)) parsed_command_line().HasSwitch(switches::kEnablePagePrerender))
ResourceDispatcherHost::set_is_prefetch_enabled(true); ResourceDispatcherHost::set_is_prefetch_enabled(true);
...@@ -448,6 +449,17 @@ void BrowserMainParts::PrefetchFieldTrial() { ...@@ -448,6 +449,17 @@ void BrowserMainParts::PrefetchFieldTrial() {
ResourceDispatcherHost::set_is_prefetch_enabled( ResourceDispatcherHost::set_is_prefetch_enabled(
trial_grp == yes_prefetch_grp); 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 // If neither --enable-connect-backup-jobs or --disable-connect-backup-jobs is
......
...@@ -118,8 +118,9 @@ class BrowserMainParts { ...@@ -118,8 +118,9 @@ class BrowserMainParts {
// A/B test for spdy when --use-spdy not set. // A/B test for spdy when --use-spdy not set.
void SpdyFieldTrial(); void SpdyFieldTrial();
// A/B test for prefetching with --(enable|disable)-prefetch not set. // A/B test for prefetching with --(enable|disable)-prefetch not set,
void PrefetchFieldTrial(); // some histograms tracking prerender sessions.
void PrefetchAndPrerenderFieldTrial();
// A/B test for automatically establishing a backup TCP connection when a // A/B test for automatically establishing a backup TCP connection when a
// specified timeout value is reached. // specified timeout value is reached.
......
...@@ -15,6 +15,20 @@ ...@@ -15,6 +15,20 @@
#include "chrome/browser/tab_contents/render_view_host_manager.h" #include "chrome/browser/tab_contents/render_view_host_manager.h"
#include "chrome/common/render_messages.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 { struct PrerenderManager::PrerenderContentsData {
PrerenderContents* contents_; PrerenderContents* contents_;
base::Time start_time_; base::Time start_time_;
...@@ -33,8 +47,7 @@ PrerenderManager::PrerenderManager(Profile* profile) ...@@ -33,8 +47,7 @@ PrerenderManager::PrerenderManager(Profile* profile)
max_prerender_age_(base::TimeDelta::FromSeconds( max_prerender_age_(base::TimeDelta::FromSeconds(
kDefaultMaxPrerenderAgeSeconds)), kDefaultMaxPrerenderAgeSeconds)),
max_elements_(kDefaultMaxPrerenderElements), max_elements_(kDefaultMaxPrerenderElements),
prerender_contents_factory_(PrerenderContents::CreateFactory()), prerender_contents_factory_(PrerenderContents::CreateFactory()) {
mode_(PRERENDER_MODE_ENABLED) {
} }
PrerenderManager::~PrerenderManager() { PrerenderManager::~PrerenderManager() {
...@@ -154,7 +167,7 @@ PrerenderContents* PrerenderManager::CreatePrerenderContents( ...@@ -154,7 +167,7 @@ PrerenderContents* PrerenderManager::CreatePrerenderContents(
} }
void PrerenderManager::RecordPerceivedPageLoadTime(base::TimeDelta pplt) { void PrerenderManager::RecordPerceivedPageLoadTime(base::TimeDelta pplt) {
switch(mode_) { switch (mode_) {
case PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP: case PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP:
UMA_HISTOGRAM_TIMES("PLT.PerceivedPageLoadTime_PrerenderControl", pplt); UMA_HISTOGRAM_TIMES("PLT.PerceivedPageLoadTime_PrerenderControl", pplt);
break; break;
......
...@@ -22,11 +22,14 @@ class TabContents; ...@@ -22,11 +22,14 @@ class TabContents;
// views of webpages. // views of webpages.
class PrerenderManager : public base::RefCounted<PrerenderManager> { class PrerenderManager : public base::RefCounted<PrerenderManager> {
public: public:
// PrerenderManagerMode is used in a UMA_HISTOGRAM, so please do not
// add in the middle.
enum PrerenderManagerMode { enum PrerenderManagerMode {
PRERENDER_MODE_DISABLED, PRERENDER_MODE_DISABLED,
PRERENDER_MODE_ENABLED, PRERENDER_MODE_ENABLED,
PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP, 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. // Owned by a Profile object for the lifetime of the profile.
...@@ -59,6 +62,9 @@ class PrerenderManager : public base::RefCounted<PrerenderManager> { ...@@ -59,6 +62,9 @@ class PrerenderManager : public base::RefCounted<PrerenderManager> {
unsigned int max_elements() const { return max_elements_; } unsigned int max_elements() const { return max_elements_; }
void set_max_elements(unsigned int num) { max_elements_ = num; } void set_max_elements(unsigned int num) { max_elements_ = num; }
static PrerenderManagerMode GetMode();
static void SetMode(PrerenderManagerMode mode);
protected: protected:
virtual ~PrerenderManager(); virtual ~PrerenderManager();
...@@ -100,7 +106,7 @@ class PrerenderManager : public base::RefCounted<PrerenderManager> { ...@@ -100,7 +106,7 @@ class PrerenderManager : public base::RefCounted<PrerenderManager> {
scoped_ptr<PrerenderContents::Factory> prerender_contents_factory_; scoped_ptr<PrerenderContents::Factory> prerender_contents_factory_;
PrerenderManagerMode mode_; static PrerenderManagerMode mode_;
DISALLOW_COPY_AND_ASSIGN(PrerenderManager); DISALLOW_COPY_AND_ASSIGN(PrerenderManager);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment