Chromium Code Reviews| 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 #include "chrome/browser/browser_main_win.h" | 6 #include "chrome/browser/browser_main_win.h" |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 | 10 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 void RecordBrowserStartupTime() { | 86 void RecordBrowserStartupTime() { |
| 87 // Calculate the time that has elapsed from our own process creation. | 87 // Calculate the time that has elapsed from our own process creation. |
| 88 FILETIME creation_time = {}; | 88 FILETIME creation_time = {}; |
| 89 FILETIME ignore = {}; | 89 FILETIME ignore = {}; |
| 90 ::GetProcessTimes(::GetCurrentProcess(), &creation_time, &ignore, &ignore, | 90 ::GetProcessTimes(::GetCurrentProcess(), &creation_time, &ignore, &ignore, |
| 91 &ignore); | 91 &ignore); |
| 92 | 92 |
| 93 base::TimeDelta elapsed_from_startup = | 93 RecordPreReadExperimentTime( |
| 94 base::Time::Now() - base::Time::FromFileTime(creation_time); | 94 "Startup.BrowserMessageLoopStartTime", |
| 95 | 95 base::Time::Now() - base::Time::FromFileTime(creation_time)); |
| 96 // Record the time to present in a histogram. | |
| 97 UMA_HISTOGRAM_MEDIUM_TIMES("Startup.BrowserMessageLoopStartTime", | |
| 98 elapsed_from_startup); | |
| 99 } | 96 } |
| 100 | 97 |
| 101 int AskForUninstallConfirmation() { | 98 int AskForUninstallConfirmation() { |
| 102 int ret = content::RESULT_CODE_NORMAL_EXIT; | 99 int ret = content::RESULT_CODE_NORMAL_EXIT; |
| 103 views::Widget::CreateWindow(new UninstallView(ret))->Show(); | 100 views::Widget::CreateWindow(new UninstallView(ret))->Show(); |
| 104 views::AcceleratorHandler accelerator_handler; | 101 views::AcceleratorHandler accelerator_handler; |
| 105 MessageLoopForUI::current()->Run(&accelerator_handler); | 102 MessageLoopForUI::current()->Run(&accelerator_handler); |
| 106 return ret; | 103 return ret; |
| 107 } | 104 } |
| 108 | 105 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 uninstall_cmd.AppendSwitch( | 266 uninstall_cmd.AppendSwitch( |
| 270 installer::switches::kDoNotRemoveSharedItems); | 267 installer::switches::kDoNotRemoveSharedItems); |
| 271 base::LaunchProcess(uninstall_cmd, base::LaunchOptions(), NULL); | 268 base::LaunchProcess(uninstall_cmd, base::LaunchOptions(), NULL); |
| 272 } | 269 } |
| 273 return true; | 270 return true; |
| 274 } | 271 } |
| 275 } | 272 } |
| 276 return false; | 273 return false; |
| 277 } | 274 } |
| 278 | 275 |
| 276 // This code is specific to the Windows-only PreReadExperiment field-trial. | |
| 277 static void AddPreReadHistogramTime(const char* name, base::TimeDelta time) { | |
| 278 const base::TimeDelta kMin(base::TimeDelta::FromMilliseconds(1)); | |
| 279 const base::TimeDelta kMax(base::TimeDelta::FromHours(1)); | |
| 280 static const size_t kBuckets(100); | |
| 281 | |
| 282 // FactoryTimeGet will always return a pointer to the same histogram object, | |
| 283 // keyed on its name. There's no need for us to store it explicitly anywhere. | |
| 284 base::Histogram* counter = base::Histogram::FactoryTimeGet( | |
| 285 name, kMin, kMax, kBuckets, base::Histogram::kUmaTargetedHistogramFlag); | |
| 286 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.
| |
| 287 | |
| 288 counter->AddTime(time); | |
| 289 } | |
| 290 | |
| 291 // This code is specific to the Windows-only PreReadExperiment field-trial. | |
| 292 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { | |
| 293 DCHECK(name != NULL); | |
| 294 | |
| 295 static const char kEnvVar[] = "CHROME_PRE_READ_EXPERIMENT"; | |
| 296 | |
| 297 // This gets called with different histogram names, so we don't want to use | |
| 298 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the | |
| 299 // first call wins. | |
| 300 AddPreReadHistogramTime(name, time); | |
| 301 | |
| 302 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
| 303 DCHECK(env.get() != NULL); | |
| 304 | |
| 305 // Only record the sub-histogram result if the experiment is running | |
| 306 // (environment variable is set, and valid). | |
| 307 std::string pre_read; | |
| 308 if (env->GetVar(kEnvVar, &pre_read) && (pre_read == "0" || pre_read == "1")) { | |
| 309 std::string uma_name(name); | |
| 310 uma_name += "_PreRead"; | |
| 311 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | |
| 312 AddPreReadHistogramTime(uma_name.c_str(), time); | |
| 313 } | |
| 314 } | |
| 315 | |
| 279 // BrowserMainPartsWin --------------------------------------------------------- | 316 // BrowserMainPartsWin --------------------------------------------------------- |
| 280 | 317 |
| 281 class BrowserMainPartsWin : public BrowserMainParts { | 318 class BrowserMainPartsWin : public BrowserMainParts { |
| 282 public: | 319 public: |
| 283 explicit BrowserMainPartsWin(const MainFunctionParams& parameters) | 320 explicit BrowserMainPartsWin(const MainFunctionParams& parameters) |
| 284 : BrowserMainParts(parameters) {} | 321 : BrowserMainParts(parameters) {} |
| 285 | 322 |
| 286 protected: | 323 protected: |
| 287 virtual void PreEarlyInitialization() { | 324 virtual void PreEarlyInitialization() { |
| 288 // Initialize Winsock. | 325 // Initialize Winsock. |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 315 crypto::EnsureNSPRInit(); | 352 crypto::EnsureNSPRInit(); |
| 316 } | 353 } |
| 317 } | 354 } |
| 318 }; | 355 }; |
| 319 | 356 |
| 320 // static | 357 // static |
| 321 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( | 358 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( |
| 322 const MainFunctionParams& parameters) { | 359 const MainFunctionParams& parameters) { |
| 323 return new BrowserMainPartsWin(parameters); | 360 return new BrowserMainPartsWin(parameters); |
| 324 } | 361 } |
| OLD | NEW |