summaryrefslogtreecommitdiffstats
path: root/ios/chrome/browser/ios_chrome_main_parts.h
blob: 4ddc0941d16eede3b17ffbf22b3a672b73e52b73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_IOS_CHROME_MAIN_PARTS_H_
#define IOS_CHROME_BROWSER_IOS_CHROME_MAIN_PARTS_H_

#include "base/command_line.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/field_trial.h"
#include "ios/web/public/app/web_main_parts.h"

class ApplicationContextImpl;
class PrefService;

namespace metrics {
class TrackingSynchronizer;
}

namespace ios {
class FieldTrialSynchronizer;
}

class IOSChromeMainParts : public web::WebMainParts {
 public:
  explicit IOSChromeMainParts(const base::CommandLine& parsed_command_line);
  ~IOSChromeMainParts() override;

 private:
  // web::WebMainParts implementation.
  void PreMainMessageLoopStart() override;
  void PreCreateThreads() override;
  void PreMainMessageLoopRun() override;
  void PostMainMessageLoopRun() override;
  void PostDestroyThreads() override;

  // Constructs metrics service and does related initialization, including
  // creation of field trials. Call only after labs have been converted to
  // switches.
  void SetUpMetricsAndFieldTrials();

  // Starts recording of metrics. This can only be called after we have a file
  // thread.
  void StartMetricsRecording();

  const base::CommandLine& parsed_command_line_;

  scoped_ptr<ApplicationContextImpl> application_context_;
  scoped_refptr<metrics::TrackingSynchronizer> tracking_synchronizer_;

  // Statistical testing infrastructure for the entire browser. NULL until
  // SetUpMetricsAndFieldTrials is called.
  scoped_ptr<base::FieldTrialList> field_trial_list_;

  PrefService* local_state_;

  // Initialized in SetupMetricsAndFieldTrials.
  scoped_ptr<ios::FieldTrialSynchronizer> field_trial_synchronizer_;

  DISALLOW_COPY_AND_ASSIGN(IOSChromeMainParts);
};

#endif  // IOS_CHROME_BROWSER_IOS_CHROME_MAIN_PARTS_H_