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/metrics/metrics_reporting_scheduler.h" | 5 #include "components/metrics/metrics_reporting_scheduler.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
8 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
9 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "build/build_config.h" |
10 #include "components/variations/variations_associated_data.h" | 13 #include "components/variations/variations_associated_data.h" |
11 | 14 |
12 using base::TimeDelta; | 15 using base::TimeDelta; |
13 | 16 |
14 namespace metrics { | 17 namespace metrics { |
15 | 18 |
16 namespace { | 19 namespace { |
17 | 20 |
18 // The delay, in seconds, after startup before sending the first log message. | 21 // The delay, in seconds, after startup before sending the first log message. |
19 #if defined(OS_ANDROID) || defined(OS_IOS) | 22 #if defined(OS_ANDROID) || defined(OS_IOS) |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 DCHECK(running_); | 158 DCHECK(running_); |
156 if (upload_timer_.IsRunning() || callback_pending_) | 159 if (upload_timer_.IsRunning() || callback_pending_) |
157 return; | 160 return; |
158 | 161 |
159 upload_timer_.Start(FROM_HERE, upload_interval_, this, | 162 upload_timer_.Start(FROM_HERE, upload_interval_, this, |
160 &MetricsReportingScheduler::TriggerUpload); | 163 &MetricsReportingScheduler::TriggerUpload); |
161 } | 164 } |
162 | 165 |
163 void MetricsReportingScheduler::BackOffUploadInterval() { | 166 void MetricsReportingScheduler::BackOffUploadInterval() { |
164 DCHECK_GT(kBackoffMultiplier, 1.0); | 167 DCHECK_GT(kBackoffMultiplier, 1.0); |
165 upload_interval_ = TimeDelta::FromMicroseconds( | 168 upload_interval_ = TimeDelta::FromMicroseconds(static_cast<int64_t>( |
166 static_cast<int64>(kBackoffMultiplier * | 169 kBackoffMultiplier * upload_interval_.InMicroseconds())); |
167 upload_interval_.InMicroseconds())); | |
168 | 170 |
169 TimeDelta max_interval = kMaxBackoffMultiplier * GetStandardUploadInterval(); | 171 TimeDelta max_interval = kMaxBackoffMultiplier * GetStandardUploadInterval(); |
170 if (upload_interval_ > max_interval || upload_interval_.InSeconds() < 0) { | 172 if (upload_interval_ > max_interval || upload_interval_.InSeconds() < 0) { |
171 upload_interval_ = max_interval; | 173 upload_interval_ = max_interval; |
172 } | 174 } |
173 } | 175 } |
174 | 176 |
175 base::TimeDelta MetricsReportingScheduler::GetStandardUploadInterval() { | 177 base::TimeDelta MetricsReportingScheduler::GetStandardUploadInterval() { |
176 return upload_interval_callback_.Run(); | 178 return upload_interval_callback_.Run(); |
177 } | 179 } |
178 | 180 |
179 } // namespace metrics | 181 } // namespace metrics |
OLD | NEW |