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/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
13 #include "base/tracked_objects.h" | 13 #include "base/tracked_objects.h" |
14 #include "chrome/browser/first_run/first_run.h" | 14 #include "chrome/browser/first_run/first_run.h" |
15 #include "chrome/browser/process_singleton.h" | 15 #include "chrome/browser/process_singleton.h" |
| 16 #include "chrome/browser/ui/browser_init.h" |
16 #include "content/public/browser/browser_main_parts.h" | 17 #include "content/public/browser/browser_main_parts.h" |
| 18 #include "content/public/browser/browser_thread.h" |
17 | 19 |
18 class BrowserInit; | 20 class BrowserInit; |
19 class BrowserProcessImpl; | 21 class BrowserProcessImpl; |
20 class FieldTrialSynchronizer; | 22 class FieldTrialSynchronizer; |
21 class HistogramSynchronizer; | 23 class HistogramSynchronizer; |
22 class MetricsService; | 24 class MetricsService; |
23 class PrefService; | 25 class PrefService; |
24 class Profile; | 26 class Profile; |
25 class ShutdownWatcherHelper; | 27 class ShutdownWatcherHelper; |
26 class TranslateManager; | 28 class TranslateManager; |
27 | 29 |
28 namespace chrome_browser { | 30 namespace chrome_browser { |
29 // For use by ShowMissingLocaleMessageBox. | 31 // For use by ShowMissingLocaleMessageBox. |
30 extern const char kMissingLocaleDataTitle[]; | 32 extern const char kMissingLocaleDataTitle[]; |
31 extern const char kMissingLocaleDataMessage[]; | 33 extern const char kMissingLocaleDataMessage[]; |
32 } | 34 } |
33 | 35 |
34 namespace chrome_browser_metrics { | 36 namespace chrome_browser_metrics { |
35 class TrackingSynchronizer; | 37 class TrackingSynchronizer; |
36 } | 38 } |
37 | 39 |
38 namespace content { | 40 namespace content { |
| 41 class IOThreadDelegate; |
39 struct MainFunctionParams; | 42 struct MainFunctionParams; |
40 } | 43 } |
41 | 44 |
42 class ChromeBrowserMainParts : public content::BrowserMainParts { | 45 class ChromeBrowserMainParts : public content::BrowserMainParts { |
43 public: | 46 public: |
44 virtual ~ChromeBrowserMainParts(); | 47 virtual ~ChromeBrowserMainParts(); |
45 | 48 |
46 // Constructs metrics service and does related initialization, including | 49 // Constructs metrics service and does related initialization, including |
47 // creation of field trials. Call only after labs have been converted to | 50 // creation of field trials. Call only after labs have been converted to |
48 // switches. | 51 // switches. |
49 MetricsService* SetupMetricsAndFieldTrials(PrefService* local_state); | 52 MetricsService* SetupMetricsAndFieldTrials(PrefService* local_state); |
50 | 53 |
51 const content::MainFunctionParams& parameters() const { | 54 const content::MainFunctionParams& parameters() const { |
52 return parameters_; | 55 return parameters_; |
53 } | 56 } |
54 const CommandLine& parsed_command_line() const { | 57 const CommandLine& parsed_command_line() const { |
55 return parsed_command_line_; | 58 return parsed_command_line_; |
56 } | 59 } |
57 | 60 |
58 protected: | 61 protected: |
59 explicit ChromeBrowserMainParts( | 62 explicit ChromeBrowserMainParts( |
60 const content::MainFunctionParams& parameters); | 63 const content::MainFunctionParams& parameters); |
61 | 64 |
62 // content::BrowserParts overrides | 65 // content::BrowserParts overrides |
63 virtual void PreEarlyInitialization() OVERRIDE; | 66 virtual void PreEarlyInitialization() OVERRIDE; |
64 virtual void PostEarlyInitialization() OVERRIDE; | 67 virtual void PostEarlyInitialization() OVERRIDE; |
65 virtual void ToolkitInitialized() OVERRIDE; | 68 virtual void ToolkitInitialized() OVERRIDE; |
66 virtual void PreMainMessageLoopStart() OVERRIDE; | 69 virtual void PreMainMessageLoopStart() OVERRIDE; |
67 virtual void PostMainMessageLoopStart() OVERRIDE; | 70 virtual void PostMainMessageLoopStart() OVERRIDE; |
68 virtual void PreMainMessageLoopRun() OVERRIDE; | 71 virtual content::IOThreadDelegate* PreMainMessageLoopRun() OVERRIDE; |
| 72 virtual void PreMainMessageLoopRunThreadsCreated() OVERRIDE; |
69 virtual bool MainMessageLoopRun(int* result_code) OVERRIDE; | 73 virtual bool MainMessageLoopRun(int* result_code) OVERRIDE; |
70 virtual void PostMainMessageLoopRun() OVERRIDE; | 74 virtual void PostMainMessageLoopRun() OVERRIDE; |
| 75 virtual void PreStopThread(content::BrowserThread::ID identifier) OVERRIDE; |
| 76 virtual void PostStopThread(content::BrowserThread::ID identifier) OVERRIDE; |
| 77 virtual void FinalCleanup() OVERRIDE; |
71 | 78 |
72 // Displays a warning message that we can't find any locale data files. | 79 // Displays a warning message that we can't find any locale data files. |
73 virtual void ShowMissingLocaleMessageBox() = 0; | 80 virtual void ShowMissingLocaleMessageBox() = 0; |
74 | 81 |
75 private: | 82 private: |
76 // Methods for |EarlyInitialization()| --------------------------------------- | 83 // Methods for |EarlyInitialization()| --------------------------------------- |
77 | 84 |
78 // A/B test for the maximum number of persistent connections per host. | 85 // A/B test for the maximum number of persistent connections per host. |
79 void ConnectionFieldTrial(); | 86 void ConnectionFieldTrial(); |
80 | 87 |
(...skipping 27 matching lines...) Expand all Loading... |
108 const CommandLine& parsed_command_line, | 115 const CommandLine& parsed_command_line, |
109 const PrefService* local_state); | 116 const PrefService* local_state); |
110 | 117 |
111 // 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. |
112 void SetupFieldTrials(bool metrics_recording_enabled, | 119 void SetupFieldTrials(bool metrics_recording_enabled, |
113 bool proxy_policy_is_set); | 120 bool proxy_policy_is_set); |
114 | 121 |
115 // Methods for Main Message Loop ------------------------------------------- | 122 // Methods for Main Message Loop ------------------------------------------- |
116 | 123 |
117 int PreMainMessageLoopRunImpl(); | 124 int PreMainMessageLoopRunImpl(); |
| 125 int PreMainMessageLoopRunThreadsCreatedImpl(); |
118 void StartBrowserOrUITask(); | 126 void StartBrowserOrUITask(); |
119 | 127 |
120 // Members initialized on construction --------------------------------------- | 128 // Members initialized on construction --------------------------------------- |
121 | 129 |
122 const content::MainFunctionParams& parameters_; | 130 const content::MainFunctionParams& parameters_; |
123 const CommandLine& parsed_command_line_; | 131 const CommandLine& parsed_command_line_; |
124 int result_code_; | 132 int result_code_; |
125 | 133 |
126 // Create ShutdownWatcherHelper object for watching jank during shutdown. | 134 // Create ShutdownWatcherHelper object for watching jank during shutdown. |
127 // Please keep |shutdown_watcher| as the first object constructed, and hence | 135 // Please keep |shutdown_watcher| as the first object constructed, and hence |
(...skipping 20 matching lines...) Expand all Loading... |
148 scoped_ptr<FirstRun::MasterPrefs> master_prefs_; | 156 scoped_ptr<FirstRun::MasterPrefs> master_prefs_; |
149 bool record_search_engine_; | 157 bool record_search_engine_; |
150 TranslateManager* translate_manager_; | 158 TranslateManager* translate_manager_; |
151 Profile* profile_; | 159 Profile* profile_; |
152 bool run_message_loop_; | 160 bool run_message_loop_; |
153 ProcessSingleton::NotifyResult notify_result_; | 161 ProcessSingleton::NotifyResult notify_result_; |
154 | 162 |
155 // Initialized in SetupMetricsAndFieldTrials. | 163 // Initialized in SetupMetricsAndFieldTrials. |
156 scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer_; | 164 scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer_; |
157 | 165 |
| 166 // Members initialized in PreMainMessageLoopRun, needed in |
| 167 // PreMainMessageLoopRunThreadsCreated. |
| 168 bool is_first_run_; |
| 169 bool first_run_ui_bypass_; |
| 170 MetricsService* metrics_; |
| 171 PrefService* local_state_; |
| 172 FilePath user_data_dir_; |
| 173 |
| 174 // Members needed across shutdown methods. |
| 175 bool restart_last_session_; |
| 176 |
158 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket); | 177 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket); |
159 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Random); | 178 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Random); |
160 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Invalid); | 179 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Invalid); |
161 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts); | 180 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts); |
162 }; | 181 }; |
163 | 182 |
164 // Records the conditions that can prevent Breakpad from generating and | 183 // Records the conditions that can prevent Breakpad from generating and |
165 // sending crash reports. The presence of a Breakpad handler (after | 184 // sending crash reports. The presence of a Breakpad handler (after |
166 // attempting to initialize crash reporting) and the presence of a debugger | 185 // attempting to initialize crash reporting) and the presence of a debugger |
167 // are registered with the UMA metrics service. | 186 // are registered with the UMA metrics service. |
168 void RecordBreakpadStatusUMA(MetricsService* metrics); | 187 void RecordBreakpadStatusUMA(MetricsService* metrics); |
169 | 188 |
170 // Displays a warning message if some minimum level of OS support is not | 189 // Displays a warning message if some minimum level of OS support is not |
171 // present on the current platform. | 190 // present on the current platform. |
172 void WarnAboutMinimumSystemRequirements(); | 191 void WarnAboutMinimumSystemRequirements(); |
173 | 192 |
174 // Records the time from our process' startup to the present time in | 193 // Records the time from our process' startup to the present time in |
175 // the UMA histogram |metric_name|. | 194 // the UMA histogram |metric_name|. |
176 void RecordBrowserStartupTime(); | 195 void RecordBrowserStartupTime(); |
177 | 196 |
178 // Records a time value to an UMA histogram in the context of the | 197 // Records a time value to an UMA histogram in the context of the |
179 // PreReadExperiment field-trial. This also reports to the appropriate | 198 // PreReadExperiment field-trial. This also reports to the appropriate |
180 // sub-histogram (_PreRead(Enabled|Disabled)). | 199 // sub-histogram (_PreRead(Enabled|Disabled)). |
181 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time); | 200 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time); |
182 | 201 |
183 #endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ | 202 #endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ |
OLD | NEW |