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