Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2185)

Unified Diff: chrome/browser/browser_main.cc

Issue 7712014: Make a channel and time limited persistent PreRead experiment (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browser_main.h ('k') | chrome/browser/browser_main_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_main.cc
===================================================================
--- chrome/browser/browser_main.cc (revision 98422)
+++ chrome/browser/browser_main.cc (working copy)
@@ -165,6 +165,7 @@
#include <commctrl.h>
#include <shellapi.h>
+#include "base/environment.h" // For PreRead experiment.
#include "base/win/scoped_com_initializer.h"
#include "base/win/windows_version.h"
#include "chrome/browser/browser_trial.h"
@@ -814,6 +815,20 @@
}
#endif // #if defined(USE_LINUX_BREAKPAD)
+// This code is specific to the Windows-only PreReadExperiment field-trial.
+void AddPreReadHistogramTime(const char* name, base::TimeDelta time) {
+ const base::TimeDelta kMin(base::TimeDelta::FromMilliseconds(1));
+ const base::TimeDelta kMax(base::TimeDelta::FromHours(1));
+ static const size_t kBuckets(100);
+
+ // FactoryTimeGet will always return a pointer to the same histogram object,
+ // keyed on its name. There's no need for us to store it explicitly anywhere.
+ base::Histogram* counter = base::Histogram::FactoryTimeGet(
+ name, kMin, kMax, kBuckets, base::Histogram::kUmaTargetedHistogramFlag);
+
+ counter->AddTime(time);
+}
+
} // namespace
namespace chrome_browser {
@@ -2053,12 +2068,8 @@
if (pool)
pool->Recycle();
- UMA_HISTOGRAM_CUSTOM_TIMES(
- "Startup.BrowserOpenTabs",
- base::TimeTicks::Now() - browser_open_start,
- base::TimeDelta::FromMilliseconds(1),
- base::TimeDelta::FromHours(1),
- 100);
+ RecordPreReadExperimentTime("Startup.BrowserOpenTabs",
+ base::TimeTicks::Now() - browser_open_start);
// TODO(mad): Move this call in a proper place on CrOS.
// http://crosbug.com/17687
@@ -2153,3 +2164,30 @@
TRACE_EVENT_END_ETW("BrowserMain", 0, 0);
return result_code;
}
+
+// This code is specific to the Windows-only PreReadExperiment field-trial.
+void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) {
+ DCHECK(name != NULL);
+
+ // This gets called with different histogram names, so we don't want to use
+ // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the
+ // first call wins.
+ AddPreReadHistogramTime(name, time);
+
+#if defined(OS_WIN)
+ // The pre-read experiment is Windows specific.
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+
+ // Only record the sub-histogram result if the experiment is running
+ // (environment variable is set, and valid).
+ std::string pre_read;
+ if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) &&
+ (pre_read == "0" || pre_read == "1")) {
+ std::string uma_name(name);
+ uma_name += "_PreRead";
+ uma_name += pre_read == "1" ? "Enabled" : "Disabled";
+ AddPreReadHistogramTime(uma_name.c_str(), time);
+ }
+#endif
+}
+
« no previous file with comments | « chrome/browser/browser_main.h ('k') | chrome/browser/browser_main_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698