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_BROWSER_MAIN_H_ | 5 #ifndef CHROME_BROWSER_BROWSER_MAIN_H_ |
6 #define CHROME_BROWSER_BROWSER_MAIN_H_ | 6 #define CHROME_BROWSER_BROWSER_MAIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/tracked_objects.h" | 12 #include "base/tracked_objects.h" |
13 | 13 |
14 class BrowserThread; | 14 class BrowserThread; |
15 class CommandLine; | 15 class CommandLine; |
| 16 class FieldTrialSynchronizer; |
16 class HighResolutionTimerManager; | 17 class HighResolutionTimerManager; |
17 struct MainFunctionParams; | 18 struct MainFunctionParams; |
18 class MessageLoop; | 19 class MessageLoop; |
19 class MetricsService; | 20 class MetricsService; |
| 21 class PrefService; |
20 | 22 |
21 namespace net { | 23 namespace net { |
22 class NetworkChangeNotifier; | 24 class NetworkChangeNotifier; |
23 } | 25 } |
24 | 26 |
25 namespace ui { | 27 namespace ui { |
26 class SystemMonitor; | 28 class SystemMonitor; |
27 } | 29 } |
28 | 30 |
29 // BrowserMainParts: | 31 // BrowserMainParts: |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // instantiate the appropriate subclass. | 75 // instantiate the appropriate subclass. |
74 static BrowserMainParts* CreateBrowserMainParts( | 76 static BrowserMainParts* CreateBrowserMainParts( |
75 const MainFunctionParams& parameters); | 77 const MainFunctionParams& parameters); |
76 | 78 |
77 virtual ~BrowserMainParts(); | 79 virtual ~BrowserMainParts(); |
78 | 80 |
79 // Parts to be called by |BrowserMain()|. | 81 // Parts to be called by |BrowserMain()|. |
80 void EarlyInitialization(); | 82 void EarlyInitialization(); |
81 void MainMessageLoopStart(); | 83 void MainMessageLoopStart(); |
82 | 84 |
83 void SetupFieldTrials(); | 85 // Constructs metrics service and does related initialization, including |
| 86 // creation of field trials. Call only after labs have been converted to |
| 87 // switches. |
| 88 MetricsService* SetupMetricsAndFieldTrials( |
| 89 const CommandLine& parsed_command_line, |
| 90 PrefService* local_state); |
84 | 91 |
85 protected: | 92 protected: |
86 explicit BrowserMainParts(const MainFunctionParams& parameters); | 93 explicit BrowserMainParts(const MainFunctionParams& parameters); |
87 | 94 |
88 // Accessors for data members (below) ---------------------------------------- | 95 // Accessors for data members (below) ---------------------------------------- |
89 const MainFunctionParams& parameters() const { | 96 const MainFunctionParams& parameters() const { |
90 return parameters_; | 97 return parameters_; |
91 } | 98 } |
92 const CommandLine& parsed_command_line() const { | 99 const CommandLine& parsed_command_line() const { |
93 return parsed_command_line_; | 100 return parsed_command_line_; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // A/B test for SSL False Start. | 132 // A/B test for SSL False Start. |
126 void SSLFalseStartFieldTrial(); | 133 void SSLFalseStartFieldTrial(); |
127 | 134 |
128 // Used to initialize NSPR where appropriate. | 135 // Used to initialize NSPR where appropriate. |
129 virtual void InitializeSSL() = 0; | 136 virtual void InitializeSSL() = 0; |
130 | 137 |
131 // Methods for |MainMessageLoopStart()| -------------------------------------- | 138 // Methods for |MainMessageLoopStart()| -------------------------------------- |
132 | 139 |
133 void InitializeMainThread(); | 140 void InitializeMainThread(); |
134 | 141 |
| 142 // Methods for |SetupMetricsAndFieldTrials()| -------------------------------- |
| 143 |
| 144 static MetricsService* InitializeMetrics( |
| 145 const CommandLine& parsed_command_line, |
| 146 const PrefService* local_state); |
| 147 |
| 148 // Add an invocation of your field trial init function to this method. |
| 149 void SetupFieldTrials(bool metrics_recording_enabled); |
| 150 |
135 // Members initialized on construction --------------------------------------- | 151 // Members initialized on construction --------------------------------------- |
136 | 152 |
137 const MainFunctionParams& parameters_; | 153 const MainFunctionParams& parameters_; |
138 const CommandLine& parsed_command_line_; | 154 const CommandLine& parsed_command_line_; |
139 | 155 |
140 #if defined(TRACK_ALL_TASK_OBJECTS) | 156 #if defined(TRACK_ALL_TASK_OBJECTS) |
141 // Creating this object starts tracking the creation and deletion of Task | 157 // Creating this object starts tracking the creation and deletion of Task |
142 // instance. This MUST be done before main_message_loop, so that it is | 158 // instance. This MUST be done before main_message_loop, so that it is |
143 // destroyed after the main_message_loop. | 159 // destroyed after the main_message_loop. |
144 tracked_objects::AutoTracking tracking_objects_; | 160 tracked_objects::AutoTracking tracking_objects_; |
145 #endif | 161 #endif |
146 | 162 |
147 // Statistical testing infrastructure for the entire browser. | 163 // Statistical testing infrastructure for the entire browser. NULL until |
148 base::FieldTrialList field_trial_; | 164 // SetupMetricsAndFieldTrials is called. |
| 165 scoped_ptr<base::FieldTrialList> field_trial_list_; |
149 | 166 |
150 // Members initialized in |MainMessageLoopStart()| --------------------------- | 167 // Members initialized in |MainMessageLoopStart()| --------------------------- |
151 scoped_ptr<MessageLoop> main_message_loop_; | 168 scoped_ptr<MessageLoop> main_message_loop_; |
152 scoped_ptr<ui::SystemMonitor> system_monitor_; | 169 scoped_ptr<ui::SystemMonitor> system_monitor_; |
153 scoped_ptr<HighResolutionTimerManager> hi_res_timer_manager_; | 170 scoped_ptr<HighResolutionTimerManager> hi_res_timer_manager_; |
154 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 171 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
155 scoped_ptr<BrowserThread> main_thread_; | 172 scoped_ptr<BrowserThread> main_thread_; |
156 | 173 |
| 174 // Initialized in SetupMetricsAndFieldTrials. |
| 175 scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer_; |
| 176 |
157 DISALLOW_COPY_AND_ASSIGN(BrowserMainParts); | 177 DISALLOW_COPY_AND_ASSIGN(BrowserMainParts); |
158 }; | 178 }; |
159 | 179 |
160 | 180 |
161 // Perform platform-specific work that needs to be done after the main event | 181 // Perform platform-specific work that needs to be done after the main event |
162 // loop has ended. | 182 // loop has ended. |
163 void DidEndMainMessageLoop(); | 183 void DidEndMainMessageLoop(); |
164 | 184 |
165 // Records the conditions that can prevent Breakpad from generating and | 185 // Records the conditions that can prevent Breakpad from generating and |
166 // sending crash reports. The presence of a Breakpad handler (after | 186 // sending crash reports. The presence of a Breakpad handler (after |
167 // attempting to initialize crash reporting) and the presence of a debugger | 187 // attempting to initialize crash reporting) and the presence of a debugger |
168 // are registered with the UMA metrics service. | 188 // are registered with the UMA metrics service. |
169 void RecordBreakpadStatusUMA(MetricsService* metrics); | 189 void RecordBreakpadStatusUMA(MetricsService* metrics); |
170 | 190 |
171 // Displays a warning message if some minimum level of OS support is not | 191 // Displays a warning message if some minimum level of OS support is not |
172 // present on the current platform. | 192 // present on the current platform. |
173 void WarnAboutMinimumSystemRequirements(); | 193 void WarnAboutMinimumSystemRequirements(); |
174 | 194 |
175 // Records the time from our process' startup to the present time in | 195 // Records the time from our process' startup to the present time in |
176 // the UMA histogram |metric_name|. | 196 // the UMA histogram |metric_name|. |
177 void RecordBrowserStartupTime(); | 197 void RecordBrowserStartupTime(); |
178 | 198 |
179 #endif // CHROME_BROWSER_BROWSER_MAIN_H_ | 199 #endif // CHROME_BROWSER_BROWSER_MAIN_H_ |
OLD | NEW |