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 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { |
| 278 DCHECK(name != NULL); |
| 279 |
| 280 static const char kEnvVar[] = "CHROME_PRE_READ_EXPERIMENT"; |
| 281 static const base::TimeDelta kMin(base::TimeDelta::FromMilliseconds(1)); |
| 282 static const base::TimeDelta kMax(base::TimeDelta::FromHours(1)); |
| 283 static const size_t kBuckets(100); |
| 284 |
| 285 UMA_HISTOGRAM_CUSTOM_TIMES(name, time, kMin, kMax, kBuckets); |
| 286 |
| 287 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 288 DCHECK(env.get() != NULL); |
| 289 |
| 290 // Only record the sub-histogram result if the experiment is running |
| 291 // (environment variable is set, and valid). |
| 292 std::string pre_read; |
| 293 if (env->GetVar(kEnvVar, &pre_read) && (pre_read == "0" || pre_read == "1")) { |
| 294 std::string uma_name(name); |
| 295 uma_name += "_PreRead"; |
| 296 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
| 297 UMA_HISTOGRAM_CUSTOM_TIMES(uma_name.c_str(), time, kMin, kMax, kBuckets); |
| 298 } |
| 299 } |
| 300 |
279 // BrowserMainPartsWin --------------------------------------------------------- | 301 // BrowserMainPartsWin --------------------------------------------------------- |
280 | 302 |
281 class BrowserMainPartsWin : public BrowserMainParts { | 303 class BrowserMainPartsWin : public BrowserMainParts { |
282 public: | 304 public: |
283 explicit BrowserMainPartsWin(const MainFunctionParams& parameters) | 305 explicit BrowserMainPartsWin(const MainFunctionParams& parameters) |
284 : BrowserMainParts(parameters) {} | 306 : BrowserMainParts(parameters) {} |
285 | 307 |
286 protected: | 308 protected: |
287 virtual void PreEarlyInitialization() { | 309 virtual void PreEarlyInitialization() { |
288 // Initialize Winsock. | 310 // Initialize Winsock. |
(...skipping 26 matching lines...) Expand all Loading... |
315 crypto::EnsureNSPRInit(); | 337 crypto::EnsureNSPRInit(); |
316 } | 338 } |
317 } | 339 } |
318 }; | 340 }; |
319 | 341 |
320 // static | 342 // static |
321 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( | 343 BrowserMainParts* BrowserMainParts::CreateBrowserMainParts( |
322 const MainFunctionParams& parameters) { | 344 const MainFunctionParams& parameters) { |
323 return new BrowserMainPartsWin(parameters); | 345 return new BrowserMainPartsWin(parameters); |
324 } | 346 } |
OLD | NEW |