Index: chrome/browser/browser_main_win.cc |
=================================================================== |
--- chrome/browser/browser_main_win.cc (revision 95298) |
+++ chrome/browser/browser_main_win.cc (working copy) |
@@ -90,12 +90,9 @@ |
::GetProcessTimes(::GetCurrentProcess(), &creation_time, &ignore, &ignore, |
&ignore); |
- base::TimeDelta elapsed_from_startup = |
- base::Time::Now() - base::Time::FromFileTime(creation_time); |
- |
- // Record the time to present in a histogram. |
- UMA_HISTOGRAM_MEDIUM_TIMES("Startup.BrowserMessageLoopStartTime", |
- elapsed_from_startup); |
+ RecordPreReadExperimentTime( |
+ "Startup.BrowserMessageLoopStartTime", |
+ base::Time::Now() - base::Time::FromFileTime(creation_time)); |
} |
int AskForUninstallConfirmation() { |
@@ -276,6 +273,46 @@ |
return false; |
} |
+// This code is specific to the Windows-only PreReadExperiment field-trial. |
+static 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); |
+ DCHECK(counter != NULL); |
jar (doing other things)
2011/08/04 19:11:03
nit: I always think it is strange to DCHECK (or CH
chrisha
2011/08/04 19:19:06
Removed.
|
+ |
+ counter->AddTime(time); |
+} |
+ |
+// This code is specific to the Windows-only PreReadExperiment field-trial. |
+void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { |
+ DCHECK(name != NULL); |
+ |
+ static const char kEnvVar[] = "CHROME_PRE_READ_EXPERIMENT"; |
+ |
+ // 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); |
+ |
+ scoped_ptr<base::Environment> env(base::Environment::Create()); |
+ DCHECK(env.get() != NULL); |
+ |
+ // Only record the sub-histogram result if the experiment is running |
+ // (environment variable is set, and valid). |
+ std::string pre_read; |
+ if (env->GetVar(kEnvVar, &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); |
+ } |
+} |
+ |
// BrowserMainPartsWin --------------------------------------------------------- |
class BrowserMainPartsWin : public BrowserMainParts { |