blob: ddfcd3a06a436c9b1b54334fb095a0806438c9b7 [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]f8abf722010-07-07 19:46:2436 protected:
[email protected]f967b722011-09-07 00:58:0437 explicit ChromeBrowserMainParts(const MainFunctionParams& parameters);
[email protected]f8abf722010-07-07 19:46:2438
[email protected]f967b722011-09-07 00:58:0439 virtual void PostMainMessageLoopStart() OVERRIDE;
[email protected]c1702d712011-09-08 19:41:4340 virtual void PreMainMessageLoopRun() OVERRIDE;
41 int PreMainMessageLoopRunInternal();
42 virtual void MainMessageLoopRun() OVERRIDE;
43 virtual void PostMainMessageLoopRun() OVERRIDE;
[email protected]f967b722011-09-07 00:58:0444 virtual void ToolkitInitialized() OVERRIDE;
[email protected]f8abf722010-07-07 19:46:2445
[email protected]1fec64352010-07-27 13:55:2146 private:
[email protected]f8abf722010-07-07 19:46:2447 // Methods for |EarlyInitialization()| ---------------------------------------
48
49 // A/B test for the maximum number of persistent connections per host.
50 void ConnectionFieldTrial();
51
52 // A/B test for determining a value for unused socket timeout.
53 void SocketTimeoutFieldTrial();
54
[email protected]78a258a2010-08-02 16:34:2655 // A/B test for the maximum number of connections per proxy server.
56 void ProxyConnectionsFieldTrial();
57
[email protected]f8abf722010-07-07 19:46:2458 // A/B test for spdy when --use-spdy not set.
59 void SpdyFieldTrial();
60
[email protected]6930c522011-07-28 22:15:1961 // A/B test for warmest socket vs. most recently used socket.
62 void WarmConnectionFieldTrial();
63
[email protected]06d94042010-08-25 01:45:2264 // A/B test for automatically establishing a backup TCP connection when a
65 // specified timeout value is reached.
66 void ConnectBackupJobsFieldTrial();
67
[email protected]67372ecf2011-09-10 01:30:4668 // Field trial to see what disabling DNS pre-resolution does to
69 // latency of page loads.
70 void PredictorFieldTrial();
71
[email protected]51a7a9d2011-09-27 17:21:4172 // Field trial to see what effect installing defaults in the NTP apps pane
73 // has on retention and general apps/webstore usage.
74 void DefaultAppsFieldTrial();
75
[email protected]b994cb852011-10-01 07:00:0876 // Constructs metrics service and field trials. Call only after labs have been
77 // converted to switches.
78 MetricsService* CreateMetrics(
[email protected]edafd4c2011-05-10 17:18:5379 const CommandLine& parsed_command_line,
80 const PrefService* local_state);
81
[email protected]b994cb852011-10-01 07:00:0882 // Initializes metrics service and sets up the field trial experiments.
83 void SetupMetricsAndFieldTrials(MetricsService* metrics,
84 const CommandLine& parsed_command_line,
85 PrefService* local_state);
86
[email protected]edafd4c2011-05-10 17:18:5387 // Add an invocation of your field trial init function to this method.
[email protected]12c84e22011-07-11 09:35:4588 void SetupFieldTrials(bool metrics_recording_enabled,
89 bool proxy_policy_is_set);
[email protected]edafd4c2011-05-10 17:18:5390
[email protected]f8abf722010-07-07 19:46:2491 // Members initialized on construction ---------------------------------------
92
[email protected]f967b722011-09-07 00:58:0493 // Create ShutdownWatcherHelper object for watching jank during shutdown.
94 // Please keep |shutdown_watcher| as the first object constructed, and hence
95 // it is destroyed last.
96 scoped_ptr<ShutdownWatcherHelper> shutdown_watcher_;
[email protected]f8abf722010-07-07 19:46:2497
98#if defined(TRACK_ALL_TASK_OBJECTS)
99 // Creating this object starts tracking the creation and deletion of Task
100 // instance. This MUST be done before main_message_loop, so that it is
101 // destroyed after the main_message_loop.
102 tracked_objects::AutoTracking tracking_objects_;
103#endif
104
[email protected]edafd4c2011-05-10 17:18:53105 // Statistical testing infrastructure for the entire browser. NULL until
106 // SetupMetricsAndFieldTrials is called.
107 scoped_ptr<base::FieldTrialList> field_trial_list_;
[email protected]f8abf722010-07-07 19:46:24108
[email protected]0f247aea82011-09-03 03:05:51109 // Members initialized after / released before main_message_loop_ ------------
110
[email protected]c1702d712011-09-08 19:41:43111 scoped_ptr<BrowserProcessImpl> browser_process_;
[email protected]0f247aea82011-09-03 03:05:51112 scoped_refptr<HistogramSynchronizer> histogram_synchronizer_;
[email protected]c1702d712011-09-08 19:41:43113 scoped_ptr<ProcessSingleton> process_singleton_;
114 scoped_ptr<FirstRun::MasterPrefs> master_prefs_;
115 bool record_search_engine_;
116 TranslateManager* translate_manager_;
117 Profile* profile_;
118 bool run_message_loop_;
[email protected]66013922011-09-13 18:53:42119 ProcessSingleton::NotifyResult notify_result_;
[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_