| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "base/feature_list.h" | 23 #include "base/feature_list.h" |
| 24 #include "base/files/file_path.h" | 24 #include "base/files/file_path.h" |
| 25 #include "base/files/file_util.h" | 25 #include "base/files/file_util.h" |
| 26 #include "base/logging.h" | 26 #include "base/logging.h" |
| 27 #include "base/memory/ptr_util.h" | 27 #include "base/memory/ptr_util.h" |
| 28 #include "base/metrics/field_trial.h" | 28 #include "base/metrics/field_trial.h" |
| 29 #include "base/metrics/histogram_macros.h" | 29 #include "base/metrics/histogram_macros.h" |
| 30 #include "base/path_service.h" | 30 #include "base/path_service.h" |
| 31 #include "base/profiler/scoped_tracker.h" | 31 #include "base/profiler/scoped_tracker.h" |
| 32 #include "base/run_loop.h" | 32 #include "base/run_loop.h" |
| 33 #include "base/strings/string16.h" |
| 33 #include "base/strings/string_number_conversions.h" | 34 #include "base/strings/string_number_conversions.h" |
| 34 #include "base/strings/string_piece.h" | 35 #include "base/strings/string_piece.h" |
| 35 #include "base/strings/string_split.h" | 36 #include "base/strings/string_split.h" |
| 36 #include "base/strings/sys_string_conversions.h" | 37 #include "base/strings/sys_string_conversions.h" |
| 37 #include "base/strings/utf_string_conversions.h" | 38 #include "base/strings/utf_string_conversions.h" |
| 38 #include "base/sys_info.h" | 39 #include "base/sys_info.h" |
| 39 #include "base/task_scheduler/scheduler_worker_pool_params.h" | 40 #include "base/task_scheduler/scheduler_worker_pool_params.h" |
| 40 #include "base/task_scheduler/switches.h" | 41 #include "base/task_scheduler/switches.h" |
| 41 #include "base/task_scheduler/task_scheduler.h" | 42 #include "base/task_scheduler/task_scheduler.h" |
| 42 #include "base/task_scheduler/task_traits.h" | 43 #include "base/task_scheduler/task_traits.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 #include "chromeos/settings/cros_settings_names.h" | 192 #include "chromeos/settings/cros_settings_names.h" |
| 192 #endif // defined(OS_CHROMEOS) | 193 #endif // defined(OS_CHROMEOS) |
| 193 | 194 |
| 194 // TODO(port): several win-only methods have been pulled out of this, but | 195 // TODO(port): several win-only methods have been pulled out of this, but |
| 195 // BrowserMain() as a whole needs to be broken apart so that it's usable by | 196 // BrowserMain() as a whole needs to be broken apart so that it's usable by |
| 196 // other platforms. For now, it's just a stub. This is a serious work in | 197 // other platforms. For now, it's just a stub. This is a serious work in |
| 197 // progress and should not be taken as an indication of a real refactoring. | 198 // progress and should not be taken as an indication of a real refactoring. |
| 198 | 199 |
| 199 #if defined(OS_WIN) | 200 #if defined(OS_WIN) |
| 200 #include "base/trace_event/trace_event_etw_export_win.h" | 201 #include "base/trace_event/trace_event_etw_export_win.h" |
| 202 #include "base/win/registry.h" |
| 201 #include "base/win/win_util.h" | 203 #include "base/win/win_util.h" |
| 202 #include "base/win/windows_version.h" | 204 #include "base/win/windows_version.h" |
| 203 #include "chrome/browser/chrome_browser_main_win.h" | 205 #include "chrome/browser/chrome_browser_main_win.h" |
| 204 #include "chrome/browser/component_updater/sw_reporter_installer_win.h" | 206 #include "chrome/browser/component_updater/sw_reporter_installer_win.h" |
| 205 #include "chrome/browser/downgrade/user_data_downgrade.h" | 207 #include "chrome/browser/downgrade/user_data_downgrade.h" |
| 206 #include "chrome/browser/first_run/try_chrome_dialog_view.h" | 208 #include "chrome/browser/first_run/try_chrome_dialog_view.h" |
| 207 #include "chrome/browser/first_run/upgrade_util_win.h" | 209 #include "chrome/browser/first_run/upgrade_util_win.h" |
| 208 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | |
| 209 #include "chrome/browser/ui/network_profile_bubble.h" | 210 #include "chrome/browser/ui/network_profile_bubble.h" |
| 210 #include "chrome/browser/win/browser_util.h" | 211 #include "chrome/browser/win/browser_util.h" |
| 211 #include "chrome/browser/win/chrome_select_file_dialog_factory.h" | 212 #include "chrome/browser/win/chrome_select_file_dialog_factory.h" |
| 212 #include "chrome/installer/util/browser_distribution.h" | 213 #include "chrome/installer/util/browser_distribution.h" |
| 213 #include "chrome/installer/util/helper.h" | 214 #include "chrome/installer/util/helper.h" |
| 214 #include "chrome/installer/util/install_util.h" | 215 #include "chrome/installer/util/install_util.h" |
| 215 #include "chrome/installer/util/shell_util.h" | 216 #include "chrome/installer/util/shell_util.h" |
| 216 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win.
h" | |
| 217 #include "ui/base/l10n/l10n_util_win.h" | 217 #include "ui/base/l10n/l10n_util_win.h" |
| 218 #include "ui/shell_dialogs/select_file_dialog.h" | 218 #include "ui/shell_dialogs/select_file_dialog.h" |
| 219 #endif // defined(OS_WIN) | 219 #endif // defined(OS_WIN) |
| 220 | 220 |
| 221 #if defined(OS_MACOSX) | 221 #if defined(OS_MACOSX) |
| 222 #include <Security/Security.h> | 222 #include <Security/Security.h> |
| 223 | 223 |
| 224 #include "base/mac/scoped_nsautorelease_pool.h" | 224 #include "base/mac/scoped_nsautorelease_pool.h" |
| 225 #include "chrome/browser/mac/keystone_glue.h" | 225 #include "chrome/browser/mac/keystone_glue.h" |
| 226 #endif // defined(OS_MACOSX) | 226 #endif // defined(OS_MACOSX) |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 ~ScopedMainMessageLoopRunEvent() { | 730 ~ScopedMainMessageLoopRunEvent() { |
| 731 TRACE_EVENT_ASYNC_END0("toplevel", | 731 TRACE_EVENT_ASYNC_END0("toplevel", |
| 732 "ChromeBrowserMainParts::MainMessageLoopRun", this); | 732 "ChromeBrowserMainParts::MainMessageLoopRun", this); |
| 733 } | 733 } |
| 734 }; | 734 }; |
| 735 | 735 |
| 736 } // namespace | 736 } // namespace |
| 737 | 737 |
| 738 namespace chrome_browser { | 738 namespace chrome_browser { |
| 739 | 739 |
| 740 #if defined(OS_WIN) | |
| 741 // Helper function to setup the pre-read field trial. This function is defined | |
| 742 // outside of the anonymous namespace to allow it to be friend with | |
| 743 // ChromeMetricsServiceAccessor. | |
| 744 void SetupPreReadFieldTrial() { | |
| 745 const base::string16 registry_path = | |
| 746 BrowserDistribution::GetDistribution()->GetRegistryPath(); | |
| 747 | |
| 748 // Register a synthetic field trial with the PreRead group used during the | |
| 749 // current startup. This must be done before the first metric log | |
| 750 // (metrics::MetricLog) is created. Otherwise, UMA metrics generated during | |
| 751 // startup won't be correctly annotated. The current function is always called | |
| 752 // before the first metric log is created, as part of | |
| 753 // ChromeBrowserMainParts::PreMainMessageLoopRun(). | |
| 754 startup_metric_utils::RegisterPreReadSyntheticFieldTrial( | |
| 755 registry_path, | |
| 756 base::Bind(&ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial)); | |
| 757 | |
| 758 // Initialize the PreRead options for the current process. | |
| 759 startup_metric_utils::InitializePreReadOptions(registry_path); | |
| 760 | |
| 761 // After startup is complete, update the PreRead group in the registry. The | |
| 762 // group written in the registry will be used for the next startup. | |
| 763 BrowserThread::PostAfterStartupTask( | |
| 764 FROM_HERE, content::BrowserThread::GetBlockingPool(), | |
| 765 base::Bind(&startup_metric_utils::UpdatePreReadOptions, registry_path)); | |
| 766 } | |
| 767 #endif // defined(OS_WIN) | |
| 768 | |
| 769 // This error message is not localized because we failed to load the | 740 // This error message is not localized because we failed to load the |
| 770 // localization data files. | 741 // localization data files. |
| 771 #if defined(OS_WIN) | 742 #if defined(OS_WIN) |
| 772 const char kMissingLocaleDataTitle[] = "Missing File Error"; | 743 const char kMissingLocaleDataTitle[] = "Missing File Error"; |
| 773 #endif // defined(OS_WIN) | 744 #endif // defined(OS_WIN) |
| 774 | 745 |
| 775 #if defined(OS_WIN) | 746 #if defined(OS_WIN) |
| 776 // TODO(port) This should be used on Linux Aura as well. http://crbug.com/338969 | 747 // TODO(port) This should be used on Linux Aura as well. http://crbug.com/338969 |
| 777 const char kMissingLocaleDataMessage[] = | 748 const char kMissingLocaleDataMessage[] = |
| 778 "Unable to find locale data files. Please reinstall."; | 749 "Unable to find locale data files. Please reinstall."; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 // Register a synthetic field trial for the sampling profiler configuration | 915 // Register a synthetic field trial for the sampling profiler configuration |
| 945 // that was already chosen. | 916 // that was already chosen. |
| 946 sampling_profiler_config_.RegisterSyntheticFieldTrial(); | 917 sampling_profiler_config_.RegisterSyntheticFieldTrial(); |
| 947 | 918 |
| 948 #if defined(OS_WIN) || defined(OS_MACOSX) || \ | 919 #if defined(OS_WIN) || defined(OS_MACOSX) || \ |
| 949 (defined(OS_LINUX) && !defined(OS_CHROMEOS)) | 920 (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
| 950 metrics::DesktopEngagementService::Initialize(); | 921 metrics::DesktopEngagementService::Initialize(); |
| 951 #endif | 922 #endif |
| 952 | 923 |
| 953 #if defined(OS_WIN) | 924 #if defined(OS_WIN) |
| 954 chrome_browser::SetupPreReadFieldTrial(); | 925 // Cleanup the PreRead field trial registry key. |
| 926 // TODO(fdoray): Remove this when M56 hits stable. |
| 927 const base::string16 pre_read_field_trial_registry_path = |
| 928 BrowserDistribution::GetDistribution()->GetRegistryPath() + |
| 929 L"\\PreReadFieldTrial"; |
| 930 base::win::RegKey(HKEY_CURRENT_USER, |
| 931 pre_read_field_trial_registry_path.c_str(), KEY_SET_VALUE) |
| 932 .DeleteKey(L""); |
| 955 #endif // defined(OS_WIN) | 933 #endif // defined(OS_WIN) |
| 956 } | 934 } |
| 957 | 935 |
| 958 // ChromeBrowserMainParts: |SetupMetricsAndFieldTrials()| related -------------- | 936 // ChromeBrowserMainParts: |SetupMetricsAndFieldTrials()| related -------------- |
| 959 | 937 |
| 960 void ChromeBrowserMainParts::StartMetricsRecording() { | 938 void ChromeBrowserMainParts::StartMetricsRecording() { |
| 961 TRACE_EVENT0("startup", "ChromeBrowserMainParts::StartMetricsRecording"); | 939 TRACE_EVENT0("startup", "ChromeBrowserMainParts::StartMetricsRecording"); |
| 962 | 940 |
| 963 g_browser_process->metrics_service()->CheckForClonedInstall( | 941 g_browser_process->metrics_service()->CheckForClonedInstall( |
| 964 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); | 942 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); |
| (...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2214 chromeos::CrosSettings::Shutdown(); | 2192 chromeos::CrosSettings::Shutdown(); |
| 2215 #endif // defined(OS_CHROMEOS) | 2193 #endif // defined(OS_CHROMEOS) |
| 2216 #endif // defined(OS_ANDROID) | 2194 #endif // defined(OS_ANDROID) |
| 2217 } | 2195 } |
| 2218 | 2196 |
| 2219 // Public members: | 2197 // Public members: |
| 2220 | 2198 |
| 2221 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 2199 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 2222 chrome_extra_parts_.push_back(parts); | 2200 chrome_extra_parts_.push_back(parts); |
| 2223 } | 2201 } |
| OLD | NEW |