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

Side by Side Diff: net/base/network_change_notifier.cc

Issue 760703002: Fix "value possibly truncated" warnings on MSVC, net/base edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile Created 6 years 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
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/base/network_change_notifier.h" 5 #include "net/base/network_change_notifier.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 fastest_RTT_since_last_connection_change_ = request_duration; 298 fastest_RTT_since_last_connection_change_ = request_duration;
299 } 299 }
300 bytes_read_since_last_connection_change_ += bytes_read; 300 bytes_read_since_last_connection_change_ += bytes_read;
301 if (request_duration < fastest_RTT_since_last_connection_change_) 301 if (request_duration < fastest_RTT_since_last_connection_change_)
302 fastest_RTT_since_last_connection_change_ = request_duration; 302 fastest_RTT_since_last_connection_change_ = request_duration;
303 // Ignore tiny transfers which will not produce accurate rates. 303 // Ignore tiny transfers which will not produce accurate rates.
304 // Ignore zero duration transfers which might cause divide by zero. 304 // Ignore zero duration transfers which might cause divide by zero.
305 if (bytes_read > 10000 && 305 if (bytes_read > 10000 &&
306 request_duration > base::TimeDelta::FromMilliseconds(1) && 306 request_duration > base::TimeDelta::FromMilliseconds(1) &&
307 request.creation_time() > last_connection_change_) { 307 request.creation_time() > last_connection_change_) {
308 int32 kbps = bytes_read * 8 / request_duration.InMilliseconds(); 308 int32 kbps = static_cast<int32>(
309 bytes_read * 8 / request_duration.InMilliseconds());
309 if (kbps > peak_kbps_since_last_connection_change_) 310 if (kbps > peak_kbps_since_last_connection_change_)
310 peak_kbps_since_last_connection_change_ = kbps; 311 peak_kbps_since_last_connection_change_ = kbps;
311 } 312 }
312 313
313 if (last_connection_type_ != NetworkChangeNotifier::CONNECTION_NONE) 314 if (last_connection_type_ != NetworkChangeNotifier::CONNECTION_NONE)
314 return; 315 return;
315 316
316 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineDataRecv", 317 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OfflineDataRecv",
317 now - last_connection_change_); 318 now - last_connection_change_);
318 offline_packets_received_++; 319 offline_packets_received_++;
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 DCHECK(g_network_change_notifier); 851 DCHECK(g_network_change_notifier);
851 g_network_change_notifier = NULL; 852 g_network_change_notifier = NULL;
852 } 853 }
853 854
854 NetworkChangeNotifier::DisableForTest::~DisableForTest() { 855 NetworkChangeNotifier::DisableForTest::~DisableForTest() {
855 DCHECK(!g_network_change_notifier); 856 DCHECK(!g_network_change_notifier);
856 g_network_change_notifier = network_change_notifier_; 857 g_network_change_notifier = network_change_notifier_;
857 } 858 }
858 859
859 } // namespace net 860 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698