| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ios/chrome/browser/metrics/ios_chrome_metrics_services_manager_client.
h" | 5 #include "ios/chrome/browser/metrics/ios_chrome_metrics_services_manager_client.
h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "components/metrics/enabled_state_provider.h" | 10 #include "components/metrics/enabled_state_provider.h" |
| 11 #include "components/metrics/metrics_state_manager.h" | 11 #include "components/metrics/metrics_state_manager.h" |
| 12 #include "components/prefs/pref_service.h" | 12 #include "components/prefs/pref_service.h" |
| 13 #include "components/rappor/rappor_service_impl.h" | 13 #include "components/rappor/rappor_service_impl.h" |
| 14 #include "components/variations/service/variations_service.h" | 14 #include "components/variations/service/variations_service.h" |
| 15 #include "ios/chrome/browser/application_context.h" | 15 #include "ios/chrome/browser/application_context.h" |
| 16 #include "ios/chrome/browser/chrome_switches.h" | 16 #include "ios/chrome/browser/chrome_switches.h" |
| 17 #include "ios/chrome/browser/metrics/ios_chrome_metrics_service_accessor.h" | 17 #include "ios/chrome/browser/metrics/ios_chrome_metrics_service_accessor.h" |
| 18 #include "ios/chrome/browser/metrics/ios_chrome_metrics_service_client.h" | 18 #include "ios/chrome/browser/metrics/ios_chrome_metrics_service_client.h" |
| 19 #include "ios/chrome/browser/ui/browser_otr_state.h" | 19 #include "ios/chrome/browser/ui/browser_list_ios.h" |
| 20 #include "ios/chrome/browser/variations/ios_chrome_variations_service_client.h" | 20 #include "ios/chrome/browser/variations/ios_chrome_variations_service_client.h" |
| 21 #include "ios/chrome/browser/variations/ios_ui_string_overrider_factory.h" | 21 #include "ios/chrome/browser/variations/ios_ui_string_overrider_factory.h" |
| 22 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 22 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 23 | 23 |
| 24 #if !defined(__has_feature) || !__has_feature(objc_arc) | 24 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 25 #error "This file requires ARC support." | 25 #error "This file requires ARC support." |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 43 | 43 |
| 44 bool IsConsentGiven() override { | 44 bool IsConsentGiven() override { |
| 45 return IOSChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); | 45 return IOSChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(IOSChromeEnabledStateProvider); | 48 DISALLOW_COPY_AND_ASSIGN(IOSChromeEnabledStateProvider); |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 IOSChromeMetricsServicesManagerClient::IOSChromeMetricsServicesManagerClient( | 51 IOSChromeMetricsServicesManagerClient::IOSChromeMetricsServicesManagerClient( |
| 52 PrefService* local_state) | 52 PrefService* local_state) |
| 53 : enabled_state_provider_(new IOSChromeEnabledStateProvider()), | 53 : enabled_state_provider_( |
| 54 base::MakeUnique<IOSChromeEnabledStateProvider>()), |
| 54 local_state_(local_state) { | 55 local_state_(local_state) { |
| 55 DCHECK(local_state); | 56 DCHECK(local_state); |
| 56 } | 57 } |
| 57 | 58 |
| 58 IOSChromeMetricsServicesManagerClient:: | 59 IOSChromeMetricsServicesManagerClient:: |
| 59 ~IOSChromeMetricsServicesManagerClient() = default; | 60 ~IOSChromeMetricsServicesManagerClient() = default; |
| 60 | 61 |
| 61 std::unique_ptr<rappor::RapporServiceImpl> | 62 std::unique_ptr<rappor::RapporServiceImpl> |
| 62 IOSChromeMetricsServicesManagerClient::CreateRapporServiceImpl() { | 63 IOSChromeMetricsServicesManagerClient::CreateRapporServiceImpl() { |
| 63 DCHECK(thread_checker_.CalledOnValidThread()); | 64 DCHECK(thread_checker_.CalledOnValidThread()); |
| 64 return base::MakeUnique<rappor::RapporServiceImpl>( | 65 return base::MakeUnique<rappor::RapporServiceImpl>( |
| 65 local_state_, base::Bind(&::IsOffTheRecordSessionActive)); | 66 local_state_, base::Bind(&BrowserListIOS::IsOffTheRecordSessionActive)); |
| 66 } | 67 } |
| 67 | 68 |
| 68 std::unique_ptr<variations::VariationsService> | 69 std::unique_ptr<variations::VariationsService> |
| 69 IOSChromeMetricsServicesManagerClient::CreateVariationsService() { | 70 IOSChromeMetricsServicesManagerClient::CreateVariationsService() { |
| 70 DCHECK(thread_checker_.CalledOnValidThread()); | 71 DCHECK(thread_checker_.CalledOnValidThread()); |
| 71 | 72 |
| 72 // NOTE: On iOS, disabling background networking is not supported, so pass in | 73 // NOTE: On iOS, disabling background networking is not supported, so pass in |
| 73 // a dummy value for the name of the switch that disables background | 74 // a dummy value for the name of the switch that disables background |
| 74 // networking. | 75 // networking. |
| 75 return variations::VariationsService::Create( | 76 return variations::VariationsService::Create( |
| 76 base::WrapUnique(new IOSChromeVariationsServiceClient), local_state_, | 77 base::MakeUnique<IOSChromeVariationsServiceClient>(), local_state_, |
| 77 GetMetricsStateManager(), "dummy-disable-background-switch", | 78 GetMetricsStateManager(), "dummy-disable-background-switch", |
| 78 ::CreateUIStringOverrider()); | 79 ::CreateUIStringOverrider()); |
| 79 } | 80 } |
| 80 | 81 |
| 81 std::unique_ptr<metrics::MetricsServiceClient> | 82 std::unique_ptr<metrics::MetricsServiceClient> |
| 82 IOSChromeMetricsServicesManagerClient::CreateMetricsServiceClient() { | 83 IOSChromeMetricsServicesManagerClient::CreateMetricsServiceClient() { |
| 83 DCHECK(thread_checker_.CalledOnValidThread()); | 84 DCHECK(thread_checker_.CalledOnValidThread()); |
| 84 return IOSChromeMetricsServiceClient::Create(GetMetricsStateManager()); | 85 return IOSChromeMetricsServiceClient::Create(GetMetricsStateManager()); |
| 85 } | 86 } |
| 86 | 87 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 113 IOSChromeMetricsServicesManagerClient::GetMetricsStateManager() { | 114 IOSChromeMetricsServicesManagerClient::GetMetricsStateManager() { |
| 114 DCHECK(thread_checker_.CalledOnValidThread()); | 115 DCHECK(thread_checker_.CalledOnValidThread()); |
| 115 if (!metrics_state_manager_) { | 116 if (!metrics_state_manager_) { |
| 116 metrics_state_manager_ = metrics::MetricsStateManager::Create( | 117 metrics_state_manager_ = metrics::MetricsStateManager::Create( |
| 117 local_state_, enabled_state_provider_.get(), | 118 local_state_, enabled_state_provider_.get(), |
| 118 base::Bind(&PostStoreMetricsClientInfo), | 119 base::Bind(&PostStoreMetricsClientInfo), |
| 119 base::Bind(&LoadMetricsClientInfo)); | 120 base::Bind(&LoadMetricsClientInfo)); |
| 120 } | 121 } |
| 121 return metrics_state_manager_.get(); | 122 return metrics_state_manager_.get(); |
| 122 } | 123 } |
| OLD | NEW |