blob: b6d9817f6d9c14ab522dbdc0380646e35fac7503 [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]66013922011-09-13 18:53:4214#include "chrome/browser/process_singleton.h"
[email protected]f967b722011-09-07 00:58:0415#include "content/browser/browser_main.h"
[email protected]f8abf722010-07-07 19:46:2416
[email protected]c1702d712011-09-08 19:41:4317class BrowserProcessImpl;
[email protected]edafd4c2011-05-10 17:18:5318class FieldTrialSynchronizer;
[email protected]f967b722011-09-07 00:58:0419class HistogramSynchronizer;
[email protected]1152b7e2009-09-14 03:26:0320class MetricsService;
[email protected]edafd4c2011-05-10 17:18:5321class PrefService;
[email protected]c1702d712011-09-08 19:41:4322class 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]51a7a9d2011-09-27 17:21:4182 // Field trial to see what effect installing defaults in the NTP apps pane
83 // has on retention and general apps/webstore usage.
84 void DefaultAppsFieldTrial();
85
[email protected]edafd4c2011-05-10 17:18:5386 // Methods for |SetupMetricsAndFieldTrials()| --------------------------------
87
88 static MetricsService* InitializeMetrics(
89 const CommandLine& parsed_command_line,
90 const PrefService* local_state);
91
92 // Add an invocation of your field trial init function to this method.
[email protected]12c84e22011-07-11 09:35:4593 void SetupFieldTrials(bool metrics_recording_enabled,
94 bool proxy_policy_is_set);
[email protected]edafd4c2011-05-10 17:18:5395
[email protected]f8abf722010-07-07 19:46:2496 // Members initialized on construction ---------------------------------------
97
[email protected]f967b722011-09-07 00:58:0498 // Create ShutdownWatcherHelper object for watching jank during shutdown.
99 // Please keep |shutdown_watcher| as the first object constructed, and hence
100 // it is destroyed last.
101 scoped_ptr<ShutdownWatcherHelper> shutdown_watcher_;
[email protected]f8abf722010-07-07 19:46:24102
103#if defined(TRACK_ALL_TASK_OBJECTS)
104 // Creating this object starts tracking the creation and deletion of Task
105 // instance. This MUST be done before main_message_loop, so that it is
106 // destroyed after the main_message_loop.
107 tracked_objects::AutoTracking tracking_objects_;
108#endif
109
[email protected]edafd4c2011-05-10 17:18:53110 // Statistical testing infrastructure for the entire browser. NULL until
111 // SetupMetricsAndFieldTrials is called.
112 scoped_ptr<base::FieldTrialList> field_trial_list_;
[email protected]f8abf722010-07-07 19:46:24113
[email protected]0f247aea82011-09-03 03:05:51114 // Members initialized after / released before main_message_loop_ ------------
115
[email protected]c1702d712011-09-08 19:41:43116 scoped_ptr<BrowserProcessImpl> browser_process_;
[email protected]0f247aea82011-09-03 03:05:51117 scoped_refptr<HistogramSynchronizer> histogram_synchronizer_;
[email protected]c1702d712011-09-08 19:41:43118 scoped_ptr<ProcessSingleton> process_singleton_;
119 scoped_ptr<FirstRun::MasterPrefs> master_prefs_;
120 bool record_search_engine_;
121 TranslateManager* translate_manager_;
122 Profile* profile_;
123 bool run_message_loop_;
[email protected]66013922011-09-13 18:53:42124 ProcessSingleton::NotifyResult notify_result_;
[email protected]0f247aea82011-09-03 03:05:51125
[email protected]edafd4c2011-05-10 17:18:53126 // Initialized in SetupMetricsAndFieldTrials.
127 scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer_;
128
[email protected]5e6efa52011-06-27 17:26:41129 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket);
130 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Random);
131 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Invalid);
[email protected]f967b722011-09-07 00:58:04132 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts);
[email protected]f8abf722010-07-07 19:46:24133};
134
[email protected]1152b7e2009-09-14 03:26:03135// Records the conditions that can prevent Breakpad from generating and
136// sending crash reports. The presence of a Breakpad handler (after
137// attempting to initialize crash reporting) and the presence of a debugger
138// are registered with the UMA metrics service.
139void RecordBreakpadStatusUMA(MetricsService* metrics);
140
[email protected]34f73fb2010-03-24 20:50:34141// Displays a warning message if some minimum level of OS support is not
142// present on the current platform.
143void WarnAboutMinimumSystemRequirements();
[email protected]1152b7e2009-09-14 03:26:03144
[email protected]cbce47242011-08-12 21:40:59145// Displays a warning message that we can't find any locale data files.
146void ShowMissingLocaleMessageBox();
147
[email protected]45d72762011-04-15 18:58:20148// Records the time from our process' startup to the present time in
149// the UMA histogram |metric_name|.
150void RecordBrowserStartupTime();
151
[email protected]28f576f2011-08-26 20:46:55152// Records a time value to an UMA histogram in the context of the
153// PreReadExperiment field-trial. This also reports to the appropriate
154// sub-histogram (_PreRead(Enabled|Disabled)).
155void RecordPreReadExperimentTime(const char* name, base::TimeDelta time);
156
[email protected]e6b5bc22011-09-08 22:01:56157#endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_H_