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 | 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. | |
| 169 #include "base/win/registry.h" // For PreRead experiment. | |
|
Sigurður Ásgeirsson
2011/08/25 17:44:14
I don't think you need this include?
chrisha
2011/08/25 19:39:17
Leftover from before refactor.
Done.
| |
| 168 #include "base/win/scoped_com_initializer.h" | 170 #include "base/win/scoped_com_initializer.h" |
| 169 #include "base/win/windows_version.h" | 171 #include "base/win/windows_version.h" |
| 170 #include "chrome/browser/browser_trial.h" | 172 #include "chrome/browser/browser_trial.h" |
| 171 #include "chrome/browser/browser_util_win.h" | 173 #include "chrome/browser/browser_util_win.h" |
| 172 #include "chrome/browser/first_run/try_chrome_dialog_view.h" | 174 #include "chrome/browser/first_run/try_chrome_dialog_view.h" |
| 173 #include "chrome/browser/first_run/upgrade_util_win.h" | 175 #include "chrome/browser/first_run/upgrade_util_win.h" |
| 174 #include "chrome/browser/net/url_fixer_upper.h" | 176 #include "chrome/browser/net/url_fixer_upper.h" |
| 175 #include "chrome/browser/rlz/rlz.h" | 177 #include "chrome/browser/rlz/rlz.h" |
| 176 #include "chrome/browser/ui/views/user_data_dir_dialog.h" | 178 #include "chrome/browser/ui/views/user_data_dir_dialog.h" |
| 177 #include "chrome/installer/util/helper.h" | 179 #include "chrome/installer/util/helper.h" |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 807 CHECK(metrics_reporting_enabled); | 809 CHECK(metrics_reporting_enabled); |
| 808 bool breakpad_enabled = | 810 bool breakpad_enabled = |
| 809 local_state->GetBoolean(prefs::kMetricsReportingEnabled); | 811 local_state->GetBoolean(prefs::kMetricsReportingEnabled); |
| 810 if (!breakpad_enabled && metrics_reporting_enabled->IsUserModifiable()) | 812 if (!breakpad_enabled && metrics_reporting_enabled->IsUserModifiable()) |
| 811 breakpad_enabled = getenv(env_vars::kHeadless) != NULL; | 813 breakpad_enabled = getenv(env_vars::kHeadless) != NULL; |
| 812 #endif // #if defined(OS_CHROMEOS) | 814 #endif // #if defined(OS_CHROMEOS) |
| 813 return breakpad_enabled; | 815 return breakpad_enabled; |
| 814 } | 816 } |
| 815 #endif // #if defined(USE_LINUX_BREAKPAD) | 817 #endif // #if defined(USE_LINUX_BREAKPAD) |
| 816 | 818 |
| 819 // This code is specific to the Windows-only PreReadExperiment field-trial. | |
| 820 void AddPreReadHistogramTime(const char* name, base::TimeDelta time) { | |
| 821 const base::TimeDelta kMin(base::TimeDelta::FromMilliseconds(1)); | |
| 822 const base::TimeDelta kMax(base::TimeDelta::FromHours(1)); | |
| 823 static const size_t kBuckets(100); | |
| 824 | |
| 825 // FactoryTimeGet will always return a pointer to the same histogram object, | |
| 826 // keyed on its name. There's no need for us to store it explicitly anywhere. | |
| 827 base::Histogram* counter = base::Histogram::FactoryTimeGet( | |
| 828 name, kMin, kMax, kBuckets, base::Histogram::kUmaTargetedHistogramFlag); | |
| 829 | |
| 830 counter->AddTime(time); | |
| 831 } | |
| 832 | |
| 817 } // namespace | 833 } // namespace |
| 818 | 834 |
| 819 namespace chrome_browser { | 835 namespace chrome_browser { |
| 820 // This error message is not localized because we failed to load the | 836 // This error message is not localized because we failed to load the |
| 821 // localization data files. | 837 // localization data files. |
| 822 const char kMissingLocaleDataTitle[] = "Missing File Error"; | 838 const char kMissingLocaleDataTitle[] = "Missing File Error"; |
| 823 const char kMissingLocaleDataMessage[] = | 839 const char kMissingLocaleDataMessage[] = |
| 824 "Unable to find locale data files. Please reinstall."; | 840 "Unable to find locale data files. Please reinstall."; |
| 825 } // namespace chrome_browser | 841 } // namespace chrome_browser |
| 826 | 842 |
| (...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2039 upgrade_util::SaveLastModifiedTimeOfExe(); | 2055 upgrade_util::SaveLastModifiedTimeOfExe(); |
| 2040 #endif | 2056 #endif |
| 2041 | 2057 |
| 2042 // Record now as the last successful chrome start. | 2058 // Record now as the last successful chrome start. |
| 2043 GoogleUpdateSettings::SetLastRunTime(); | 2059 GoogleUpdateSettings::SetLastRunTime(); |
| 2044 // Call Recycle() here as late as possible, before going into the loop | 2060 // 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. | 2061 // because Start() will add things to it while creating the main window. |
| 2046 if (pool) | 2062 if (pool) |
| 2047 pool->Recycle(); | 2063 pool->Recycle(); |
| 2048 | 2064 |
| 2049 UMA_HISTOGRAM_CUSTOM_TIMES( | 2065 RecordPreReadExperimentTime("Startup.BrowserOpenTabs", |
| 2050 "Startup.BrowserOpenTabs", | 2066 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 | 2067 |
| 2056 // TODO(mad): Move this call in a proper place on CrOS. | 2068 // TODO(mad): Move this call in a proper place on CrOS. |
| 2057 // http://crosbug.com/17687 | 2069 // http://crosbug.com/17687 |
| 2058 #if !defined(OS_CHROMEOS) | 2070 #if !defined(OS_CHROMEOS) |
| 2059 // If we're running tests (ui_task is non-null), then we don't want to | 2071 // If we're running tests (ui_task is non-null), then we don't want to |
| 2060 // call FetchLanguageListFromTranslateServer | 2072 // call FetchLanguageListFromTranslateServer |
| 2061 if (parameters.ui_task == NULL && translate_manager != NULL) { | 2073 if (parameters.ui_task == NULL && translate_manager != NULL) { |
| 2062 // TODO(willchan): Get rid of this after TranslateManager doesn't use | 2074 // TODO(willchan): Get rid of this after TranslateManager doesn't use |
| 2063 // the default request context. http://crbug.com/89396. | 2075 // the default request context. http://crbug.com/89396. |
| 2064 // This is necessary to force |default_request_context_| to be | 2076 // This is necessary to force |default_request_context_| to be |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2139 #if defined(OS_CHROMEOS) | 2151 #if defined(OS_CHROMEOS) |
| 2140 // To be precise, logout (browser shutdown) is not yet done, but the | 2152 // To be precise, logout (browser shutdown) is not yet done, but the |
| 2141 // remaining work is negligible, hence we say LogoutDone here. | 2153 // remaining work is negligible, hence we say LogoutDone here. |
| 2142 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 2154 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
| 2143 false); | 2155 false); |
| 2144 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 2156 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
| 2145 #endif | 2157 #endif |
| 2146 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); | 2158 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); |
| 2147 return result_code; | 2159 return result_code; |
| 2148 } | 2160 } |
| 2161 | |
| 2162 // This code is specific to the Windows-only PreReadExperiment field-trial. | |
| 2163 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { | |
| 2164 DCHECK(name != NULL); | |
| 2165 | |
| 2166 // This gets called with different histogram names, so we don't want to use | |
| 2167 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the | |
| 2168 // first call wins. | |
| 2169 AddPreReadHistogramTime(name, time); | |
| 2170 | |
| 2171 #if defined(OS_WIN) | |
| 2172 // The pre-read experiment is Windows specific. | |
| 2173 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
| 2174 | |
| 2175 // Only record the sub-histogram result if the experiment is running | |
| 2176 // (environment variable is set, and valid). | |
| 2177 std::string pre_read; | |
| 2178 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && | |
| 2179 (pre_read == "0" || pre_read == "1")) { | |
| 2180 std::string uma_name(name); | |
| 2181 uma_name += "_PreRead"; | |
| 2182 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | |
| 2183 AddPreReadHistogramTime(uma_name.c_str(), time); | |
| 2184 } | |
| 2185 #endif | |
| 2186 } | |
| 2187 | |
| OLD | NEW |