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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browser_main.h" 5 #include "chrome/browser/browser_main.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // TODO(port): several win-only methods have been pulled out of this, but 158 // TODO(port): several win-only methods have been pulled out of this, but
159 // BrowserMain() as a whole needs to be broken apart so that it's usable by 159 // BrowserMain() as a whole needs to be broken apart so that it's usable by
160 // other platforms. For now, it's just a stub. This is a serious work in 160 // other platforms. For now, it's just a stub. This is a serious work in
161 // progress and should not be taken as an indication of a real refactoring. 161 // progress and should not be taken as an indication of a real refactoring.
162 162
163 #if defined(OS_WIN) 163 #if defined(OS_WIN)
164 #include <windows.h> 164 #include <windows.h>
165 #include <commctrl.h> 165 #include <commctrl.h>
166 #include <shellapi.h> 166 #include <shellapi.h>
167 167
168 #include "base/environment.h" // For PreRead experiment.
168 #include "base/win/scoped_com_initializer.h" 169 #include "base/win/scoped_com_initializer.h"
169 #include "base/win/windows_version.h" 170 #include "base/win/windows_version.h"
170 #include "chrome/browser/browser_trial.h" 171 #include "chrome/browser/browser_trial.h"
171 #include "chrome/browser/browser_util_win.h" 172 #include "chrome/browser/browser_util_win.h"
172 #include "chrome/browser/first_run/try_chrome_dialog_view.h" 173 #include "chrome/browser/first_run/try_chrome_dialog_view.h"
173 #include "chrome/browser/first_run/upgrade_util_win.h" 174 #include "chrome/browser/first_run/upgrade_util_win.h"
174 #include "chrome/browser/net/url_fixer_upper.h" 175 #include "chrome/browser/net/url_fixer_upper.h"
175 #include "chrome/browser/rlz/rlz.h" 176 #include "chrome/browser/rlz/rlz.h"
176 #include "chrome/browser/ui/views/user_data_dir_dialog.h" 177 #include "chrome/browser/ui/views/user_data_dir_dialog.h"
177 #include "chrome/installer/util/helper.h" 178 #include "chrome/installer/util/helper.h"
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 CHECK(metrics_reporting_enabled); 808 CHECK(metrics_reporting_enabled);
808 bool breakpad_enabled = 809 bool breakpad_enabled =
809 local_state->GetBoolean(prefs::kMetricsReportingEnabled); 810 local_state->GetBoolean(prefs::kMetricsReportingEnabled);
810 if (!breakpad_enabled && metrics_reporting_enabled->IsUserModifiable()) 811 if (!breakpad_enabled && metrics_reporting_enabled->IsUserModifiable())
811 breakpad_enabled = getenv(env_vars::kHeadless) != NULL; 812 breakpad_enabled = getenv(env_vars::kHeadless) != NULL;
812 #endif // #if defined(OS_CHROMEOS) 813 #endif // #if defined(OS_CHROMEOS)
813 return breakpad_enabled; 814 return breakpad_enabled;
814 } 815 }
815 #endif // #if defined(USE_LINUX_BREAKPAD) 816 #endif // #if defined(USE_LINUX_BREAKPAD)
816 817
818 // This code is specific to the Windows-only PreReadExperiment field-trial.
819 void AddPreReadHistogramTime(const char* name, base::TimeDelta time) {
820 const base::TimeDelta kMin(base::TimeDelta::FromMilliseconds(1));
821 const base::TimeDelta kMax(base::TimeDelta::FromHours(1));
822 static const size_t kBuckets(100);
823
824 // FactoryTimeGet will always return a pointer to the same histogram object,
825 // keyed on its name. There's no need for us to store it explicitly anywhere.
826 base::Histogram* counter = base::Histogram::FactoryTimeGet(
827 name, kMin, kMax, kBuckets, base::Histogram::kUmaTargetedHistogramFlag);
828
829 counter->AddTime(time);
830 }
831
817 } // namespace 832 } // namespace
818 833
819 namespace chrome_browser { 834 namespace chrome_browser {
820 // This error message is not localized because we failed to load the 835 // This error message is not localized because we failed to load the
821 // localization data files. 836 // localization data files.
822 const char kMissingLocaleDataTitle[] = "Missing File Error"; 837 const char kMissingLocaleDataTitle[] = "Missing File Error";
823 const char kMissingLocaleDataMessage[] = 838 const char kMissingLocaleDataMessage[] =
824 "Unable to find locale data files. Please reinstall."; 839 "Unable to find locale data files. Please reinstall.";
825 } // namespace chrome_browser 840 } // namespace chrome_browser
826 841
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 upgrade_util::SaveLastModifiedTimeOfExe(); 2054 upgrade_util::SaveLastModifiedTimeOfExe();
2040 #endif 2055 #endif
2041 2056
2042 // Record now as the last successful chrome start. 2057 // Record now as the last successful chrome start.
2043 GoogleUpdateSettings::SetLastRunTime(); 2058 GoogleUpdateSettings::SetLastRunTime();
2044 // Call Recycle() here as late as possible, before going into the loop 2059 // Call Recycle() here as late as possible, before going into the loop
2045 // because Start() will add things to it while creating the main window. 2060 // because Start() will add things to it while creating the main window.
2046 if (pool) 2061 if (pool)
2047 pool->Recycle(); 2062 pool->Recycle();
2048 2063
2049 UMA_HISTOGRAM_CUSTOM_TIMES( 2064 RecordPreReadExperimentTime("Startup.BrowserOpenTabs",
2050 "Startup.BrowserOpenTabs", 2065 base::TimeTicks::Now() - browser_open_start);
2051 base::TimeTicks::Now() - browser_open_start,
2052 base::TimeDelta::FromMilliseconds(1),
2053 base::TimeDelta::FromHours(1),
2054 100);
2055 2066
2056 // TODO(mad): Move this call in a proper place on CrOS. 2067 // TODO(mad): Move this call in a proper place on CrOS.
2057 // http://crosbug.com/17687 2068 // http://crosbug.com/17687
2058 #if !defined(OS_CHROMEOS) 2069 #if !defined(OS_CHROMEOS)
2059 // If we're running tests (ui_task is non-null), then we don't want to 2070 // If we're running tests (ui_task is non-null), then we don't want to
2060 // call FetchLanguageListFromTranslateServer 2071 // call FetchLanguageListFromTranslateServer
2061 if (parameters.ui_task == NULL && translate_manager != NULL) { 2072 if (parameters.ui_task == NULL && translate_manager != NULL) {
2062 // TODO(willchan): Get rid of this after TranslateManager doesn't use 2073 // TODO(willchan): Get rid of this after TranslateManager doesn't use
2063 // the default request context. http://crbug.com/89396. 2074 // the default request context. http://crbug.com/89396.
2064 // This is necessary to force |default_request_context_| to be 2075 // This is necessary to force |default_request_context_| to be
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2139 #if defined(OS_CHROMEOS) 2150 #if defined(OS_CHROMEOS)
2140 // To be precise, logout (browser shutdown) is not yet done, but the 2151 // To be precise, logout (browser shutdown) is not yet done, but the
2141 // remaining work is negligible, hence we say LogoutDone here. 2152 // remaining work is negligible, hence we say LogoutDone here.
2142 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", 2153 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone",
2143 false); 2154 false);
2144 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); 2155 chromeos::BootTimesLoader::Get()->WriteLogoutTimes();
2145 #endif 2156 #endif
2146 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); 2157 TRACE_EVENT_END_ETW("BrowserMain", 0, 0);
2147 return result_code; 2158 return result_code;
2148 } 2159 }
2160
2161 // This code is specific to the Windows-only PreReadExperiment field-trial.
2162 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) {
2163 DCHECK(name != NULL);
2164
2165 // This gets called with different histogram names, so we don't want to use
2166 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the
2167 // first call wins.
2168 AddPreReadHistogramTime(name, time);
2169
2170 #if defined(OS_WIN)
2171 // The pre-read experiment is Windows specific.
2172 scoped_ptr<base::Environment> env(base::Environment::Create());
2173
2174 // Only record the sub-histogram result if the experiment is running
2175 // (environment variable is set, and valid).
2176 std::string pre_read;
2177 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) &&
2178 (pre_read == "0" || pre_read == "1")) {
2179 std::string uma_name(name);
2180 uma_name += "_PreRead";
2181 uma_name += pre_read == "1" ? "Enabled" : "Disabled";
2182 AddPreReadHistogramTime(uma_name.c_str(), time);
2183 }
2184 #endif
2185 }
2186
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698