| 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 #import <UIKit/UIKit.h> | 5 #import <UIKit/UIKit.h> |
| 6 | 6 |
| 7 #import "ios/chrome/today_extension/today_metrics_logger.h" | 7 #import "ios/chrome/today_extension/today_metrics_logger.h" |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/cpu.h" | 10 #include "base/cpu.h" |
| 11 #include "base/mac/bind_objc_block.h" | 11 #include "base/mac/bind_objc_block.h" |
| 12 #import "base/mac/scoped_nsobject.h" | 12 #import "base/mac/scoped_nsobject.h" |
| 13 #include "base/metrics/histogram_base.h" | 13 #include "base/metrics/histogram_base.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/metrics/statistics_recorder.h" | 15 #include "base/metrics/statistics_recorder.h" |
| 16 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/sys_info.h" | 18 #include "base/sys_info.h" |
| 19 #include "components/metrics/metrics_log.h" | 19 #include "components/metrics/metrics_log.h" |
| 20 #include "components/metrics/metrics_log_uploader.h" | 20 #include "components/metrics/metrics_log_uploader.h" |
| 21 #include "components/metrics/metrics_pref_names.h" | 21 #include "components/metrics/metrics_pref_names.h" |
| 22 #include "components/metrics/metrics_provider.h" |
| 22 #include "components/metrics/metrics_service_client.h" | 23 #include "components/metrics/metrics_service_client.h" |
| 23 #include "components/metrics/net/version_utils.h" | 24 #include "components/metrics/net/version_utils.h" |
| 24 #include "components/prefs/json_pref_store.h" | 25 #include "components/prefs/json_pref_store.h" |
| 25 #include "components/prefs/pref_registry_simple.h" | 26 #include "components/prefs/pref_registry_simple.h" |
| 26 #include "components/prefs/pref_service.h" | 27 #include "components/prefs/pref_service.h" |
| 27 #include "components/prefs/pref_service_factory.h" | 28 #include "components/prefs/pref_service_factory.h" |
| 28 #include "components/prefs/value_map_pref_store.h" | 29 #include "components/prefs/value_map_pref_store.h" |
| 29 #include "components/variations/active_field_trials.h" | 30 #include "components/variations/active_field_trials.h" |
| 30 #include "components/version_info/version_info.h" | 31 #include "components/version_info/version_info.h" |
| 31 #import "ios/chrome/common/app_group/app_group_constants.h" | 32 #import "ios/chrome/common/app_group/app_group_constants.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 [[NSUserDefaults standardUserDefaults] | 240 [[NSUserDefaults standardUserDefaults] |
| 240 setInteger:session_id + 1 | 241 setInteger:session_id + 1 |
| 241 forKey:kTodayExtensionMetricsSessionID]; | 242 forKey:kTodayExtensionMetricsSessionID]; |
| 242 session_id = app_group::AppGroupSessionID( | 243 session_id = app_group::AppGroupSessionID( |
| 243 session_id, app_group::APP_GROUP_TODAY_EXTENSION); | 244 session_id, app_group::APP_GROUP_TODAY_EXTENSION); |
| 244 log_.reset(new TodayMetricsLog(base::SysNSStringToUTF8(client_id), session_id, | 245 log_.reset(new TodayMetricsLog(base::SysNSStringToUTF8(client_id), session_id, |
| 245 metrics::MetricsLog::ONGOING_LOG, | 246 metrics::MetricsLog::ONGOING_LOG, |
| 246 metrics_service_client_.get(), | 247 metrics_service_client_.get(), |
| 247 pref_service_.get())); | 248 pref_service_.get())); |
| 248 | 249 |
| 249 log_->RecordEnvironment(std::vector<metrics::MetricsProvider*>(), | 250 log_->RecordEnvironment( |
| 250 std::vector<variations::ActiveGroupId>(), | 251 std::vector<std::unique_ptr<metrics::MetricsProvider>>(), |
| 251 [install_date longLongValue], | 252 std::vector<variations::ActiveGroupId>(), [install_date longLongValue], |
| 252 [enabled_date longLongValue]); | 253 [enabled_date longLongValue]); |
| 253 | 254 |
| 254 return true; | 255 return true; |
| 255 } | 256 } |
| 256 | 257 |
| 257 TodayMetricsLogger::TodayMetricsLogger() | 258 TodayMetricsLogger::TodayMetricsLogger() |
| 258 : pref_registry_(new PrefRegistrySimple()), | 259 : pref_registry_(new PrefRegistrySimple()), |
| 259 thread_pool_( | 260 thread_pool_( |
| 260 new base::SequencedWorkerPool(2, | 261 new base::SequencedWorkerPool(2, |
| 261 "LoggerPool", | 262 "LoggerPool", |
| 262 base::TaskPriority::BACKGROUND)), | 263 base::TaskPriority::BACKGROUND)), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 293 void TodayMetricsLogger::UniqueInconsistencyDetected( | 294 void TodayMetricsLogger::UniqueInconsistencyDetected( |
| 294 base::HistogramBase::Inconsistency problem) { | 295 base::HistogramBase::Inconsistency problem) { |
| 295 UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique", problem, | 296 UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique", problem, |
| 296 base::HistogramBase::NEVER_EXCEEDED_VALUE); | 297 base::HistogramBase::NEVER_EXCEEDED_VALUE); |
| 297 } | 298 } |
| 298 | 299 |
| 299 void TodayMetricsLogger::InconsistencyDetectedInLoggedCount(int amount) { | 300 void TodayMetricsLogger::InconsistencyDetectedInLoggedCount(int amount) { |
| 300 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotBrowser", | 301 UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotBrowser", |
| 301 std::abs(amount)); | 302 std::abs(amount)); |
| 302 } | 303 } |
| OLD | NEW |