blob: 503de2303b5875d52cab34e88010e5e5d6a4486c [file] [log] [blame]
[email protected]3b63f8f42011-03-28 01:54:151// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]1152b7e2009-09-14 03:26:032// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]e6b5bc22011-09-08 22:01:565#ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_H_
6#define CHROME_BROWSER_CHROME_BROWSER_MAIN_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]1152b7e2009-09-14 03:26:038
[email protected]f8abf722010-07-07 19:46:249#include "base/basictypes.h"
[email protected]5e6efa52011-06-27 17:26:4110#include "base/gtest_prod_util.h"
[email protected]835d7c82010-10-14 04:38:3811#include "base/metrics/field_trial.h"
[email protected]f8abf722010-07-07 19:46:2412#include "base/tracked_objects.h"
[email protected]c1702d712011-09-08 19:41:4313#include "chrome/browser/first_run/first_run.h"
[email protected]f967b722011-09-07 00:58:0414#include "content/browser/browser_main.h"
[email protected]f8abf722010-07-07 19:46:2415
[email protected]c1702d712011-09-08 19:41:4316class BrowserProcessImpl;
[email protected]edafd4c2011-05-10 17:18:5317class FieldTrialSynchronizer;
[email protected]f967b722011-09-07 00:58:0418class HistogramSynchronizer;
[email protected]1152b7e2009-09-14 03:26:0319class MetricsService;
[email protected]edafd4c2011-05-10 17:18:5320class PrefService;
[email protected]c1702d712011-09-08 19:41:4321class ProcessSingleton;
22class Profile;
[email protected]f967b722011-09-07 00:58:0423class ShutdownWatcherHelper;
[email protected]c1702d712011-09-08 19:41:4324class TranslateManager;
[email protected]5f988b92011-05-18 07:14:0825
[email protected]cbce47242011-08-12 21:40:5926namespace chrome_browser {
27// For use by ShowMissingLocaleMessageBox.
28extern const char kMissingLocaleDataTitle[];
29extern const char kMissingLocaleDataMessage[];
30}
31
[email protected]f967b722011-09-07 00:58:0432class ChromeBrowserMainParts : public content::BrowserMainParts {
[email protected]f8abf722010-07-07 19:46:2433 public:
[email protected]f967b722011-09-07 00:58:0434 virtual ~ChromeBrowserMainParts();
[email protected]f8abf722010-07-07 19:46:2435
[email protected]edafd4c2011-05-10 17:18:5336 // 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]68adccab2011-01-26 21:18:1342
[email protected]f8abf722010-07-07 19:46:2443 protected:
[email protected]f967b722011-09-07 00:58:0444 explicit ChromeBrowserMainParts(const MainFunctionParams& parameters);
[email protected]f8abf722010-07-07 19:46:2445
[email protected]f967b722011-09-07 00:58:0446 virtual void PostMainMessageLoopStart() OVERRIDE;
[email protected]c1702d712011-09-08 19:41:4347 virtual void PreMainMessageLoopRun() OVERRIDE;
48 int PreMainMessageLoopRunInternal();
49 virtual void MainMessageLoopRun() OVERRIDE;
50 virtual void PostMainMessageLoopRun() OVERRIDE;
[email protected]f967b722011-09-07 00:58:0451 virtual void ToolkitInitialized() OVERRIDE;
[email protected]f8abf722010-07-07 19:46:2452
[email protected]1fec64352010-07-27 13:55:2153 private:
[email protected]f8abf722010-07-07 19:46:2454 // 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]78a258a2010-08-02 16:34:2662 // A/B test for the maximum number of connections per proxy server.
63 void ProxyConnectionsFieldTrial();
64
[email protected]f8abf722010-07-07 19:46:2465 // A/B test for spdy when --use-spdy not set.
66 void SpdyFieldTrial();
67
[email protected]6930c522011-07-28 22:15:1968 // A/B test for warmest socket vs. most recently used socket.
69 void WarmConnectionFieldTrial();
70
[email protected]06d94042010-08-25 01:45:2271 // A/B test for automatically establishing a backup TCP connection when a
72 // specified timeout value is reached.
73 void ConnectBackupJobsFieldTrial();
74
[email protected]6930c522011-07-28 22:15:1975 // A/B test for using a different host prefix in Google search suggest.
76 void SuggestPrefixFieldTrial();
[email protected]5e6efa52011-06-27 17:26:4177
[email protected]edafd4c2011-05-10 17:18:5378 // 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]12c84e22011-07-11 09:35:4585 void SetupFieldTrials(bool metrics_recording_enabled,
86 bool proxy_policy_is_set);
[email protected]edafd4c2011-05-10 17:18:5387
[email protected]f8abf722010-07-07 19:46:2488 // Members initialized on construction ---------------------------------------
89
[email protected]f967b722011-09-07 00:58:0490 // 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]f8abf722010-07-07 19:46:2494
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]edafd4c2011-05-10 17:18:53102 // Statistical testing infrastructure for the entire browser. NULL until
103 // SetupMetricsAndFieldTrials is called.
104 scoped_ptr<base::FieldTrialList> field_trial_list_;
[email protected]f8abf722010-07-07 19:46:24105
[email protected]0f247aea82011-09-03 03:05:51106 // Members initialized after / released before main_message_loop_ ------------
107
[email protected]c1702d712011-09-08 19:41:43108 scoped_ptr<BrowserProcessImpl> browser_process_;
[email protected]0f247aea82011-09-03 03:05:51109 scoped_refptr<HistogramSynchronizer> histogram_synchronizer_;
[email protected]c1702d712011-09-08 19:41:43110 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]0f247aea82011-09-03 03:05:51116
[email protected]edafd4c2011-05-10 17:18:53117 // Initialized in SetupMetricsAndFieldTrials.
118 scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer_;
119
[email protected]5e6efa52011-06-27 17:26:41120 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket);
121 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Random);
122 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Invalid);
[email protected]f967b722011-09-07 00:58:04123 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts);
[email protected]f8abf722010-07-07 19:46:24124};
125
[email protected]1152b7e2009-09-14 03:26:03126// 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.
130void RecordBreakpadStatusUMA(MetricsService* metrics);
131
[email protected]34f73fb2010-03-24 20:50:34132// Displays a warning message if some minimum level of OS support is not
133// present on the current platform.
134void WarnAboutMinimumSystemRequirements();
[email protected]1152b7e2009-09-14 03:26:03135
[email protected]cbce47242011-08-12 21:40:59136// Displays a warning message that we can't find any locale data files.
137void ShowMissingLocaleMessageBox();
138
[email protected]45d72762011-04-15 18:58:20139// Records the time from our process' startup to the present time in
140// the UMA histogram |metric_name|.
141void RecordBrowserStartupTime();
142
[email protected]28f576f2011-08-26 20:46:55143// 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)).
146void RecordPreReadExperimentTime(const char* name, base::TimeDelta time);
147
[email protected]e6b5bc22011-09-08 22:01:56148#endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_H_