Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: ios/chrome/browser/metrics/ios_chrome_metrics_services_manager_client.cc

Issue 1421733002: Introduce IOSChromeMetricsServicesManagerClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git add client Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 #include "ios/chrome/browser/metrics/ios_chrome_metrics_services_manager_client. h"
6
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/prefs/pref_service.h"
10 #include "components/metrics/metrics_state_manager.h"
11 #include "components/rappor/rappor_service.h"
12 #include "components/variations/service/variations_service.h"
13 #include "ios/chrome/browser/application_context.h"
14 #include "ios/chrome/browser/chrome_switches.h"
15 #include "ios/chrome/browser/metrics/ios_chrome_metrics_service_accessor.h"
16 #include "ios/chrome/browser/metrics/ios_chrome_metrics_service_client.h"
17 #include "ios/chrome/browser/ui/browser_otr_state.h"
18 #include "ios/chrome/browser/variations/ios_chrome_variations_service_client.h"
19 #include "ios/chrome/browser/variations/ios_ui_string_overrider_factory.h"
20 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
21
22 namespace {
23
24 void PostStoreMetricsClientInfo(const metrics::ClientInfo& client_info) {}
25
26 scoped_ptr<metrics::ClientInfo> LoadMetricsClientInfo() {
27 return scoped_ptr<metrics::ClientInfo>();
28 }
29
30 } // namespace
31
32 IOSChromeMetricsServicesManagerClient::IOSChromeMetricsServicesManagerClient(
33 PrefService* local_state)
34 : local_state_(local_state) {
35 DCHECK(local_state);
36 }
37
38 IOSChromeMetricsServicesManagerClient::
39 ~IOSChromeMetricsServicesManagerClient() {
40 ios::GetChromeBrowserProvider()->OnMetricsServicesManagerClientDestroyed();
41 }
42
43 scoped_ptr<rappor::RapporService>
44 IOSChromeMetricsServicesManagerClient::CreateRapporService() {
45 DCHECK(thread_checker_.CalledOnValidThread());
46 return make_scoped_ptr(new rappor::RapporService(
47 local_state_, base::Bind(&::IsOffTheRecordSessionActive)));
48 }
49
50 scoped_ptr<variations::VariationsService>
51 IOSChromeMetricsServicesManagerClient::CreateVariationsService() {
52 DCHECK(thread_checker_.CalledOnValidThread());
53
54 // NOTE: On iOS, disabling background networking is not supported, so pass in
55 // a dummy value for the name of the switch that disables background
56 // networking.
57 return variations::VariationsService::Create(
58 make_scoped_ptr(new IOSChromeVariationsServiceClient), local_state_,
59 GetMetricsStateManager(), "dummyDisableBackgroundSwitch",
60 ::CreateUIStringOverrider());
61 }
62
63 scoped_ptr<metrics::MetricsServiceClient>
64 IOSChromeMetricsServicesManagerClient::CreateMetricsServiceClient() {
65 DCHECK(thread_checker_.CalledOnValidThread());
66 return IOSChromeMetricsServiceClient::Create(GetMetricsStateManager(),
67 local_state_);
68 }
69
70 net::URLRequestContextGetter*
71 IOSChromeMetricsServicesManagerClient::GetURLRequestContext() {
72 return GetApplicationContext()->GetSystemURLRequestContext();
73 }
74
75 bool IOSChromeMetricsServicesManagerClient::IsSafeBrowsingEnabled(
76 const base::Closure& on_update_callback) {
77 return ios::GetChromeBrowserProvider()->IsSafeBrowsingEnabled(
78 on_update_callback);
79 }
80
81 bool IOSChromeMetricsServicesManagerClient::IsMetricsReportingEnabled() {
82 return IOSChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled();
83 }
84
85 bool IOSChromeMetricsServicesManagerClient::OnlyDoMetricsRecording() {
86 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
87 return cmdline->HasSwitch(switches::kIOSMetricsRecordingOnly);
88 }
89
90 metrics::MetricsStateManager*
91 IOSChromeMetricsServicesManagerClient::GetMetricsStateManager() {
92 DCHECK(thread_checker_.CalledOnValidThread());
93 if (!metrics_state_manager_) {
94 metrics_state_manager_ = metrics::MetricsStateManager::Create(
95 local_state_, base::Bind(&IOSChromeMetricsServiceAccessor::
96 IsMetricsAndCrashReportingEnabled),
97 base::Bind(&PostStoreMetricsClientInfo),
98 base::Bind(&LoadMetricsClientInfo));
99 }
100 return metrics_state_manager_.get();
101 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/metrics/ios_chrome_metrics_services_manager_client.h ('k') | ios/chrome/ios_chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698