| 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_REQUEST_THROTTLER_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_REQUEST_THROTTLER_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_REQUEST_THROTTLER_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_REQUEST_THROTTLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // 2) define a new RequestThrottlerTypes histogram suffix in histogram.xml | 39 // 2) define a new RequestThrottlerTypes histogram suffix in histogram.xml |
| 40 // (with the same string value as in 1a)). | 40 // (with the same string value as in 1a)). |
| 41 class RequestThrottler { | 41 class RequestThrottler { |
| 42 public: | 42 public: |
| 43 // Enumeration listing all current applications of the request counter. | 43 // Enumeration listing all current applications of the request counter. |
| 44 enum class RequestType { | 44 enum class RequestType { |
| 45 CONTENT_SUGGESTION_FETCHER | 45 CONTENT_SUGGESTION_FETCHER |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 RequestThrottler(PrefService* pref_service, | 48 RequestThrottler(PrefService* pref_service, |
| 49 RequestType type, | 49 RequestType type, |
| 50 int default_quota); | 50 int default_quota); |
| 51 | 51 |
| 52 // Registers profile prefs for all RequestTypes. Called from browser_prefs.cc. | 52 // Registers profile prefs for all RequestTypes. Called from browser_prefs.cc. |
| 53 static void RegisterProfilePrefs(PrefRegistrySimple* registry); | 53 static void RegisterProfilePrefs(PrefRegistrySimple* registry); |
| 54 | 54 |
| 55 // Returns whether quota is available for another request and reports this | 55 // Returns whether quota is available for another request and reports this |
| 56 // information to UMA. Forced requests always return true -- should be only | 56 // information to UMA. Forced requests always return true -- should be only |
| 57 // used for requests initiated by the user (if it is safe to assume that all | 57 // used for requests initiated by the user (if it is safe to assume that all |
| 58 // users cannot generate an amount of requests we cannot handle). | 58 // users cannot generate an amount of requests we cannot handle). |
| 59 bool DemandQuotaForRequest(bool force_request); | 59 bool DemandQuotaForRequest(bool force_request); |
| 60 | 60 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 79 // The histograms for reporting the requests of the given |type_|. | 79 // The histograms for reporting the requests of the given |type_|. |
| 80 base::HistogramBase* histogram_request_status_; | 80 base::HistogramBase* histogram_request_status_; |
| 81 base::HistogramBase* histogram_per_day_; | 81 base::HistogramBase* histogram_per_day_; |
| 82 | 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(RequestThrottler); | 83 DISALLOW_COPY_AND_ASSIGN(RequestThrottler); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 } // namespace ntp_snippets | 86 } // namespace ntp_snippets |
| 87 | 87 |
| 88 #endif // COMPONENTS_NTP_SNIPPETS_REQUEST_THROTTLER_H_ | 88 #endif // COMPONENTS_NTP_SNIPPETS_REQUEST_THROTTLER_H_ |
| OLD | NEW |