blob: 74078862a59b8a93ec95a42271c10b39b6d8ed4f [file] [log] [blame]
sdefresneade99e672016-01-12 16:47:001// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef IOS_CHROME_BROWSER_IOS_CHROME_MAIN_PARTS_H_
6#define IOS_CHROME_BROWSER_IOS_CHROME_MAIN_PARTS_H_
7
dcheng942f39d72016-04-07 21:11:238#include <memory>
9
sdefresneade99e672016-01-12 16:47:0010#include "base/command_line.h"
11#include "base/macros.h"
sdefresneade99e672016-01-12 16:47:0012#include "base/metrics/field_trial.h"
13#include "ios/web/public/app/web_main_parts.h"
14
15class ApplicationContextImpl;
16class PrefService;
17
18namespace metrics {
19class TrackingSynchronizer;
20}
21
22namespace ios {
23class FieldTrialSynchronizer;
24}
25
26class IOSChromeMainParts : public web::WebMainParts {
27 public:
28 explicit IOSChromeMainParts(const base::CommandLine& parsed_command_line);
29 ~IOSChromeMainParts() override;
30
31 private:
32 // web::WebMainParts implementation.
33 void PreMainMessageLoopStart() override;
34 void PreCreateThreads() override;
35 void PreMainMessageLoopRun() override;
36 void PostMainMessageLoopRun() override;
37 void PostDestroyThreads() override;
38
robliaod38f6b0a2016-10-04 19:45:3239 // Sets up the field trials and related initialization. Call only after
40 // about:flags have been converted to switches.
41 void SetupFieldTrials();
42
43 // Constructs the metrics service and initializes metrics recording.
44 void SetupMetrics();
sdefresneade99e672016-01-12 16:47:0045
46 // Starts recording of metrics. This can only be called after we have a file
47 // thread.
48 void StartMetricsRecording();
49
50 const base::CommandLine& parsed_command_line_;
51
dcheng942f39d72016-04-07 21:11:2352 std::unique_ptr<ApplicationContextImpl> application_context_;
sdefresneade99e672016-01-12 16:47:0053 scoped_refptr<metrics::TrackingSynchronizer> tracking_synchronizer_;
54
55 // Statistical testing infrastructure for the entire browser. NULL until
56 // SetUpMetricsAndFieldTrials is called.
dcheng942f39d72016-04-07 21:11:2357 std::unique_ptr<base::FieldTrialList> field_trial_list_;
sdefresneade99e672016-01-12 16:47:0058
59 PrefService* local_state_;
60
61 // Initialized in SetupMetricsAndFieldTrials.
dcheng942f39d72016-04-07 21:11:2362 std::unique_ptr<ios::FieldTrialSynchronizer> field_trial_synchronizer_;
sdefresneade99e672016-01-12 16:47:0063
64 DISALLOW_COPY_AND_ASSIGN(IOSChromeMainParts);
65};
66
67#endif // IOS_CHROME_BROWSER_IOS_CHROME_MAIN_PARTS_H_