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

Unified Diff: components/metrics/metrics_data_use_measurements.h

Issue 1818613002: Implement UMA log throttling for cellular connections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: components/metrics/metrics_data_use_measurements.h
diff --git a/components/metrics/metrics_data_use_measurements.h b/components/metrics/metrics_data_use_measurements.h
new file mode 100644
index 0000000000000000000000000000000000000000..df75ecb3c621ae09ddf3137be0197d80c7b5b0a4
--- /dev/null
+++ b/components/metrics/metrics_data_use_measurements.h
@@ -0,0 +1,46 @@
+// Copyright 2014 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 COMPONENTS_METRICS_METRICS_DATA_USE_MEASUREMENT_H_
+#define COMPONENTS_METRICS_METRICS_DATA_USE_MEASUREMENT_H_
+
+#include "base/gtest_prod_util.h"
+#include "base/memory/scoped_ptr.h"
+#include "components/prefs/pref_service.h"
+
+namespace metrics {
+
+class MetricsDataUseMeasurements{
+public:
+ static void Initialize(PrefService* local_state);
+ static MetricsDataUseMeasurements* GetInstance();
+
+ void UpdateMetricsUsagePrefs(const std::string& service_name, int message_size);
Alexei Svitkine (slow) 2016/03/18 22:23:30 Suggest running "git cl format" on your CL.
gayane -on leave until 09-2017 2016/03/29 16:06:20 hmm, didn't notice it didn't apply to new files
+ bool CanUploadUMALog(int log_bytes);
+
+ ~MetricsDataUseMeasurements();
+private:
+ FRIEND_TEST_ALL_PREFIXES(MetricsDataUseMeasurementsTest, CheckUpdateUsagePref);
+ FRIEND_TEST_ALL_PREFIXES(MetricsDataUseMeasurementsTest, CheckRemoveExpiredEntries);
+ FRIEND_TEST_ALL_PREFIXES(MetricsDataUseMeasurementsTest, CheckTotalDataUse);
+ FRIEND_TEST_ALL_PREFIXES(MetricsDataUseMeasurementsTest, CheckCanUploadUMALog);
+ MetricsDataUseMeasurements(PrefService* local_state);
+
+ void UpdateMetricsUsagePrefsOnUIThread(const std::string& service_name, int message_size);
+ void SetMeasurementDateForTesting(std::string date);
+ void RemoveExpiredEntries();
+ void UpdateUsagePref(const std::string& pref_name, int message_size);
+ std::string GetCurrentMeasurementDate();
+ int GetUmaQouta();
+ double GetUmaRatio();
+ int TotalDataUse(std::string pref_name);
+ void RemoveExpiredEntriesForPref(std::string pref_name);
+
+ PrefService* local_state_;
+ std::string date_for_testing_;
+ base::WeakPtrFactory<MetricsDataUseMeasurements> self_ptr_factory_;
Alexei Svitkine (slow) 2016/03/18 22:23:30 Nit: weak_ptr_factory_
gayane -on leave until 09-2017 2016/03/29 16:06:20 Done.
+};
+
+}// namespace metrics
+#endif // COMPONENTS_METRICS_METRICS_DATA_USE_MEASUREMENT_H_

Powered by Google App Engine
This is Rietveld 408576698