Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: components/domain_reliability/scheduler.cc

Issue 272773004: Domain Reliability: Don't clear "upload pending" bit until upload starts (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/domain_reliability/scheduler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "components/domain_reliability/scheduler.h" 5 #include "components/domain_reliability/scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 void DomainReliabilityScheduler::OnBeaconAdded() { 82 void DomainReliabilityScheduler::OnBeaconAdded() {
83 if (!upload_pending_) 83 if (!upload_pending_)
84 first_beacon_time_ = time_->NowTicks(); 84 first_beacon_time_ = time_->NowTicks();
85 upload_pending_ = true; 85 upload_pending_ = true;
86 MaybeScheduleUpload(); 86 MaybeScheduleUpload();
87 } 87 }
88 88
89 size_t DomainReliabilityScheduler::OnUploadStart() { 89 size_t DomainReliabilityScheduler::OnUploadStart() {
90 DCHECK(upload_scheduled_); 90 DCHECK(upload_scheduled_);
91 DCHECK_EQ(kInvalidCollectorIndex, collector_index_); 91 DCHECK_EQ(kInvalidCollectorIndex, collector_index_);
92 upload_pending_ = false;
92 upload_scheduled_ = false; 93 upload_scheduled_ = false;
93 upload_running_ = true; 94 upload_running_ = true;
94 95
95 base::TimeTicks now = time_->NowTicks(); 96 base::TimeTicks now = time_->NowTicks();
96 base::TimeTicks min_upload_time; 97 base::TimeTicks min_upload_time;
97 GetNextUploadTimeAndCollector(now, &min_upload_time, &collector_index_); 98 GetNextUploadTimeAndCollector(now, &min_upload_time, &collector_index_);
98 DCHECK(min_upload_time <= now); 99 DCHECK(min_upload_time <= now);
99 100
100 VLOG(1) << "Starting upload to collector " << collector_index_ << "."; 101 VLOG(1) << "Starting upload to collector " << collector_index_ << ".";
101 102
(...skipping 30 matching lines...) Expand all
132 133
133 MaybeScheduleUpload(); 134 MaybeScheduleUpload();
134 } 135 }
135 136
136 DomainReliabilityScheduler::CollectorState::CollectorState() : failures(0) {} 137 DomainReliabilityScheduler::CollectorState::CollectorState() : failures(0) {}
137 138
138 void DomainReliabilityScheduler::MaybeScheduleUpload() { 139 void DomainReliabilityScheduler::MaybeScheduleUpload() {
139 if (!upload_pending_ || upload_scheduled_ || upload_running_) 140 if (!upload_pending_ || upload_scheduled_ || upload_running_)
140 return; 141 return;
141 142
142 upload_pending_ = false;
143 upload_scheduled_ = true; 143 upload_scheduled_ = true;
144 old_first_beacon_time_ = first_beacon_time_; 144 old_first_beacon_time_ = first_beacon_time_;
145 145
146 base::TimeTicks now = time_->NowTicks(); 146 base::TimeTicks now = time_->NowTicks();
147 147
148 base::TimeTicks min_by_deadline, max_by_deadline; 148 base::TimeTicks min_by_deadline, max_by_deadline;
149 min_by_deadline = first_beacon_time_ + params_.minimum_upload_delay; 149 min_by_deadline = first_beacon_time_ + params_.minimum_upload_delay;
150 max_by_deadline = first_beacon_time_ + params_.maximum_upload_delay; 150 max_by_deadline = first_beacon_time_ + params_.maximum_upload_delay;
151 DCHECK(min_by_deadline <= max_by_deadline); 151 DCHECK(min_by_deadline <= max_by_deadline);
152 152
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 return base::TimeDelta::FromSeconds(0); 203 return base::TimeDelta::FromSeconds(0);
204 else { 204 else {
205 // Don't back off more than 64x the original delay. 205 // Don't back off more than 64x the original delay.
206 if (failures > 7) 206 if (failures > 7)
207 failures = 7; 207 failures = 7;
208 return params_.upload_retry_interval * (1 << (failures - 1)); 208 return params_.upload_retry_interval * (1 << (failures - 1));
209 } 209 }
210 } 210 }
211 211
212 } // namespace domain_reliability 212 } // namespace domain_reliability
OLDNEW
« no previous file with comments | « no previous file | components/domain_reliability/scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698