sdefresne | ade99e67 | 2016-01-12 16:47:00 | [diff] [blame] | 1 | // 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 | |
dcheng | 942f39d7 | 2016-04-07 21:11:23 | [diff] [blame] | 8 | #include <memory> |
| 9 | |
sdefresne | ade99e67 | 2016-01-12 16:47:00 | [diff] [blame] | 10 | #include "base/command_line.h" |
| 11 | #include "base/macros.h" |
sdefresne | ade99e67 | 2016-01-12 16:47:00 | [diff] [blame] | 12 | #include "base/metrics/field_trial.h" |
| 13 | #include "ios/web/public/app/web_main_parts.h" |
| 14 | |
| 15 | class ApplicationContextImpl; |
| 16 | class PrefService; |
| 17 | |
| 18 | namespace metrics { |
| 19 | class TrackingSynchronizer; |
| 20 | } |
| 21 | |
| 22 | namespace ios { |
| 23 | class FieldTrialSynchronizer; |
| 24 | } |
| 25 | |
| 26 | class 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 | |
robliao | d38f6b0a | 2016-10-04 19:45:32 | [diff] [blame^] | 39 | // 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(); |
sdefresne | ade99e67 | 2016-01-12 16:47:00 | [diff] [blame] | 45 | |
| 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 | |
dcheng | 942f39d7 | 2016-04-07 21:11:23 | [diff] [blame] | 52 | std::unique_ptr<ApplicationContextImpl> application_context_; |
sdefresne | ade99e67 | 2016-01-12 16:47:00 | [diff] [blame] | 53 | scoped_refptr<metrics::TrackingSynchronizer> tracking_synchronizer_; |
| 54 | |
| 55 | // Statistical testing infrastructure for the entire browser. NULL until |
| 56 | // SetUpMetricsAndFieldTrials is called. |
dcheng | 942f39d7 | 2016-04-07 21:11:23 | [diff] [blame] | 57 | std::unique_ptr<base::FieldTrialList> field_trial_list_; |
sdefresne | ade99e67 | 2016-01-12 16:47:00 | [diff] [blame] | 58 | |
| 59 | PrefService* local_state_; |
| 60 | |
| 61 | // Initialized in SetupMetricsAndFieldTrials. |
dcheng | 942f39d7 | 2016-04-07 21:11:23 | [diff] [blame] | 62 | std::unique_ptr<ios::FieldTrialSynchronizer> field_trial_synchronizer_; |
sdefresne | ade99e67 | 2016-01-12 16:47:00 | [diff] [blame] | 63 | |
| 64 | DISALLOW_COPY_AND_ASSIGN(IOSChromeMainParts); |
| 65 | }; |
| 66 | |
| 67 | #endif // IOS_CHROME_BROWSER_IOS_CHROME_MAIN_PARTS_H_ |