| 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 #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" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "components/domain_reliability/config.h" | 12 #include "components/domain_reliability/config.h" |
| 13 #include "components/domain_reliability/util.h" | 13 #include "components/domain_reliability/util.h" |
| 14 #include "net/base/backoff_entry.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 const unsigned kInvalidCollectorIndex = static_cast<unsigned>(-1); | 18 const unsigned kInvalidCollectorIndex = static_cast<unsigned>(-1); |
| 18 | 19 |
| 19 const unsigned kDefaultMinimumUploadDelaySec = 60; | 20 const unsigned kDefaultMinimumUploadDelaySec = 60; |
| 20 const unsigned kDefaultMaximumUploadDelaySec = 300; | 21 const unsigned kDefaultMaximumUploadDelaySec = 300; |
| 21 const unsigned kDefaultUploadRetryIntervalSec = 60; | 22 const unsigned kDefaultUploadRetryIntervalSec = 60; |
| 22 | 23 |
| 23 const char* kMinimumUploadDelayFieldTrialName = "DomRel-MinimumUploadDelay"; | 24 const char* kMinimumUploadDelayFieldTrialName = "DomRel-MinimumUploadDelay"; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 backoff_policy_.initial_delay_ms = | 86 backoff_policy_.initial_delay_ms = |
| 86 params.upload_retry_interval.InMilliseconds(); | 87 params.upload_retry_interval.InMilliseconds(); |
| 87 backoff_policy_.multiply_factor = kMultiplyFactor; | 88 backoff_policy_.multiply_factor = kMultiplyFactor; |
| 88 backoff_policy_.jitter_factor = kJitterFactor; | 89 backoff_policy_.jitter_factor = kJitterFactor; |
| 89 backoff_policy_.maximum_backoff_ms = kMaximumBackoffMs; | 90 backoff_policy_.maximum_backoff_ms = kMaximumBackoffMs; |
| 90 backoff_policy_.entry_lifetime_ms = 0; | 91 backoff_policy_.entry_lifetime_ms = 0; |
| 91 backoff_policy_.always_use_initial_delay = false; | 92 backoff_policy_.always_use_initial_delay = false; |
| 92 | 93 |
| 93 for (size_t i = 0; i < num_collectors; ++i) { | 94 for (size_t i = 0; i < num_collectors; ++i) { |
| 94 collectors_.push_back( | 95 collectors_.push_back( |
| 95 new MockableTimeBackoffEntry(&backoff_policy_, time_)); | 96 new net::BackoffEntry(&backoff_policy_, time_)); |
| 96 } | 97 } |
| 97 } | 98 } |
| 98 | 99 |
| 99 DomainReliabilityScheduler::~DomainReliabilityScheduler() {} | 100 DomainReliabilityScheduler::~DomainReliabilityScheduler() {} |
| 100 | 101 |
| 101 void DomainReliabilityScheduler::OnBeaconAdded() { | 102 void DomainReliabilityScheduler::OnBeaconAdded() { |
| 102 if (!upload_pending_) | 103 if (!upload_pending_) |
| 103 first_beacon_time_ = time_->NowTicks(); | 104 first_beacon_time_ = time_->NowTicks(); |
| 104 upload_pending_ = true; | 105 upload_pending_ = true; |
| 105 MaybeScheduleUpload(); | 106 MaybeScheduleUpload(); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 min_index = i; | 259 min_index = i; |
| 259 } | 260 } |
| 260 } | 261 } |
| 261 | 262 |
| 262 DCHECK_NE(kInvalidCollectorIndex, min_index); | 263 DCHECK_NE(kInvalidCollectorIndex, min_index); |
| 263 *upload_time_out = min_time; | 264 *upload_time_out = min_time; |
| 264 *collector_index_out = min_index; | 265 *collector_index_out = min_index; |
| 265 } | 266 } |
| 266 | 267 |
| 267 } // namespace domain_reliability | 268 } // namespace domain_reliability |
| OLD | NEW |