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