| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_DOMAIN_RELIABILITY_CONTEXT_H_ | 5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_H_ |
| 6 #define COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_H_ | 6 #define COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 const std::string& upload_reporter_string, | 54 const std::string& upload_reporter_string, |
| 55 const base::TimeTicks* last_network_change_time, | 55 const base::TimeTicks* last_network_change_time, |
| 56 DomainReliabilityDispatcher* dispatcher, | 56 DomainReliabilityDispatcher* dispatcher, |
| 57 DomainReliabilityUploader* uploader, | 57 DomainReliabilityUploader* uploader, |
| 58 std::unique_ptr<const DomainReliabilityConfig> config); | 58 std::unique_ptr<const DomainReliabilityConfig> config); |
| 59 ~DomainReliabilityContext(); | 59 ~DomainReliabilityContext(); |
| 60 | 60 |
| 61 // Notifies the context of a beacon on its domain(s); may or may not save the | 61 // Notifies the context of a beacon on its domain(s); may or may not save the |
| 62 // actual beacon to be uploaded, depending on the sample rates in the config, | 62 // actual beacon to be uploaded, depending on the sample rates in the config, |
| 63 // but will increment one of the request counters in any case. | 63 // but will increment one of the request counters in any case. |
| 64 void OnBeacon(std::unique_ptr<DomainReliabilityBeacon> beacon); | 64 // |
| 65 // Returns |true| if the beacon was queued or |false| if it was discarded, |
| 66 // for metrics purposes. |
| 67 bool OnBeacon(std::unique_ptr<DomainReliabilityBeacon> beacon); |
| 65 | 68 |
| 66 // Called to clear browsing data, since beacons are like browsing history. | 69 // Called to clear browsing data, since beacons are like browsing history. |
| 67 void ClearBeacons(); | 70 void ClearBeacons(); |
| 68 | 71 |
| 69 // Gets a Value containing data that can be formatted into a web page for | 72 // Gets a Value containing data that can be formatted into a web page for |
| 70 // debugging purposes. | 73 // debugging purposes. |
| 71 std::unique_ptr<base::Value> GetWebUIData() const; | 74 std::unique_ptr<base::Value> GetWebUIData() const; |
| 72 | 75 |
| 73 // Gets the beacons queued for upload in this context. |*beacons_out| will be | 76 // Gets the beacons queued for upload in this context. |*beacons_out| will be |
| 74 // cleared and filled with pointers to the beacons; the pointers remain valid | 77 // cleared and filled with pointers to the beacons; the pointers remain valid |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 DomainReliabilityUploader* uploader_; | 118 DomainReliabilityUploader* uploader_; |
| 116 | 119 |
| 117 std::deque<std::unique_ptr<DomainReliabilityBeacon>> beacons_; | 120 std::deque<std::unique_ptr<DomainReliabilityBeacon>> beacons_; |
| 118 size_t uploading_beacons_size_; | 121 size_t uploading_beacons_size_; |
| 119 base::TimeTicks upload_time_; | 122 base::TimeTicks upload_time_; |
| 120 base::TimeTicks last_upload_time_; | 123 base::TimeTicks last_upload_time_; |
| 121 // The last network change time is not tracked per-context, so this is a | 124 // The last network change time is not tracked per-context, so this is a |
| 122 // pointer to that value in a wider (e.g. per-Monitor or unittest) scope. | 125 // pointer to that value in a wider (e.g. per-Monitor or unittest) scope. |
| 123 const base::TimeTicks* last_network_change_time_; | 126 const base::TimeTicks* last_network_change_time_; |
| 124 | 127 |
| 128 base::TimeTicks last_queued_beacon_time_; |
| 129 |
| 125 base::WeakPtrFactory<DomainReliabilityContext> weak_factory_; | 130 base::WeakPtrFactory<DomainReliabilityContext> weak_factory_; |
| 126 | 131 |
| 127 DISALLOW_COPY_AND_ASSIGN(DomainReliabilityContext); | 132 DISALLOW_COPY_AND_ASSIGN(DomainReliabilityContext); |
| 128 }; | 133 }; |
| 129 | 134 |
| 130 } // namespace domain_reliability | 135 } // namespace domain_reliability |
| 131 | 136 |
| 132 #endif // COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_H_ | 137 #endif // COMPONENTS_DOMAIN_RELIABILITY_CONTEXT_H_ |
| OLD | NEW |