Chromium Code Reviews| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 static Params GetFromFieldTrialsOrDefaults(); | 43 static Params GetFromFieldTrialsOrDefaults(); |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 DomainReliabilityScheduler(MockableTime* time, | 46 DomainReliabilityScheduler(MockableTime* time, |
| 47 size_t num_collectors, | 47 size_t num_collectors, |
| 48 const Params& params, | 48 const Params& params, |
| 49 const ScheduleUploadCallback& callback); | 49 const ScheduleUploadCallback& callback); |
| 50 ~DomainReliabilityScheduler(); | 50 ~DomainReliabilityScheduler(); |
| 51 | 51 |
| 52 // Called when a beacon is added to the context. May call the provided | 52 // Called when a beacon is added to the context. May call the provided |
| 53 // ScheduleUploadCallback (if all previous beacons have been uploaded). | 53 // ScheduleUploadCallback (if all previous beacons have been uploaded). |
|
Ryan Sleevi
2014/04/26 02:37:39
Comment nit: Don't describe how this *is* used, de
Deprecated (see juliatuttle)
2014/04/28 22:01:13
Done.
| |
| 54 void OnBeaconAdded(); | 54 void OnBeaconAdded(); |
| 55 | 55 |
| 56 // Called when an upload is about to start. | 56 // Called when an upload is about to start. |
| 57 void OnUploadStart(int* collector_index_out); | 57 void OnUploadStart(int* collector_index_out); |
|
Ryan Sleevi
2014/04/26 02:37:39
BUG: You define |num_collectors| as a size_t, but
Deprecated (see juliatuttle)
2014/04/28 22:01:13
Done.
| |
| 58 | 58 |
| 59 // Called when an upload has finished. May call the provided | 59 // Called when an upload has finished. May call the provided |
| 60 // ScheduleUploadCallback (if the upload failed, or if beacons arrived | 60 // ScheduleUploadCallback (if the upload failed, or if beacons arrived |
| 61 // during the upload). | 61 // during the upload). |
| 62 void OnUploadComplete(bool success); | 62 void OnUploadComplete(bool success); |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 struct CollectorState { | 65 struct CollectorState { |
| 66 CollectorState(); | 66 CollectorState(); |
| 67 | 67 |
| 68 // The number of consecutive failures to upload to this collector, or 0 if | 68 // The number of consecutive failures to upload to this collector, or 0 if |
| 69 // the most recent upload succeeded. | 69 // the most recent upload succeeded. |
| 70 int failures; | 70 int failures; |
| 71 base::TimeTicks next_upload; | 71 base::TimeTicks next_upload; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 void MaybeScheduleUpload(); | 74 void MaybeScheduleUpload(); |
| 75 | 75 |
| 76 void GetNextUploadTimeAndCollector(base::TimeTicks now, | 76 void GetNextUploadTimeAndCollector(base::TimeTicks now, |
| 77 base::TimeTicks* upload_time_out, | 77 base::TimeTicks* upload_time_out, |
| 78 int* collector_index_out); | 78 int* collector_index_out); |
| 79 | |
| 79 base::TimeDelta GetUploadRetryInterval(int failures); | 80 base::TimeDelta GetUploadRetryInterval(int failures); |
| 80 | 81 |
| 81 MockableTime* time_; | 82 MockableTime* time_; |
| 82 std::vector<CollectorState> collectors_; | 83 std::vector<CollectorState> collectors_; |
| 83 Params params_; | 84 Params params_; |
| 84 ScheduleUploadCallback callback_; | 85 ScheduleUploadCallback callback_; |
| 85 | 86 |
| 86 // Whether there are beacons that have not yet been uploaded. Set when a | 87 // Whether there are beacons that have not yet been uploaded. Set when a |
| 87 // beacon arrives or an upload fails, and cleared when an upload starts. | 88 // beacon arrives or an upload fails, and cleared when an upload starts. |
| 88 bool upload_pending_; | 89 bool upload_pending_; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 104 // upload. | 105 // upload. |
| 105 base::TimeTicks first_beacon_time_; | 106 base::TimeTicks first_beacon_time_; |
| 106 | 107 |
| 107 // first_beacon_time_ saved during uploads. Restored if upload fails. | 108 // first_beacon_time_ saved during uploads. Restored if upload fails. |
| 108 base::TimeTicks old_first_beacon_time_; | 109 base::TimeTicks old_first_beacon_time_; |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 } // namespace domain_reliability | 112 } // namespace domain_reliability |
| 112 | 113 |
| 113 #endif // COMPONENTS_DOMAIN_RELIABILITY_SCHEDULER_H_ | 114 #endif // COMPONENTS_DOMAIN_RELIABILITY_SCHEDULER_H_ |
| OLD | NEW |