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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2046 upgrade_util::SaveLastModifiedTimeOfExe(); | 2061 upgrade_util::SaveLastModifiedTimeOfExe(); |
2047 #endif | 2062 #endif |
2048 | 2063 |
2049 // Record now as the last successful chrome start. | 2064 // Record now as the last successful chrome start. |
2050 GoogleUpdateSettings::SetLastRunTime(); | 2065 GoogleUpdateSettings::SetLastRunTime(); |
2051 // Call Recycle() here as late as possible, before going into the loop | 2066 // Call Recycle() here as late as possible, before going into the loop |
2052 // because Start() will add things to it while creating the main window. | 2067 // because Start() will add things to it while creating the main window. |
2053 if (pool) | 2068 if (pool) |
2054 pool->Recycle(); | 2069 pool->Recycle(); |
2055 | 2070 |
2056 UMA_HISTOGRAM_CUSTOM_TIMES( | 2071 RecordPreReadExperimentTime("Startup.BrowserOpenTabs", |
2057 "Startup.BrowserOpenTabs", | 2072 base::TimeTicks::Now() - browser_open_start); |
2058 base::TimeTicks::Now() - browser_open_start, | |
2059 base::TimeDelta::FromMilliseconds(1), | |
2060 base::TimeDelta::FromHours(1), | |
2061 100); | |
2062 | 2073 |
2063 // TODO(mad): Move this call in a proper place on CrOS. | 2074 // TODO(mad): Move this call in a proper place on CrOS. |
2064 // http://crosbug.com/17687 | 2075 // http://crosbug.com/17687 |
2065 #if !defined(OS_CHROMEOS) | 2076 #if !defined(OS_CHROMEOS) |
2066 // If we're running tests (ui_task is non-null), then we don't want to | 2077 // If we're running tests (ui_task is non-null), then we don't want to |
2067 // call FetchLanguageListFromTranslateServer | 2078 // call FetchLanguageListFromTranslateServer |
2068 if (parameters.ui_task == NULL && translate_manager != NULL) { | 2079 if (parameters.ui_task == NULL && translate_manager != NULL) { |
2069 // TODO(willchan): Get rid of this after TranslateManager doesn't use | 2080 // TODO(willchan): Get rid of this after TranslateManager doesn't use |
2070 // the default request context. http://crbug.com/89396. | 2081 // the default request context. http://crbug.com/89396. |
2071 // This is necessary to force |default_request_context_| to be | 2082 // This is necessary to force |default_request_context_| to be |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2146 #if defined(OS_CHROMEOS) | 2157 #if defined(OS_CHROMEOS) |
2147 // To be precise, logout (browser shutdown) is not yet done, but the | 2158 // To be precise, logout (browser shutdown) is not yet done, but the |
2148 // remaining work is negligible, hence we say LogoutDone here. | 2159 // remaining work is negligible, hence we say LogoutDone here. |
2149 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 2160 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
2150 false); | 2161 false); |
2151 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 2162 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
2152 #endif | 2163 #endif |
2153 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); | 2164 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); |
2154 return result_code; | 2165 return result_code; |
2155 } | 2166 } |
| 2167 |
| 2168 // This code is specific to the Windows-only PreReadExperiment field-trial. |
| 2169 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { |
| 2170 DCHECK(name != NULL); |
| 2171 |
| 2172 // This gets called with different histogram names, so we don't want to use |
| 2173 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the |
| 2174 // first call wins. |
| 2175 AddPreReadHistogramTime(name, time); |
| 2176 |
| 2177 #if defined(OS_WIN) |
| 2178 // The pre-read experiment is Windows specific. |
| 2179 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 2180 |
| 2181 // Only record the sub-histogram result if the experiment is running |
| 2182 // (environment variable is set, and valid). |
| 2183 std::string pre_read; |
| 2184 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && |
| 2185 (pre_read == "0" || pre_read == "1")) { |
| 2186 std::string uma_name(name); |
| 2187 uma_name += "_PreRead"; |
| 2188 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
| 2189 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 2190 } |
| 2191 #endif |
| 2192 } |
| 2193 |
OLD | NEW |