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

Side by Side Diff: components/metrics/data_use_tracker.h

Issue 2770853002: Create Ukm ReportingService implementation. (Closed)
Patch Set: Fix register prefs Created 3 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 unified diff | Download patch
OLDNEW
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 #ifndef COMPONENTS_METRICS_DATA_USE_TRACKER_H_ 5 #ifndef COMPONENTS_METRICS_DATA_USE_TRACKER_H_
6 #define COMPONENTS_METRICS_DATA_USE_TRACKER_H_ 6 #define COMPONENTS_METRICS_DATA_USE_TRACKER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "components/metrics/metrics_log_uploader.h"
15 #include "components/prefs/pref_registry_simple.h" 16 #include "components/prefs/pref_registry_simple.h"
16 #include "components/prefs/pref_service.h" 17 #include "components/prefs/pref_service.h"
17 18
18 namespace metrics { 19 namespace metrics {
19 20
20 typedef base::Callback<void(const std::string&, int, bool)> 21 typedef base::Callback<void(const std::string&, int, bool)>
21 UpdateUsagePrefCallbackType; 22 UpdateUsagePrefCallbackType;
22 23
23 // Records the data use of user traffic and UMA traffic in user prefs. Taking 24 // Records the data use of user traffic and UMA traffic in user prefs. Taking
24 // into account those prefs it can verify whether certain UMA log upload is 25 // into account those prefs it can verify whether certain UMA log upload is
(...skipping 10 matching lines...) Expand all
35 // Registers data use prefs using provided |registry|. 36 // Registers data use prefs using provided |registry|.
36 static void RegisterPrefs(PrefRegistrySimple* registry); 37 static void RegisterPrefs(PrefRegistrySimple* registry);
37 38
38 // Updates data usage tracking prefs with the specified values. 39 // Updates data usage tracking prefs with the specified values.
39 void UpdateMetricsUsagePrefs(const std::string& service_name, 40 void UpdateMetricsUsagePrefs(const std::string& service_name,
40 int message_size, 41 int message_size,
41 bool is_cellular); 42 bool is_cellular);
42 43
43 // Returns whether a log with provided |log_bytes| can be uploaded according 44 // Returns whether a log with provided |log_bytes| can be uploaded according
44 // to data use ratio and UMA quota provided by variations. 45 // to data use ratio and UMA quota provided by variations.
45 bool ShouldUploadLogOnCellular(int log_bytes); 46 bool ShouldUploadLogOnCellular(
47 int log_bytes,
48 MetricsLogUploader::MetricServiceType service_type);
46 49
47 private: 50 private:
48 FRIEND_TEST_ALL_PREFIXES(DataUseTrackerTest, CheckUpdateUsagePref); 51 FRIEND_TEST_ALL_PREFIXES(DataUseTrackerTest, CheckUpdateUsagePref);
49 FRIEND_TEST_ALL_PREFIXES(DataUseTrackerTest, CheckRemoveExpiredEntries); 52 FRIEND_TEST_ALL_PREFIXES(DataUseTrackerTest, CheckRemoveExpiredEntries);
50 FRIEND_TEST_ALL_PREFIXES(DataUseTrackerTest, CheckComputeTotalDataUse); 53 FRIEND_TEST_ALL_PREFIXES(DataUseTrackerTest, CheckComputeTotalDataUse);
51 FRIEND_TEST_ALL_PREFIXES(DataUseTrackerTest, CheckCanUploadUMALog); 54 FRIEND_TEST_ALL_PREFIXES(DataUseTrackerTest, CheckCanUploadUMALog);
52 55
53 // Updates provided |pref_name| for a current date with the given message 56 // Updates provided |pref_name| for a current date with the given message
54 // size. 57 // size.
55 void UpdateUsagePref(const std::string& pref_name, int message_size); 58 void UpdateUsagePref(const std::string& pref_name, int message_size);
(...skipping 23 matching lines...) Expand all
79 82
80 PrefService* local_state_; 83 PrefService* local_state_;
81 84
82 base::ThreadChecker thread_checker_; 85 base::ThreadChecker thread_checker_;
83 86
84 DISALLOW_COPY_AND_ASSIGN(DataUseTracker); 87 DISALLOW_COPY_AND_ASSIGN(DataUseTracker);
85 }; 88 };
86 89
87 } // namespace metrics 90 } // namespace metrics
88 #endif // COMPONENTS_METRICS_DATA_USE_TRACKER_H_ 91 #endif // COMPONENTS_METRICS_DATA_USE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698