| 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 #ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ | 5 #ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ |
| 6 #define CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ | 6 #define CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 14 #include "base/tracked_objects.h" | 14 #include "base/tracked_objects.h" |
| 15 #include "chrome/browser/first_run/first_run.h" | 15 #include "chrome/browser/first_run/first_run.h" |
| 16 #include "chrome/browser/process_singleton.h" | 16 #include "chrome/browser/process_singleton.h" |
| 17 #include "chrome/browser/ui/browser_init.h" | |
| 18 #include "content/public/browser/browser_main_parts.h" | 17 #include "content/public/browser/browser_main_parts.h" |
| 19 #include "content/public/browser/browser_thread.h" | |
| 20 | 18 |
| 21 class BrowserInit; | 19 class BrowserInit; |
| 22 class BrowserProcessImpl; | 20 class BrowserProcessImpl; |
| 23 class ChromeBrowserMainExtraParts; | 21 class ChromeBrowserMainExtraParts; |
| 24 class FieldTrialSynchronizer; | 22 class FieldTrialSynchronizer; |
| 25 class HistogramSynchronizer; | 23 class HistogramSynchronizer; |
| 26 class MetricsService; | 24 class MetricsService; |
| 27 class PrefService; | 25 class PrefService; |
| 28 class Profile; | 26 class Profile; |
| 29 class ShutdownWatcherHelper; | 27 class ShutdownWatcherHelper; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 53 protected: | 51 protected: |
| 54 explicit ChromeBrowserMainParts( | 52 explicit ChromeBrowserMainParts( |
| 55 const content::MainFunctionParams& parameters); | 53 const content::MainFunctionParams& parameters); |
| 56 | 54 |
| 57 // content::BrowserMainParts overrides. | 55 // content::BrowserMainParts overrides. |
| 58 virtual void PreEarlyInitialization() OVERRIDE; | 56 virtual void PreEarlyInitialization() OVERRIDE; |
| 59 virtual void PostEarlyInitialization() OVERRIDE; | 57 virtual void PostEarlyInitialization() OVERRIDE; |
| 60 virtual void ToolkitInitialized() OVERRIDE; | 58 virtual void ToolkitInitialized() OVERRIDE; |
| 61 virtual void PreMainMessageLoopStart() OVERRIDE; | 59 virtual void PreMainMessageLoopStart() OVERRIDE; |
| 62 virtual void PostMainMessageLoopStart() OVERRIDE; | 60 virtual void PostMainMessageLoopStart() OVERRIDE; |
| 63 virtual void PreCreateThreads() OVERRIDE; | |
| 64 virtual void PreStartThread(content::BrowserThread::ID identifier) OVERRIDE; | |
| 65 virtual void PostStartThread(content::BrowserThread::ID identifier) OVERRIDE; | |
| 66 virtual void PreMainMessageLoopRun() OVERRIDE; | 61 virtual void PreMainMessageLoopRun() OVERRIDE; |
| 67 virtual bool MainMessageLoopRun(int* result_code) OVERRIDE; | 62 virtual bool MainMessageLoopRun(int* result_code) OVERRIDE; |
| 68 virtual void PostMainMessageLoopRun() OVERRIDE; | 63 virtual void PostMainMessageLoopRun() OVERRIDE; |
| 69 virtual void PreStopThread(content::BrowserThread::ID identifier) OVERRIDE; | |
| 70 virtual void PostStopThread(content::BrowserThread::ID identifier) OVERRIDE; | |
| 71 virtual void PostDestroyThreads() OVERRIDE; | |
| 72 | 64 |
| 73 // Displays a warning message that we can't find any locale data files. | 65 // Displays a warning message that we can't find any locale data files. |
| 74 virtual void ShowMissingLocaleMessageBox() = 0; | 66 virtual void ShowMissingLocaleMessageBox() = 0; |
| 75 | 67 |
| 76 const content::MainFunctionParams& parameters() const { | 68 const content::MainFunctionParams& parameters() const { |
| 77 return parameters_; | 69 return parameters_; |
| 78 } | 70 } |
| 79 const CommandLine& parsed_command_line() const { | 71 const CommandLine& parsed_command_line() const { |
| 80 return parsed_command_line_; | 72 return parsed_command_line_; |
| 81 } | 73 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 static MetricsService* InitializeMetrics( | 114 static MetricsService* InitializeMetrics( |
| 123 const CommandLine& parsed_command_line, | 115 const CommandLine& parsed_command_line, |
| 124 const PrefService* local_state); | 116 const PrefService* local_state); |
| 125 | 117 |
| 126 // Add an invocation of your field trial init function to this method. | 118 // Add an invocation of your field trial init function to this method. |
| 127 void SetupFieldTrials(bool metrics_recording_enabled, | 119 void SetupFieldTrials(bool metrics_recording_enabled, |
| 128 bool proxy_policy_is_set); | 120 bool proxy_policy_is_set); |
| 129 | 121 |
| 130 // Methods for Main Message Loop ------------------------------------------- | 122 // Methods for Main Message Loop ------------------------------------------- |
| 131 | 123 |
| 132 int PreCreateThreadsImpl(); | |
| 133 int PreMainMessageLoopRunImpl(); | 124 int PreMainMessageLoopRunImpl(); |
| 134 | 125 |
| 135 // Members initialized on construction --------------------------------------- | 126 // Members initialized on construction --------------------------------------- |
| 136 | 127 |
| 137 const content::MainFunctionParams& parameters_; | 128 const content::MainFunctionParams& parameters_; |
| 138 const CommandLine& parsed_command_line_; | 129 const CommandLine& parsed_command_line_; |
| 139 int result_code_; | 130 int result_code_; |
| 140 | 131 |
| 141 // Create ShutdownWatcherHelper object for watching jank during shutdown. | 132 // Create ShutdownWatcherHelper object for watching jank during shutdown. |
| 142 // Please keep |shutdown_watcher| as the first object constructed, and hence | 133 // Please keep |shutdown_watcher| as the first object constructed, and hence |
| (...skipping 24 matching lines...) Expand all Loading... |
| 167 scoped_ptr<FirstRun::MasterPrefs> master_prefs_; | 158 scoped_ptr<FirstRun::MasterPrefs> master_prefs_; |
| 168 bool record_search_engine_; | 159 bool record_search_engine_; |
| 169 TranslateManager* translate_manager_; | 160 TranslateManager* translate_manager_; |
| 170 Profile* profile_; | 161 Profile* profile_; |
| 171 bool run_message_loop_; | 162 bool run_message_loop_; |
| 172 ProcessSingleton::NotifyResult notify_result_; | 163 ProcessSingleton::NotifyResult notify_result_; |
| 173 | 164 |
| 174 // Initialized in SetupMetricsAndFieldTrials. | 165 // Initialized in SetupMetricsAndFieldTrials. |
| 175 scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer_; | 166 scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer_; |
| 176 | 167 |
| 177 // Members initialized in PreMainMessageLoopRun, needed in | |
| 178 // PreMainMessageLoopRunThreadsCreated. | |
| 179 bool is_first_run_; | |
| 180 bool first_run_ui_bypass_; | |
| 181 MetricsService* metrics_; | |
| 182 PrefService* local_state_; | |
| 183 FilePath user_data_dir_; | |
| 184 | |
| 185 // Members needed across shutdown methods. | |
| 186 bool restart_last_session_; | |
| 187 | |
| 188 FRIEND_TEST_ALL_PREFIXES(BrowserMainTest, | 168 FRIEND_TEST_ALL_PREFIXES(BrowserMainTest, |
| 189 WarmConnectionFieldTrial_WarmestSocket); | 169 WarmConnectionFieldTrial_WarmestSocket); |
| 190 FRIEND_TEST_ALL_PREFIXES(BrowserMainTest, WarmConnectionFieldTrial_Random); | 170 FRIEND_TEST_ALL_PREFIXES(BrowserMainTest, WarmConnectionFieldTrial_Random); |
| 191 FRIEND_TEST_ALL_PREFIXES(BrowserMainTest, WarmConnectionFieldTrial_Invalid); | 171 FRIEND_TEST_ALL_PREFIXES(BrowserMainTest, WarmConnectionFieldTrial_Invalid); |
| 192 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts); | 172 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts); |
| 193 }; | 173 }; |
| 194 | 174 |
| 195 // Records the conditions that can prevent Breakpad from generating and | 175 // Records the conditions that can prevent Breakpad from generating and |
| 196 // sending crash reports. The presence of a Breakpad handler (after | 176 // sending crash reports. The presence of a Breakpad handler (after |
| 197 // attempting to initialize crash reporting) and the presence of a debugger | 177 // attempting to initialize crash reporting) and the presence of a debugger |
| 198 // are registered with the UMA metrics service. | 178 // are registered with the UMA metrics service. |
| 199 void RecordBreakpadStatusUMA(MetricsService* metrics); | 179 void RecordBreakpadStatusUMA(MetricsService* metrics); |
| 200 | 180 |
| 201 // Displays a warning message if some minimum level of OS support is not | 181 // Displays a warning message if some minimum level of OS support is not |
| 202 // present on the current platform. | 182 // present on the current platform. |
| 203 void WarnAboutMinimumSystemRequirements(); | 183 void WarnAboutMinimumSystemRequirements(); |
| 204 | 184 |
| 205 // Records the time from our process' startup to the present time in | 185 // Records the time from our process' startup to the present time in |
| 206 // the UMA histogram |metric_name|. | 186 // the UMA histogram |metric_name|. |
| 207 void RecordBrowserStartupTime(); | 187 void RecordBrowserStartupTime(); |
| 208 | 188 |
| 209 // Records a time value to an UMA histogram in the context of the | 189 // Records a time value to an UMA histogram in the context of the |
| 210 // PreReadExperiment field-trial. This also reports to the appropriate | 190 // PreReadExperiment field-trial. This also reports to the appropriate |
| 211 // sub-histogram (_PreRead(Enabled|Disabled)). | 191 // sub-histogram (_PreRead(Enabled|Disabled)). |
| 212 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time); | 192 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time); |
| 213 | 193 |
| 214 #endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ | 194 #endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ |
| OLD | NEW |