blob: 177ed1cbb505b8886312f309663e59a61f520c6f [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
5#ifndef CHROME_BROWSER_BROWSER_MAIN_H_
6#define CHROME_BROWSER_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]f967b722011-09-07 00:58:0413#include "content/browser/browser_main.h"
[email protected]f8abf722010-07-07 19:46:2414
[email protected]edafd4c2011-05-10 17:18:5315class FieldTrialSynchronizer;
[email protected]f967b722011-09-07 00:58:0416class HistogramSynchronizer;
[email protected]1152b7e2009-09-14 03:26:0317class MetricsService;
[email protected]edafd4c2011-05-10 17:18:5318class PrefService;
[email protected]f967b722011-09-07 00:58:0419class ShutdownWatcherHelper;
[email protected]5f988b92011-05-18 07:14:0820
[email protected]cbce47242011-08-12 21:40:5921namespace chrome_browser {
22// For use by ShowMissingLocaleMessageBox.
23extern const char kMissingLocaleDataTitle[];
24extern const char kMissingLocaleDataMessage[];
25}
26
[email protected]f967b722011-09-07 00:58:0427class ChromeBrowserMainParts : public content::BrowserMainParts {
[email protected]f8abf722010-07-07 19:46:2428 public:
[email protected]f967b722011-09-07 00:58:0429 virtual ~ChromeBrowserMainParts();
[email protected]f8abf722010-07-07 19:46:2430
[email protected]0f247aea82011-09-03 03:05:5131 // Constructs HistogramSynchronizer which gets released early (before
32 // main_message_loop_).
33 void SetupHistogramSynchronizer();
34
[email protected]edafd4c2011-05-10 17:18:5335 // 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]68adccab2011-01-26 21:18:1341
[email protected]f8abf722010-07-07 19:46:2442 protected:
[email protected]f967b722011-09-07 00:58:0443 explicit ChromeBrowserMainParts(const MainFunctionParams& parameters);
[email protected]f8abf722010-07-07 19:46:2444
[email protected]f967b722011-09-07 00:58:0445 virtual void PostMainMessageLoopStart() OVERRIDE;
46 virtual void ToolkitInitialized() OVERRIDE;
[email protected]f8abf722010-07-07 19:46:2447
[email protected]f967b722011-09-07 00:58:0448 virtual int TemporaryContinue() OVERRIDE;
[email protected]c1275ae2010-07-12 17:40:4949
[email protected]1fec64352010-07-27 13:55:2150 private:
[email protected]f8abf722010-07-07 19:46:2451 // 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]78a258a2010-08-02 16:34:2659 // A/B test for the maximum number of connections per proxy server.
60 void ProxyConnectionsFieldTrial();
61
[email protected]f8abf722010-07-07 19:46:2462 // A/B test for spdy when --use-spdy not set.
63 void SpdyFieldTrial();
64
[email protected]6930c522011-07-28 22:15:1965 // A/B test for warmest socket vs. most recently used socket.
66 void WarmConnectionFieldTrial();
67
[email protected]06d94042010-08-25 01:45:2268 // A/B test for automatically establishing a backup TCP connection when a
69 // specified timeout value is reached.
70 void ConnectBackupJobsFieldTrial();
71
[email protected]6930c522011-07-28 22:15:1972 // A/B test for using a different host prefix in Google search suggest.
73 void SuggestPrefixFieldTrial();
[email protected]5e6efa52011-06-27 17:26:4174
[email protected]edafd4c2011-05-10 17:18:5375 // 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]12c84e22011-07-11 09:35:4582 void SetupFieldTrials(bool metrics_recording_enabled,
83 bool proxy_policy_is_set);
[email protected]edafd4c2011-05-10 17:18:5384
[email protected]f8abf722010-07-07 19:46:2485 // Members initialized on construction ---------------------------------------
86
[email protected]f967b722011-09-07 00:58:0487 // 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]f8abf722010-07-07 19:46:2491
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]edafd4c2011-05-10 17:18:5399 // Statistical testing infrastructure for the entire browser. NULL until
100 // SetupMetricsAndFieldTrials is called.
101 scoped_ptr<base::FieldTrialList> field_trial_list_;
[email protected]f8abf722010-07-07 19:46:24102
[email protected]0f247aea82011-09-03 03:05:51103 // Members initialized after / released before main_message_loop_ ------------
104
105 // Initialized in SetupHistogramSynchronizer.
106 scoped_refptr<HistogramSynchronizer> histogram_synchronizer_;
107
[email protected]edafd4c2011-05-10 17:18:53108 // Initialized in SetupMetricsAndFieldTrials.
109 scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer_;
110
[email protected]5e6efa52011-06-27 17:26:41111 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket);
112 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Random);
113 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Invalid);
[email protected]f967b722011-09-07 00:58:04114 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts);
[email protected]f8abf722010-07-07 19:46:24115};
116
[email protected]1152b7e2009-09-14 03:26:03117// 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.
121void RecordBreakpadStatusUMA(MetricsService* metrics);
122
[email protected]34f73fb2010-03-24 20:50:34123// Displays a warning message if some minimum level of OS support is not
124// present on the current platform.
125void WarnAboutMinimumSystemRequirements();
[email protected]1152b7e2009-09-14 03:26:03126
[email protected]cbce47242011-08-12 21:40:59127// Displays a warning message that we can't find any locale data files.
128void ShowMissingLocaleMessageBox();
129
[email protected]45d72762011-04-15 18:58:20130// Records the time from our process' startup to the present time in
131// the UMA histogram |metric_name|.
132void RecordBrowserStartupTime();
133
[email protected]28f576f2011-08-26 20:46:55134// 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)).
137void RecordPreReadExperimentTime(const char* name, base::TimeDelta time);
138
[email protected]1152b7e2009-09-14 03:26:03139#endif // CHROME_BROWSER_BROWSER_MAIN_H_