blob: 74ed9ec1037d99bdf4ebca712d19507349f9332e [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]67372ecf2011-09-10 01:30:4678 // Field trial to see what disabling DNS pre-resolution does to
79 // latency of page loads.
80 void PredictorFieldTrial();
81
[email protected]edafd4c2011-05-10 17:18:5382 // Methods for |SetupMetricsAndFieldTrials()| --------------------------------
83
84 static MetricsService* InitializeMetrics(
85 const CommandLine& parsed_command_line,
86 const PrefService* local_state);
87
88 // Add an invocation of your field trial init function to this method.
[email protected]12c84e22011-07-11 09:35:4589 void SetupFieldTrials(bool metrics_recording_enabled,
90 bool proxy_policy_is_set);
[email protected]edafd4c2011-05-10 17:18:5391
[email protected]f8abf722010-07-07 19:46:2492 // Members initialized on construction ---------------------------------------
93
[email protected]f967b722011-09-07 00:58:0494 // Create ShutdownWatcherHelper object for watching jank during shutdown.
95 // Please keep |shutdown_watcher| as the first object constructed, and hence
96 // it is destroyed last.
97 scoped_ptr<ShutdownWatcherHelper> shutdown_watcher_;
[email protected]f8abf722010-07-07 19:46:2498
99#if defined(TRACK_ALL_TASK_OBJECTS)
100 // Creating this object starts tracking the creation and deletion of Task
101 // instance. This MUST be done before main_message_loop, so that it is
102 // destroyed after the main_message_loop.
103 tracked_objects::AutoTracking tracking_objects_;
104#endif
105
[email protected]edafd4c2011-05-10 17:18:53106 // Statistical testing infrastructure for the entire browser. NULL until
107 // SetupMetricsAndFieldTrials is called.
108 scoped_ptr<base::FieldTrialList> field_trial_list_;
[email protected]f8abf722010-07-07 19:46:24109
[email protected]0f247aea82011-09-03 03:05:51110 // Members initialized after / released before main_message_loop_ ------------
111
[email protected]c1702d712011-09-08 19:41:43112 scoped_ptr<BrowserProcessImpl> browser_process_;
[email protected]0f247aea82011-09-03 03:05:51113 scoped_refptr<HistogramSynchronizer> histogram_synchronizer_;
[email protected]c1702d712011-09-08 19:41:43114 scoped_ptr<ProcessSingleton> process_singleton_;
115 scoped_ptr<FirstRun::MasterPrefs> master_prefs_;
116 bool record_search_engine_;
117 TranslateManager* translate_manager_;
118 Profile* profile_;
119 bool run_message_loop_;
[email protected]0f247aea82011-09-03 03:05:51120
[email protected]edafd4c2011-05-10 17:18:53121 // Initialized in SetupMetricsAndFieldTrials.
122 scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer_;
123
[email protected]5e6efa52011-06-27 17:26:41124 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket);
125 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Random);
126 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Invalid);
[email protected]f967b722011-09-07 00:58:04127 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts);
[email protected]f8abf722010-07-07 19:46:24128};
129
[email protected]1152b7e2009-09-14 03:26:03130// Records the conditions that can prevent Breakpad from generating and
131// sending crash reports. The presence of a Breakpad handler (after
132// attempting to initialize crash reporting) and the presence of a debugger
133// are registered with the UMA metrics service.
134void RecordBreakpadStatusUMA(MetricsService* metrics);
135
[email protected]34f73fb2010-03-24 20:50:34136// Displays a warning message if some minimum level of OS support is not
137// present on the current platform.
138void WarnAboutMinimumSystemRequirements();
[email protected]1152b7e2009-09-14 03:26:03139
[email protected]cbce47242011-08-12 21:40:59140// Displays a warning message that we can't find any locale data files.
141void ShowMissingLocaleMessageBox();
142
[email protected]45d72762011-04-15 18:58:20143// Records the time from our process' startup to the present time in
144// the UMA histogram |metric_name|.
145void RecordBrowserStartupTime();
146
[email protected]28f576f2011-08-26 20:46:55147// Records a time value to an UMA histogram in the context of the
148// PreReadExperiment field-trial. This also reports to the appropriate
149// sub-histogram (_PreRead(Enabled|Disabled)).
150void RecordPreReadExperimentTime(const char* name, base::TimeDelta time);
151
[email protected]e6b5bc22011-09-08 22:01:56152#endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_H_