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" | |
13 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
14 #include "base/tracked_objects.h" | 13 #include "base/tracked_objects.h" |
15 #include "chrome/browser/first_run/first_run.h" | 14 #include "chrome/browser/first_run/first_run.h" |
16 #include "chrome/browser/process_singleton.h" | 15 #include "chrome/browser/process_singleton.h" |
17 #include "content/public/browser/browser_main_parts.h" | 16 #include "content/public/browser/browser_main_parts.h" |
18 | 17 |
19 class BrowserInit; | 18 class BrowserInit; |
20 class BrowserProcessImpl; | 19 class BrowserProcessImpl; |
21 class ChromeBrowserMainExtraParts; | |
22 class FieldTrialSynchronizer; | 20 class FieldTrialSynchronizer; |
23 class HistogramSynchronizer; | 21 class HistogramSynchronizer; |
24 class MetricsService; | 22 class MetricsService; |
25 class PrefService; | 23 class PrefService; |
26 class Profile; | 24 class Profile; |
27 class ShutdownWatcherHelper; | 25 class ShutdownWatcherHelper; |
28 class TranslateManager; | 26 class TranslateManager; |
29 | 27 |
30 namespace chrome_browser { | 28 namespace chrome_browser { |
31 // For use by ShowMissingLocaleMessageBox. | 29 // For use by ShowMissingLocaleMessageBox. |
32 extern const char kMissingLocaleDataTitle[]; | 30 extern const char kMissingLocaleDataTitle[]; |
33 extern const char kMissingLocaleDataMessage[]; | 31 extern const char kMissingLocaleDataMessage[]; |
34 } | 32 } |
35 | 33 |
36 namespace chrome_browser_metrics { | 34 namespace chrome_browser_metrics { |
37 class TrackingSynchronizer; | 35 class TrackingSynchronizer; |
38 } | 36 } |
39 | 37 |
40 namespace content { | 38 namespace content { |
41 struct MainFunctionParams; | 39 struct MainFunctionParams; |
42 } | 40 } |
43 | 41 |
44 class ChromeBrowserMainParts : public content::BrowserMainParts { | 42 class ChromeBrowserMainParts : public content::BrowserMainParts { |
45 public: | 43 public: |
46 virtual ~ChromeBrowserMainParts(); | 44 virtual ~ChromeBrowserMainParts(); |
47 | 45 |
48 // Add additional ChromeBrowserMainExtraParts. | 46 // Constructs metrics service and does related initialization, including |
49 virtual void AddParts(ChromeBrowserMainExtraParts* parts); | 47 // creation of field trials. Call only after labs have been converted to |
| 48 // switches. |
| 49 MetricsService* SetupMetricsAndFieldTrials(PrefService* local_state); |
| 50 |
| 51 const content::MainFunctionParams& parameters() const { |
| 52 return parameters_; |
| 53 } |
| 54 const CommandLine& parsed_command_line() const { |
| 55 return parsed_command_line_; |
| 56 } |
50 | 57 |
51 protected: | 58 protected: |
52 explicit ChromeBrowserMainParts( | 59 explicit ChromeBrowserMainParts( |
53 const content::MainFunctionParams& parameters); | 60 const content::MainFunctionParams& parameters); |
54 | 61 |
55 // content::BrowserMainParts overrides. | 62 // content::BrowserParts overrides |
56 virtual void PreEarlyInitialization() OVERRIDE; | 63 virtual void PreEarlyInitialization() OVERRIDE; |
57 virtual void PostEarlyInitialization() OVERRIDE; | 64 virtual void PostEarlyInitialization() OVERRIDE; |
58 virtual void ToolkitInitialized() OVERRIDE; | 65 virtual void ToolkitInitialized() OVERRIDE; |
59 virtual void PreMainMessageLoopStart() OVERRIDE; | 66 virtual void PreMainMessageLoopStart() OVERRIDE; |
60 virtual void PostMainMessageLoopStart() OVERRIDE; | 67 virtual void PostMainMessageLoopStart() OVERRIDE; |
61 virtual void PreMainMessageLoopRun() OVERRIDE; | 68 virtual void PreMainMessageLoopRun() OVERRIDE; |
62 virtual bool MainMessageLoopRun(int* result_code) OVERRIDE; | 69 virtual bool MainMessageLoopRun(int* result_code) OVERRIDE; |
63 virtual void PostMainMessageLoopRun() OVERRIDE; | 70 virtual void PostMainMessageLoopRun() OVERRIDE; |
64 | 71 |
65 // Displays a warning message that we can't find any locale data files. | 72 // Displays a warning message that we can't find any locale data files. |
66 virtual void ShowMissingLocaleMessageBox() = 0; | 73 virtual void ShowMissingLocaleMessageBox() = 0; |
67 | 74 |
68 const content::MainFunctionParams& parameters() const { | |
69 return parameters_; | |
70 } | |
71 const CommandLine& parsed_command_line() const { | |
72 return parsed_command_line_; | |
73 } | |
74 | |
75 Profile* profile() { return profile_; } | |
76 | |
77 private: | 75 private: |
78 // Methods for |EarlyInitialization()| --------------------------------------- | 76 // Methods for |EarlyInitialization()| --------------------------------------- |
79 | 77 |
80 // A/B test for the maximum number of persistent connections per host. | 78 // A/B test for the maximum number of persistent connections per host. |
81 void ConnectionFieldTrial(); | 79 void ConnectionFieldTrial(); |
82 | 80 |
83 // A/B test for determining a value for unused socket timeout. | 81 // A/B test for determining a value for unused socket timeout. |
84 void SocketTimeoutFieldTrial(); | 82 void SocketTimeoutFieldTrial(); |
85 | 83 |
86 // A/B test for the maximum number of connections per proxy server. | 84 // A/B test for the maximum number of connections per proxy server. |
(...skipping 12 matching lines...) Expand all Loading... |
99 // Field trial to see what disabling DNS pre-resolution does to | 97 // Field trial to see what disabling DNS pre-resolution does to |
100 // latency of page loads. | 98 // latency of page loads. |
101 void PredictorFieldTrial(); | 99 void PredictorFieldTrial(); |
102 | 100 |
103 // Field trial to see what effect installing defaults in the NTP apps pane | 101 // Field trial to see what effect installing defaults in the NTP apps pane |
104 // has on retention and general apps/webstore usage. | 102 // has on retention and general apps/webstore usage. |
105 void DefaultAppsFieldTrial(); | 103 void DefaultAppsFieldTrial(); |
106 | 104 |
107 // Methods for |SetupMetricsAndFieldTrials()| -------------------------------- | 105 // Methods for |SetupMetricsAndFieldTrials()| -------------------------------- |
108 | 106 |
109 // Constructs metrics service and does related initialization, including | |
110 // creation of field trials. Call only after labs have been converted to | |
111 // switches. | |
112 MetricsService* SetupMetricsAndFieldTrials(PrefService* local_state); | |
113 | |
114 static MetricsService* InitializeMetrics( | 107 static MetricsService* InitializeMetrics( |
115 const CommandLine& parsed_command_line, | 108 const CommandLine& parsed_command_line, |
116 const PrefService* local_state); | 109 const PrefService* local_state); |
117 | 110 |
118 // Add an invocation of your field trial init function to this method. | 111 // Add an invocation of your field trial init function to this method. |
119 void SetupFieldTrials(bool metrics_recording_enabled, | 112 void SetupFieldTrials(bool metrics_recording_enabled, |
120 bool proxy_policy_is_set); | 113 bool proxy_policy_is_set); |
121 | 114 |
122 // Methods for Main Message Loop ------------------------------------------- | 115 // Methods for Main Message Loop ------------------------------------------- |
123 | 116 |
124 int PreMainMessageLoopRunImpl(); | 117 int PreMainMessageLoopRunImpl(); |
| 118 void StartBrowserOrUITask(); |
125 | 119 |
126 // Members initialized on construction --------------------------------------- | 120 // Members initialized on construction --------------------------------------- |
127 | 121 |
128 const content::MainFunctionParams& parameters_; | 122 const content::MainFunctionParams& parameters_; |
129 const CommandLine& parsed_command_line_; | 123 const CommandLine& parsed_command_line_; |
130 int result_code_; | 124 int result_code_; |
131 | 125 |
132 // Create ShutdownWatcherHelper object for watching jank during shutdown. | 126 // Create ShutdownWatcherHelper object for watching jank during shutdown. |
133 // Please keep |shutdown_watcher| as the first object constructed, and hence | 127 // Please keep |shutdown_watcher| as the first object constructed, and hence |
134 // it is destroyed last. | 128 // it is destroyed last. |
135 scoped_ptr<ShutdownWatcherHelper> shutdown_watcher_; | 129 scoped_ptr<ShutdownWatcherHelper> shutdown_watcher_; |
136 | 130 |
137 // Creating this object starts tracking the creation and deletion of Task | 131 // Creating this object starts tracking the creation and deletion of Task |
138 // instance. This MUST be done before main_message_loop, so that it is | 132 // instance. This MUST be done before main_message_loop, so that it is |
139 // destroyed after the main_message_loop. | 133 // destroyed after the main_message_loop. |
140 tracked_objects::AutoTracking tracking_objects_; | 134 tracked_objects::AutoTracking tracking_objects_; |
141 | 135 |
142 // Statistical testing infrastructure for the entire browser. NULL until | 136 // Statistical testing infrastructure for the entire browser. NULL until |
143 // SetupMetricsAndFieldTrials is called. | 137 // SetupMetricsAndFieldTrials is called. |
144 scoped_ptr<base::FieldTrialList> field_trial_list_; | 138 scoped_ptr<base::FieldTrialList> field_trial_list_; |
145 | 139 |
146 // Vector of additional ChromeBrowserMainExtraParts. | |
147 ScopedVector<ChromeBrowserMainExtraParts> chrome_extra_parts_; | |
148 | |
149 // Members initialized after / released before main_message_loop_ ------------ | 140 // Members initialized after / released before main_message_loop_ ------------ |
150 | 141 |
151 scoped_ptr<BrowserInit> browser_init_; | 142 scoped_ptr<BrowserInit> browser_init_; |
152 scoped_ptr<BrowserProcessImpl> browser_process_; | 143 scoped_ptr<BrowserProcessImpl> browser_process_; |
153 scoped_refptr<HistogramSynchronizer> histogram_synchronizer_; | 144 scoped_refptr<HistogramSynchronizer> histogram_synchronizer_; |
154 scoped_refptr<chrome_browser_metrics::TrackingSynchronizer> | 145 scoped_refptr<chrome_browser_metrics::TrackingSynchronizer> |
155 tracking_synchronizer_; | 146 tracking_synchronizer_; |
156 scoped_ptr<ProcessSingleton> process_singleton_; | 147 scoped_ptr<ProcessSingleton> process_singleton_; |
157 scoped_ptr<FirstRun::MasterPrefs> master_prefs_; | 148 scoped_ptr<FirstRun::MasterPrefs> master_prefs_; |
158 bool record_search_engine_; | 149 bool record_search_engine_; |
(...skipping 24 matching lines...) Expand all Loading... |
183 // Records the time from our process' startup to the present time in | 174 // Records the time from our process' startup to the present time in |
184 // the UMA histogram |metric_name|. | 175 // the UMA histogram |metric_name|. |
185 void RecordBrowserStartupTime(); | 176 void RecordBrowserStartupTime(); |
186 | 177 |
187 // Records a time value to an UMA histogram in the context of the | 178 // Records a time value to an UMA histogram in the context of the |
188 // PreReadExperiment field-trial. This also reports to the appropriate | 179 // PreReadExperiment field-trial. This also reports to the appropriate |
189 // sub-histogram (_PreRead(Enabled|Disabled)). | 180 // sub-histogram (_PreRead(Enabled|Disabled)). |
190 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time); | 181 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time); |
191 | 182 |
192 #endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ | 183 #endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ |
OLD | NEW |