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 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_REQUEST_THROTTLER_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_REQUEST_THROTTLER_H_ |
6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REQUEST_THROTTLER_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REQUEST_THROTTLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // Implementation notes: When extending this class for a new RequestType, please | 33 // Implementation notes: When extending this class for a new RequestType, please |
34 // 1) define in request_counter.cc in kRequestTypeInfo | 34 // 1) define in request_counter.cc in kRequestTypeInfo |
35 // a) the string value for your |type| and | 35 // a) the string value for your |type| and |
36 // b) constants for day/count prefs; | 36 // b) constants for day/count prefs; |
37 // 2) define a new RequestThrottlerTypes histogram suffix in histogram.xml | 37 // 2) define a new RequestThrottlerTypes histogram suffix in histogram.xml |
38 // (with the same string value as in 1a)). | 38 // (with the same string value as in 1a)). |
39 class RequestThrottler { | 39 class RequestThrottler { |
40 public: | 40 public: |
41 // Enumeration listing all current applications of the request counter. | 41 // Enumeration listing all current applications of the request counter. |
42 enum class RequestType { | 42 enum class RequestType { |
43 CONTENT_SUGGESTION_FETCHER, | 43 CONTENT_SUGGESTION_FETCHER_RARE_NTP_USER, |
| 44 CONTENT_SUGGESTION_FETCHER_ACTIVE_NTP_USER, |
| 45 CONTENT_SUGGESTION_FETCHER_ACTIVE_SUGGESTIONS_CONSUMER, |
44 CONTENT_SUGGESTION_THUMBNAIL, | 46 CONTENT_SUGGESTION_THUMBNAIL, |
45 }; | 47 }; |
46 | 48 |
47 RequestThrottler(PrefService* pref_service, RequestType type); | 49 RequestThrottler(PrefService* pref_service, RequestType type); |
48 | 50 |
49 // Registers profile prefs for all RequestTypes. Called from browser_prefs.cc. | 51 // Registers profile prefs for all RequestTypes. Called from browser_prefs.cc. |
50 static void RegisterProfilePrefs(PrefRegistrySimple* registry); | 52 static void RegisterProfilePrefs(PrefRegistrySimple* registry); |
51 | 53 |
52 // Returns whether quota is available for another request and reports this | 54 // Returns whether quota is available for another request and reports this |
53 // information to UMA. Interactive requests should be always granted (upon | 55 // information to UMA. Interactive requests should be always granted (upon |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 base::HistogramBase* histogram_request_status_; | 89 base::HistogramBase* histogram_request_status_; |
88 base::HistogramBase* histogram_per_day_background_; | 90 base::HistogramBase* histogram_per_day_background_; |
89 base::HistogramBase* histogram_per_day_interactive_; | 91 base::HistogramBase* histogram_per_day_interactive_; |
90 | 92 |
91 DISALLOW_COPY_AND_ASSIGN(RequestThrottler); | 93 DISALLOW_COPY_AND_ASSIGN(RequestThrottler); |
92 }; | 94 }; |
93 | 95 |
94 } // namespace ntp_snippets | 96 } // namespace ntp_snippets |
95 | 97 |
96 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REQUEST_THROTTLER_H_ | 98 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REQUEST_THROTTLER_H_ |
OLD | NEW |