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_SCHEDULER_H_ | 5 #ifndef COMPONENTS_DOMAIN_RELIABILITY_SCHEDULER_H_ |
6 #define COMPONENTS_DOMAIN_RELIABILITY_SCHEDULER_H_ | 6 #define COMPONENTS_DOMAIN_RELIABILITY_SCHEDULER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // called exactly once after |OnUploadStart|. |result| should be the result | 71 // called exactly once after |OnUploadStart|. |result| should be the result |
72 // passed to the upload callback by the Uploader. | 72 // passed to the upload callback by the Uploader. |
73 void OnUploadComplete(const DomainReliabilityUploader::UploadResult& result); | 73 void OnUploadComplete(const DomainReliabilityUploader::UploadResult& result); |
74 | 74 |
75 base::Value* GetWebUIData() const; | 75 base::Value* GetWebUIData() const; |
76 | 76 |
77 // Disables jitter in BackoffEntries to make scheduling deterministic for | 77 // Disables jitter in BackoffEntries to make scheduling deterministic for |
78 // unit tests. | 78 // unit tests. |
79 void MakeDeterministicForTesting(); | 79 void MakeDeterministicForTesting(); |
80 | 80 |
| 81 // Gets the time until the next upload attempt on the last collector used. |
| 82 // This will be 0 if the upload was a success; it does not take into account |
| 83 // minimum_upload_delay and maximum_upload_delay. |
| 84 base::TimeDelta last_collector_retry_delay() const { |
| 85 return last_collector_retry_delay_; |
| 86 } |
| 87 |
81 private: | 88 private: |
82 void MaybeScheduleUpload(); | 89 void MaybeScheduleUpload(); |
83 | 90 |
84 void GetNextUploadTimeAndCollector(base::TimeTicks now, | 91 void GetNextUploadTimeAndCollector(base::TimeTicks now, |
85 base::TimeTicks* upload_time_out, | 92 base::TimeTicks* upload_time_out, |
86 size_t* collector_index_out); | 93 size_t* collector_index_out); |
87 | 94 |
88 MockableTime* time_; | 95 MockableTime* time_; |
89 Params params_; | 96 Params params_; |
90 ScheduleUploadCallback callback_; | 97 ScheduleUploadCallback callback_; |
(...skipping 17 matching lines...) Expand all Loading... |
108 // |OnUploadStart| and cleared in |OnUploadComplete|.) | 115 // |OnUploadStart| and cleared in |OnUploadComplete|.) |
109 size_t collector_index_; | 116 size_t collector_index_; |
110 | 117 |
111 // Time of the first beacon that was not included in the last successful | 118 // Time of the first beacon that was not included in the last successful |
112 // upload. | 119 // upload. |
113 base::TimeTicks first_beacon_time_; | 120 base::TimeTicks first_beacon_time_; |
114 | 121 |
115 // first_beacon_time_ saved during uploads. Restored if upload fails. | 122 // first_beacon_time_ saved during uploads. Restored if upload fails. |
116 base::TimeTicks old_first_beacon_time_; | 123 base::TimeTicks old_first_beacon_time_; |
117 | 124 |
| 125 // Time until the next upload attempt on the last collector used. (Saved for |
| 126 // histograms in Context.) |
| 127 base::TimeDelta last_collector_retry_delay_; |
| 128 |
118 // Extra bits to return in GetWebUIData. | 129 // Extra bits to return in GetWebUIData. |
119 base::TimeTicks scheduled_min_time_; | 130 base::TimeTicks scheduled_min_time_; |
120 base::TimeTicks scheduled_max_time_; | 131 base::TimeTicks scheduled_max_time_; |
121 // Whether the other last_upload_* fields are populated. | 132 // Whether the other last_upload_* fields are populated. |
122 bool last_upload_finished_; | 133 bool last_upload_finished_; |
123 base::TimeTicks last_upload_start_time_; | 134 base::TimeTicks last_upload_start_time_; |
124 base::TimeTicks last_upload_end_time_; | 135 base::TimeTicks last_upload_end_time_; |
125 size_t last_upload_collector_index_; | 136 size_t last_upload_collector_index_; |
126 bool last_upload_success_; | 137 bool last_upload_success_; |
127 }; | 138 }; |
128 | 139 |
129 } // namespace domain_reliability | 140 } // namespace domain_reliability |
130 | 141 |
131 #endif // COMPONENTS_DOMAIN_RELIABILITY_SCHEDULER_H_ | 142 #endif // COMPONENTS_DOMAIN_RELIABILITY_SCHEDULER_H_ |
OLD | NEW |