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

Side by Side Diff: net/dns/dns_session.cc

Issue 826973002: replace COMPILE_ASSERT with static_assert in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply fixups Created 5 years, 11 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 | « net/dns/dns_config_service_posix.cc ('k') | net/http/http_auth.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/dns/dns_session.h" 5 #include "net/dns/dns_session.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 unsigned num_backoffs = attempt / config_.nameservers.size(); 265 unsigned num_backoffs = attempt / config_.nameservers.size();
266 266
267 return std::min(timeout * (1 << num_backoffs), 267 return std::min(timeout * (1 << num_backoffs),
268 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs)); 268 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs));
269 } 269 }
270 270
271 base::TimeDelta DnsSession::NextTimeoutFromHistogram(unsigned server_index, 271 base::TimeDelta DnsSession::NextTimeoutFromHistogram(unsigned server_index,
272 int attempt) { 272 int attempt) {
273 DCHECK_LT(server_index, server_stats_.size()); 273 DCHECK_LT(server_index, server_stats_.size());
274 274
275 COMPILE_ASSERT(std::numeric_limits<base::HistogramBase::Count>::is_signed, 275 static_assert(std::numeric_limits<base::HistogramBase::Count>::is_signed,
276 histogram_base_count_assumed_to_be_signed); 276 "histogram base count assumed to be signed");
277 277
278 // Use fixed percentile of observed samples. 278 // Use fixed percentile of observed samples.
279 const base::SampleVector& samples = 279 const base::SampleVector& samples =
280 *server_stats_[server_index]->rtt_histogram; 280 *server_stats_[server_index]->rtt_histogram;
281 281
282 base::HistogramBase::Count total = samples.TotalCount(); 282 base::HistogramBase::Count total = samples.TotalCount();
283 base::HistogramBase::Count remaining_count = kRTOPercentile * total / 100; 283 base::HistogramBase::Count remaining_count = kRTOPercentile * total / 100;
284 size_t index = 0; 284 size_t index = 0;
285 while (remaining_count > 0 && index < rtt_buckets_.Get().size()) { 285 while (remaining_count > 0 && index < rtt_buckets_.Get().size()) {
286 remaining_count -= samples.GetCountAtIndex(index); 286 remaining_count -= samples.GetCountAtIndex(index);
287 ++index; 287 ++index;
288 } 288 }
289 289
290 base::TimeDelta timeout = 290 base::TimeDelta timeout =
291 base::TimeDelta::FromMilliseconds(rtt_buckets_.Get().range(index)); 291 base::TimeDelta::FromMilliseconds(rtt_buckets_.Get().range(index));
292 292
293 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs)); 293 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs));
294 294
295 // The timeout still doubles every full round. 295 // The timeout still doubles every full round.
296 unsigned num_backoffs = attempt / config_.nameservers.size(); 296 unsigned num_backoffs = attempt / config_.nameservers.size();
297 297
298 return std::min(timeout * (1 << num_backoffs), 298 return std::min(timeout * (1 << num_backoffs),
299 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs)); 299 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs));
300 } 300 }
301 301
302 } // namespace net 302 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_config_service_posix.cc ('k') | net/http/http_auth.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698