[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 1152b7e | 2009-09-14 03:26:03 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | e6b5bc2 | 2011-09-08 22:01:56 | [diff] [blame^] | 5 | #ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ |
| 6 | #define CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | 1152b7e | 2009-09-14 03:26:03 | [diff] [blame] | 8 | |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 9 | #include "base/basictypes.h" |
[email protected] | 5e6efa5 | 2011-06-27 17:26:41 | [diff] [blame] | 10 | #include "base/gtest_prod_util.h" |
[email protected] | 835d7c8 | 2010-10-14 04:38:38 | [diff] [blame] | 11 | #include "base/metrics/field_trial.h" |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 12 | #include "base/tracked_objects.h" |
[email protected] | c1702d71 | 2011-09-08 19:41:43 | [diff] [blame] | 13 | #include "chrome/browser/first_run/first_run.h" |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 14 | #include "content/browser/browser_main.h" |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 15 | |
[email protected] | c1702d71 | 2011-09-08 19:41:43 | [diff] [blame] | 16 | class BrowserProcessImpl; |
[email protected] | edafd4c | 2011-05-10 17:18:53 | [diff] [blame] | 17 | class FieldTrialSynchronizer; |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 18 | class HistogramSynchronizer; |
[email protected] | 1152b7e | 2009-09-14 03:26:03 | [diff] [blame] | 19 | class MetricsService; |
[email protected] | edafd4c | 2011-05-10 17:18:53 | [diff] [blame] | 20 | class PrefService; |
[email protected] | c1702d71 | 2011-09-08 19:41:43 | [diff] [blame] | 21 | class ProcessSingleton; |
| 22 | class Profile; |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 23 | class ShutdownWatcherHelper; |
[email protected] | c1702d71 | 2011-09-08 19:41:43 | [diff] [blame] | 24 | class TranslateManager; |
[email protected] | 5f988b9 | 2011-05-18 07:14:08 | [diff] [blame] | 25 | |
[email protected] | cbce4724 | 2011-08-12 21:40:59 | [diff] [blame] | 26 | namespace chrome_browser { |
| 27 | // For use by ShowMissingLocaleMessageBox. |
| 28 | extern const char kMissingLocaleDataTitle[]; |
| 29 | extern const char kMissingLocaleDataMessage[]; |
| 30 | } |
| 31 | |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 32 | class ChromeBrowserMainParts : public content::BrowserMainParts { |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 33 | public: |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 34 | virtual ~ChromeBrowserMainParts(); |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 35 | |
[email protected] | edafd4c | 2011-05-10 17:18:53 | [diff] [blame] | 36 | // Constructs metrics service and does related initialization, including |
| 37 | // creation of field trials. Call only after labs have been converted to |
| 38 | // switches. |
| 39 | MetricsService* SetupMetricsAndFieldTrials( |
| 40 | const CommandLine& parsed_command_line, |
| 41 | PrefService* local_state); |
[email protected] | 68adccab | 2011-01-26 21:18:13 | [diff] [blame] | 42 | |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 43 | protected: |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 44 | explicit ChromeBrowserMainParts(const MainFunctionParams& parameters); |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 45 | |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 46 | virtual void PostMainMessageLoopStart() OVERRIDE; |
[email protected] | c1702d71 | 2011-09-08 19:41:43 | [diff] [blame] | 47 | virtual void PreMainMessageLoopRun() OVERRIDE; |
| 48 | int PreMainMessageLoopRunInternal(); |
| 49 | virtual void MainMessageLoopRun() OVERRIDE; |
| 50 | virtual void PostMainMessageLoopRun() OVERRIDE; |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 51 | virtual void ToolkitInitialized() OVERRIDE; |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 52 | |
[email protected] | 1fec6435 | 2010-07-27 13:55:21 | [diff] [blame] | 53 | private: |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 54 | // Methods for |EarlyInitialization()| --------------------------------------- |
| 55 | |
| 56 | // A/B test for the maximum number of persistent connections per host. |
| 57 | void ConnectionFieldTrial(); |
| 58 | |
| 59 | // A/B test for determining a value for unused socket timeout. |
| 60 | void SocketTimeoutFieldTrial(); |
| 61 | |
[email protected] | 78a258a | 2010-08-02 16:34:26 | [diff] [blame] | 62 | // A/B test for the maximum number of connections per proxy server. |
| 63 | void ProxyConnectionsFieldTrial(); |
| 64 | |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 65 | // A/B test for spdy when --use-spdy not set. |
| 66 | void SpdyFieldTrial(); |
| 67 | |
[email protected] | 6930c52 | 2011-07-28 22:15:19 | [diff] [blame] | 68 | // A/B test for warmest socket vs. most recently used socket. |
| 69 | void WarmConnectionFieldTrial(); |
| 70 | |
[email protected] | 06d9404 | 2010-08-25 01:45:22 | [diff] [blame] | 71 | // A/B test for automatically establishing a backup TCP connection when a |
| 72 | // specified timeout value is reached. |
| 73 | void ConnectBackupJobsFieldTrial(); |
| 74 | |
[email protected] | 6930c52 | 2011-07-28 22:15:19 | [diff] [blame] | 75 | // A/B test for using a different host prefix in Google search suggest. |
| 76 | void SuggestPrefixFieldTrial(); |
[email protected] | 5e6efa5 | 2011-06-27 17:26:41 | [diff] [blame] | 77 | |
[email protected] | edafd4c | 2011-05-10 17:18:53 | [diff] [blame] | 78 | // Methods for |SetupMetricsAndFieldTrials()| -------------------------------- |
| 79 | |
| 80 | static MetricsService* InitializeMetrics( |
| 81 | const CommandLine& parsed_command_line, |
| 82 | const PrefService* local_state); |
| 83 | |
| 84 | // Add an invocation of your field trial init function to this method. |
[email protected] | 12c84e2 | 2011-07-11 09:35:45 | [diff] [blame] | 85 | void SetupFieldTrials(bool metrics_recording_enabled, |
| 86 | bool proxy_policy_is_set); |
[email protected] | edafd4c | 2011-05-10 17:18:53 | [diff] [blame] | 87 | |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 88 | // Members initialized on construction --------------------------------------- |
| 89 | |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 90 | // Create ShutdownWatcherHelper object for watching jank during shutdown. |
| 91 | // Please keep |shutdown_watcher| as the first object constructed, and hence |
| 92 | // it is destroyed last. |
| 93 | scoped_ptr<ShutdownWatcherHelper> shutdown_watcher_; |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 94 | |
| 95 | #if defined(TRACK_ALL_TASK_OBJECTS) |
| 96 | // Creating this object starts tracking the creation and deletion of Task |
| 97 | // instance. This MUST be done before main_message_loop, so that it is |
| 98 | // destroyed after the main_message_loop. |
| 99 | tracked_objects::AutoTracking tracking_objects_; |
| 100 | #endif |
| 101 | |
[email protected] | edafd4c | 2011-05-10 17:18:53 | [diff] [blame] | 102 | // Statistical testing infrastructure for the entire browser. NULL until |
| 103 | // SetupMetricsAndFieldTrials is called. |
| 104 | scoped_ptr<base::FieldTrialList> field_trial_list_; |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 105 | |
[email protected] | 0f247aea8 | 2011-09-03 03:05:51 | [diff] [blame] | 106 | // Members initialized after / released before main_message_loop_ ------------ |
| 107 | |
[email protected] | c1702d71 | 2011-09-08 19:41:43 | [diff] [blame] | 108 | scoped_ptr<BrowserProcessImpl> browser_process_; |
[email protected] | 0f247aea8 | 2011-09-03 03:05:51 | [diff] [blame] | 109 | scoped_refptr<HistogramSynchronizer> histogram_synchronizer_; |
[email protected] | c1702d71 | 2011-09-08 19:41:43 | [diff] [blame] | 110 | scoped_ptr<ProcessSingleton> process_singleton_; |
| 111 | scoped_ptr<FirstRun::MasterPrefs> master_prefs_; |
| 112 | bool record_search_engine_; |
| 113 | TranslateManager* translate_manager_; |
| 114 | Profile* profile_; |
| 115 | bool run_message_loop_; |
[email protected] | 0f247aea8 | 2011-09-03 03:05:51 | [diff] [blame] | 116 | |
[email protected] | edafd4c | 2011-05-10 17:18:53 | [diff] [blame] | 117 | // Initialized in SetupMetricsAndFieldTrials. |
| 118 | scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer_; |
| 119 | |
[email protected] | 5e6efa5 | 2011-06-27 17:26:41 | [diff] [blame] | 120 | FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket); |
| 121 | FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Random); |
| 122 | FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Invalid); |
[email protected] | f967b72 | 2011-09-07 00:58:04 | [diff] [blame] | 123 | DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts); |
[email protected] | f8abf72 | 2010-07-07 19:46:24 | [diff] [blame] | 124 | }; |
| 125 | |
[email protected] | 1152b7e | 2009-09-14 03:26:03 | [diff] [blame] | 126 | // Records the conditions that can prevent Breakpad from generating and |
| 127 | // sending crash reports. The presence of a Breakpad handler (after |
| 128 | // attempting to initialize crash reporting) and the presence of a debugger |
| 129 | // are registered with the UMA metrics service. |
| 130 | void RecordBreakpadStatusUMA(MetricsService* metrics); |
| 131 | |
[email protected] | 34f73fb | 2010-03-24 20:50:34 | [diff] [blame] | 132 | // Displays a warning message if some minimum level of OS support is not |
| 133 | // present on the current platform. |
| 134 | void WarnAboutMinimumSystemRequirements(); |
[email protected] | 1152b7e | 2009-09-14 03:26:03 | [diff] [blame] | 135 | |
[email protected] | cbce4724 | 2011-08-12 21:40:59 | [diff] [blame] | 136 | // Displays a warning message that we can't find any locale data files. |
| 137 | void ShowMissingLocaleMessageBox(); |
| 138 | |
[email protected] | 45d7276 | 2011-04-15 18:58:20 | [diff] [blame] | 139 | // Records the time from our process' startup to the present time in |
| 140 | // the UMA histogram |metric_name|. |
| 141 | void RecordBrowserStartupTime(); |
| 142 | |
[email protected] | 28f576f | 2011-08-26 20:46:55 | [diff] [blame] | 143 | // Records a time value to an UMA histogram in the context of the |
| 144 | // PreReadExperiment field-trial. This also reports to the appropriate |
| 145 | // sub-histogram (_PreRead(Enabled|Disabled)). |
| 146 | void RecordPreReadExperimentTime(const char* name, base::TimeDelta time); |
| 147 | |
[email protected] | e6b5bc2 | 2011-09-08 22:01:56 | [diff] [blame^] | 148 | #endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ |