OLD | NEW |
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 Loading... |
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 DCHECK_NE(result, socket_policy + num_groups) | 221 DCHECK_NE(result, socket_policy + num_groups) |
221 << "Not a valid socket reuse policy group"; | 222 << "Not a valid socket reuse policy group"; |
222 net::SetSocketReusePolicy(result - socket_policy); | 223 net::SetSocketReusePolicy(result - socket_policy); |
223 } | 224 } |
224 } | 225 } |
225 | 226 |
226 namespace net { | 227 namespace net { |
227 class NetLog; | 228 class NetLog; |
228 } // namespace net | 229 } // namespace net |
229 | 230 |
| 231 // This code is specific to the Windows-only PreReadExperiment field-trial. |
| 232 static void AddPreReadHistogramTime(const char* name, base::TimeDelta time) { |
| 233 const base::TimeDelta kMin(base::TimeDelta::FromMilliseconds(1)); |
| 234 const base::TimeDelta kMax(base::TimeDelta::FromHours(1)); |
| 235 static const size_t kBuckets(100); |
| 236 |
| 237 // FactoryTimeGet will always return a pointer to the same histogram object, |
| 238 // keyed on its name. There's no need for us to store it explicitly anywhere. |
| 239 base::Histogram* counter = base::Histogram::FactoryTimeGet( |
| 240 name, kMin, kMax, kBuckets, base::Histogram::kUmaTargetedHistogramFlag); |
| 241 |
| 242 counter->AddTime(time); |
| 243 } |
| 244 |
| 245 // This code is specific to the Windows-only PreReadExperiment field-trial. |
| 246 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { |
| 247 DCHECK(name != NULL); |
| 248 |
| 249 // This gets called with different histogram names, so we don't want to use |
| 250 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the |
| 251 // first call wins. |
| 252 AddPreReadHistogramTime(name, time); |
| 253 |
| 254 #if defined(OS_WIN) |
| 255 static const char kEnvVar[] = "CHROME_PRE_READ_EXPERIMENT"; |
| 256 |
| 257 // The pre-read experiment is Windows specific. |
| 258 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 259 DCHECK(env.get() != NULL); |
| 260 |
| 261 // Only record the sub-histogram result if the experiment is running |
| 262 // (environment variable is set, and valid). |
| 263 std::string pre_read; |
| 264 if (env->GetVar(kEnvVar, &pre_read) && (pre_read == "0" || pre_read == "1")) { |
| 265 std::string uma_name(name); |
| 266 uma_name += "_PreRead"; |
| 267 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
| 268 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 269 } |
| 270 #endif |
| 271 } |
| 272 |
230 // BrowserMainParts ------------------------------------------------------------ | 273 // BrowserMainParts ------------------------------------------------------------ |
231 | 274 |
232 BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters) | 275 BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters) |
233 : parameters_(parameters), | 276 : parameters_(parameters), |
234 parsed_command_line_(parameters.command_line_) { | 277 parsed_command_line_(parameters.command_line_) { |
235 } | 278 } |
236 | 279 |
237 BrowserMainParts::~BrowserMainParts() { | 280 BrowserMainParts::~BrowserMainParts() { |
238 } | 281 } |
239 | 282 |
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2019 upgrade_util::SaveLastModifiedTimeOfExe(); | 2062 upgrade_util::SaveLastModifiedTimeOfExe(); |
2020 #endif | 2063 #endif |
2021 | 2064 |
2022 // Record now as the last successful chrome start. | 2065 // Record now as the last successful chrome start. |
2023 GoogleUpdateSettings::SetLastRunTime(); | 2066 GoogleUpdateSettings::SetLastRunTime(); |
2024 // Call Recycle() here as late as possible, before going into the loop | 2067 // Call Recycle() here as late as possible, before going into the loop |
2025 // because Start() will add things to it while creating the main window. | 2068 // because Start() will add things to it while creating the main window. |
2026 if (pool) | 2069 if (pool) |
2027 pool->Recycle(); | 2070 pool->Recycle(); |
2028 | 2071 |
2029 UMA_HISTOGRAM_MEDIUM_TIMES("Startup.BrowserOpenTabs", | 2072 RecordPreReadExperimentTime("Startup.BrowserOpenTabs", |
2030 base::TimeTicks::Now() - browser_open_start); | 2073 base::TimeTicks::Now() - browser_open_start); |
2031 | 2074 |
2032 // TODO(mad): Move this call in a proper place on CrOS. | 2075 // TODO(mad): Move this call in a proper place on CrOS. |
2033 // http://crosbug.com/17687 | 2076 // http://crosbug.com/17687 |
2034 #if !defined(OS_CHROMEOS) | 2077 #if !defined(OS_CHROMEOS) |
2035 // If we're running tests (ui_task is non-null), then we don't want to | 2078 // If we're running tests (ui_task is non-null), then we don't want to |
2036 // call FetchLanguageListFromTranslateServer | 2079 // call FetchLanguageListFromTranslateServer |
2037 if (parameters.ui_task == NULL && translate_manager != NULL) { | 2080 if (parameters.ui_task == NULL && translate_manager != NULL) { |
2038 // TODO(willchan): Get rid of this after TranslateManager doesn't use | 2081 // TODO(willchan): Get rid of this after TranslateManager doesn't use |
2039 // the default request context. http://crbug.com/89396. | 2082 // the default request context. http://crbug.com/89396. |
2040 // This is necessary to force |default_request_context_| to be | 2083 // This is necessary to force |default_request_context_| to be |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2115 #if defined(OS_CHROMEOS) | 2158 #if defined(OS_CHROMEOS) |
2116 // To be precise, logout (browser shutdown) is not yet done, but the | 2159 // To be precise, logout (browser shutdown) is not yet done, but the |
2117 // remaining work is negligible, hence we say LogoutDone here. | 2160 // remaining work is negligible, hence we say LogoutDone here. |
2118 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 2161 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
2119 false); | 2162 false); |
2120 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 2163 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
2121 #endif | 2164 #endif |
2122 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); | 2165 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); |
2123 return result_code; | 2166 return result_code; |
2124 } | 2167 } |
OLD | NEW |