blob: 817e8dec4cb41ddc73eee96f8559824a7fd219e5 [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]b48c9182011-10-26 18:03:3011#include "base/memory/scoped_ptr.h"
[email protected]835d7c82010-10-14 04:38:3812#include "base/metrics/field_trial.h"
[email protected]f8abf722010-07-07 19:46:2413#include "base/tracked_objects.h"
[email protected]c1702d712011-09-08 19:41:4314#include "chrome/browser/first_run/first_run.h"
[email protected]66013922011-09-13 18:53:4215#include "chrome/browser/process_singleton.h"
[email protected]b48c9182011-10-26 18:03:3016#include "content/public/browser/browser_main_parts.h"
[email protected]f8abf722010-07-07 19:46:2417
[email protected]c1702d712011-09-08 19:41:4318class BrowserProcessImpl;
[email protected]edafd4c2011-05-10 17:18:5319class FieldTrialSynchronizer;
[email protected]f967b722011-09-07 00:58:0420class HistogramSynchronizer;
[email protected]1152b7e2009-09-14 03:26:0321class MetricsService;
[email protected]edafd4c2011-05-10 17:18:5322class PrefService;
[email protected]c1702d712011-09-08 19:41:4323class Profile;
[email protected]f967b722011-09-07 00:58:0424class ShutdownWatcherHelper;
[email protected]c1702d712011-09-08 19:41:4325class TranslateManager;
[email protected]b48c9182011-10-26 18:03:3026struct MainFunctionParams;
[email protected]5f988b92011-05-18 07:14:0827
[email protected]cbce47242011-08-12 21:40:5928namespace chrome_browser {
29// For use by ShowMissingLocaleMessageBox.
30extern const char kMissingLocaleDataTitle[];
31extern const char kMissingLocaleDataMessage[];
32}
33
[email protected]f967b722011-09-07 00:58:0434class ChromeBrowserMainParts : public content::BrowserMainParts {
[email protected]f8abf722010-07-07 19:46:2435 public:
[email protected]f967b722011-09-07 00:58:0436 virtual ~ChromeBrowserMainParts();
[email protected]f8abf722010-07-07 19:46:2437
[email protected]069cd9952011-10-01 16:34:4538 // Constructs metrics service and does related initialization, including
39 // creation of field trials. Call only after labs have been converted to
40 // switches.
[email protected]b48c9182011-10-26 18:03:3041 MetricsService* SetupMetricsAndFieldTrials(PrefService* local_state);
42
43 const MainFunctionParams& parameters() const {
44 return parameters_;
45 }
46 const CommandLine& parsed_command_line() const {
47 return parsed_command_line_;
48 }
[email protected]069cd9952011-10-01 16:34:4549
[email protected]f8abf722010-07-07 19:46:2450 protected:
[email protected]f967b722011-09-07 00:58:0451 explicit ChromeBrowserMainParts(const MainFunctionParams& parameters);
[email protected]f8abf722010-07-07 19:46:2452
[email protected]b48c9182011-10-26 18:03:3053 // content::BrowserParts overrides
54 virtual void PreEarlyInitialization() OVERRIDE {}
55 virtual void PostEarlyInitialization() OVERRIDE {}
56 virtual void PreMainMessageLoopStart() OVERRIDE {}
[email protected]f967b722011-09-07 00:58:0457 virtual void ToolkitInitialized() OVERRIDE;
[email protected]b48c9182011-10-26 18:03:3058 virtual void PostMainMessageLoopStart() OVERRIDE {}
59 virtual void PreMainMessageLoopRun() OVERRIDE;
60 virtual bool MainMessageLoopRun(int* result_code) OVERRIDE;
61 virtual void PostMainMessageLoopRun();
62
63 // Displays a warning message that we can't find any locale data files.
64 virtual void ShowMissingLocaleMessageBox() = 0;
[email protected]f8abf722010-07-07 19:46:2465
[email protected]1fec64352010-07-27 13:55:2166 private:
[email protected]f8abf722010-07-07 19:46:2467 // Methods for |EarlyInitialization()| ---------------------------------------
68
69 // A/B test for the maximum number of persistent connections per host.
70 void ConnectionFieldTrial();
71
72 // A/B test for determining a value for unused socket timeout.
73 void SocketTimeoutFieldTrial();
74
[email protected]78a258a2010-08-02 16:34:2675 // A/B test for the maximum number of connections per proxy server.
76 void ProxyConnectionsFieldTrial();
77
[email protected]f8abf722010-07-07 19:46:2478 // A/B test for spdy when --use-spdy not set.
79 void SpdyFieldTrial();
80
[email protected]6930c522011-07-28 22:15:1981 // A/B test for warmest socket vs. most recently used socket.
82 void WarmConnectionFieldTrial();
83
[email protected]06d94042010-08-25 01:45:2284 // A/B test for automatically establishing a backup TCP connection when a
85 // specified timeout value is reached.
86 void ConnectBackupJobsFieldTrial();
87
[email protected]67372ecf2011-09-10 01:30:4688 // Field trial to see what disabling DNS pre-resolution does to
89 // latency of page loads.
90 void PredictorFieldTrial();
91
[email protected]51a7a9d2011-09-27 17:21:4192 // Field trial to see what effect installing defaults in the NTP apps pane
93 // has on retention and general apps/webstore usage.
94 void DefaultAppsFieldTrial();
95
[email protected]069cd9952011-10-01 16:34:4596 // Methods for |SetupMetricsAndFieldTrials()| --------------------------------
97
98 static MetricsService* InitializeMetrics(
[email protected]edafd4c2011-05-10 17:18:5399 const CommandLine& parsed_command_line,
100 const PrefService* local_state);
101
102 // Add an invocation of your field trial init function to this method.
[email protected]12c84e22011-07-11 09:35:45103 void SetupFieldTrials(bool metrics_recording_enabled,
104 bool proxy_policy_is_set);
[email protected]edafd4c2011-05-10 17:18:53105
[email protected]b48c9182011-10-26 18:03:30106 // Methods for Main Message Loop -------------------------------------------
107
108 int PreMainMessageLoopRunImpl();
109
[email protected]f8abf722010-07-07 19:46:24110 // Members initialized on construction ---------------------------------------
111
[email protected]b48c9182011-10-26 18:03:30112 const MainFunctionParams& parameters_;
113 const CommandLine& parsed_command_line_;
114 int result_code_;
115
[email protected]f967b722011-09-07 00:58:04116 // Create ShutdownWatcherHelper object for watching jank during shutdown.
117 // Please keep |shutdown_watcher| as the first object constructed, and hence
118 // it is destroyed last.
119 scoped_ptr<ShutdownWatcherHelper> shutdown_watcher_;
[email protected]f8abf722010-07-07 19:46:24120
121#if defined(TRACK_ALL_TASK_OBJECTS)
122 // Creating this object starts tracking the creation and deletion of Task
123 // instance. This MUST be done before main_message_loop, so that it is
124 // destroyed after the main_message_loop.
125 tracked_objects::AutoTracking tracking_objects_;
126#endif
127
[email protected]edafd4c2011-05-10 17:18:53128 // Statistical testing infrastructure for the entire browser. NULL until
129 // SetupMetricsAndFieldTrials is called.
130 scoped_ptr<base::FieldTrialList> field_trial_list_;
[email protected]f8abf722010-07-07 19:46:24131
[email protected]0f247aea82011-09-03 03:05:51132 // Members initialized after / released before main_message_loop_ ------------
133
[email protected]c1702d712011-09-08 19:41:43134 scoped_ptr<BrowserProcessImpl> browser_process_;
[email protected]0f247aea82011-09-03 03:05:51135 scoped_refptr<HistogramSynchronizer> histogram_synchronizer_;
[email protected]c1702d712011-09-08 19:41:43136 scoped_ptr<ProcessSingleton> process_singleton_;
137 scoped_ptr<FirstRun::MasterPrefs> master_prefs_;
138 bool record_search_engine_;
139 TranslateManager* translate_manager_;
140 Profile* profile_;
141 bool run_message_loop_;
[email protected]66013922011-09-13 18:53:42142 ProcessSingleton::NotifyResult notify_result_;
[email protected]0f247aea82011-09-03 03:05:51143
[email protected]edafd4c2011-05-10 17:18:53144 // Initialized in SetupMetricsAndFieldTrials.
145 scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer_;
146
[email protected]5e6efa52011-06-27 17:26:41147 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket);
148 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Random);
149 FRIEND_TEST(BrowserMainTest, WarmConnectionFieldTrial_Invalid);
[email protected]f967b722011-09-07 00:58:04150 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts);
[email protected]f8abf722010-07-07 19:46:24151};
152
[email protected]1152b7e2009-09-14 03:26:03153// Records the conditions that can prevent Breakpad from generating and
154// sending crash reports. The presence of a Breakpad handler (after
155// attempting to initialize crash reporting) and the presence of a debugger
156// are registered with the UMA metrics service.
157void RecordBreakpadStatusUMA(MetricsService* metrics);
158
[email protected]34f73fb2010-03-24 20:50:34159// Displays a warning message if some minimum level of OS support is not
160// present on the current platform.
161void WarnAboutMinimumSystemRequirements();
[email protected]1152b7e2009-09-14 03:26:03162
[email protected]45d72762011-04-15 18:58:20163// Records the time from our process' startup to the present time in
164// the UMA histogram |metric_name|.
165void RecordBrowserStartupTime();
166
[email protected]28f576f2011-08-26 20:46:55167// Records a time value to an UMA histogram in the context of the
168// PreReadExperiment field-trial. This also reports to the appropriate
169// sub-histogram (_PreRead(Enabled|Disabled)).
170void RecordPreReadExperimentTime(const char* name, base::TimeDelta time);
171
[email protected]e6b5bc22011-09-08 22:01:56172#endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_H_