| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "components/metrics/data_use_tracker.h" | 5 #include "components/metrics/data_use_tracker.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 void DataUseTracker::UpdateMetricsUsagePrefs(const std::string& service_name, | 48 void DataUseTracker::UpdateMetricsUsagePrefs(const std::string& service_name, |
| 49 int message_size, | 49 int message_size, |
| 50 bool is_cellular) { | 50 bool is_cellular) { |
| 51 DCHECK(thread_checker_.CalledOnValidThread()); | 51 DCHECK(thread_checker_.CalledOnValidThread()); |
| 52 | 52 |
| 53 if (!is_cellular) | 53 if (!is_cellular) |
| 54 return; | 54 return; |
| 55 | 55 |
| 56 UpdateUsagePref(prefs::kUserCellDataUse, message_size); | 56 UpdateUsagePref(prefs::kUserCellDataUse, message_size); |
| 57 if (service_name == "UMA") | 57 // TODO(holte): Consider adding seperate tracking for UKM. |
| 58 if (service_name == "UMA" || service_name == "UKM") |
| 58 UpdateUsagePref(prefs::kUmaCellDataUse, message_size); | 59 UpdateUsagePref(prefs::kUmaCellDataUse, message_size); |
| 59 } | 60 } |
| 60 | 61 |
| 61 bool DataUseTracker::ShouldUploadLogOnCellular(int log_bytes) { | 62 bool DataUseTracker::ShouldUploadLogOnCellular(int log_bytes) { |
| 62 DCHECK(thread_checker_.CalledOnValidThread()); | 63 DCHECK(thread_checker_.CalledOnValidThread()); |
| 63 | 64 |
| 64 RemoveExpiredEntries(); | 65 RemoveExpiredEntries(); |
| 65 | 66 |
| 66 int uma_weekly_quota_bytes; | 67 int uma_weekly_quota_bytes; |
| 67 if (!GetUmaWeeklyQuota(&uma_weekly_quota_bytes)) | 68 if (!GetUmaWeeklyQuota(&uma_weekly_quota_bytes)) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 std::string DataUseTracker::GetCurrentMeasurementDateAsString() const { | 176 std::string DataUseTracker::GetCurrentMeasurementDateAsString() const { |
| 176 DCHECK(thread_checker_.CalledOnValidThread()); | 177 DCHECK(thread_checker_.CalledOnValidThread()); |
| 177 | 178 |
| 178 base::Time::Exploded today_exploded; | 179 base::Time::Exploded today_exploded; |
| 179 GetCurrentMeasurementDate().LocalExplode(&today_exploded); | 180 GetCurrentMeasurementDate().LocalExplode(&today_exploded); |
| 180 return base::StringPrintf("%04d-%02d-%02d", today_exploded.year, | 181 return base::StringPrintf("%04d-%02d-%02d", today_exploded.year, |
| 181 today_exploded.month, today_exploded.day_of_month); | 182 today_exploded.month, today_exploded.day_of_month); |
| 182 } | 183 } |
| 183 | 184 |
| 184 } // namespace metrics | 185 } // namespace metrics |
| OLD | NEW |