OLD | NEW |
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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/synchronization/lock.h" | 8 #include "base/synchronization/lock.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } else { | 242 } else { |
243 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.NetworkOfflineChange", | 243 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.NetworkOfflineChange", |
244 SinceLast(&last_network_change_)); | 244 SinceLast(&last_network_change_)); |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 // Record histogram data whenever we receive a packet. Should only be called | 248 // Record histogram data whenever we receive a packet. Should only be called |
249 // from the network thread. | 249 // from the network thread. |
250 void NotifyDataReceived(const URLRequest& request, int bytes_read) { | 250 void NotifyDataReceived(const URLRequest& request, int bytes_read) { |
251 if (IsLocalhost(request.url().host()) || | 251 if (IsLocalhost(request.url().host()) || |
252 !(request.url().SchemeIs("http") || request.url().SchemeIs("https"))) { | 252 !request.url().SchemeIsHTTPOrHTTPS()) { |
253 return; | 253 return; |
254 } | 254 } |
255 | 255 |
256 base::TimeTicks now = base::TimeTicks::Now(); | 256 base::TimeTicks now = base::TimeTicks::Now(); |
257 base::TimeDelta request_duration = now - request.creation_time(); | 257 base::TimeDelta request_duration = now - request.creation_time(); |
258 if (bytes_read_since_last_connection_change_ == 0) { | 258 if (bytes_read_since_last_connection_change_ == 0) { |
259 first_byte_after_connection_change_ = now - last_connection_change_; | 259 first_byte_after_connection_change_ = now - last_connection_change_; |
260 fastest_RTT_since_last_connection_change_ = request_duration; | 260 fastest_RTT_since_last_connection_change_ = request_duration; |
261 } | 261 } |
262 bytes_read_since_last_connection_change_ += bytes_read; | 262 bytes_read_since_last_connection_change_ += bytes_read; |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 DCHECK(g_network_change_notifier); | 704 DCHECK(g_network_change_notifier); |
705 g_network_change_notifier = NULL; | 705 g_network_change_notifier = NULL; |
706 } | 706 } |
707 | 707 |
708 NetworkChangeNotifier::DisableForTest::~DisableForTest() { | 708 NetworkChangeNotifier::DisableForTest::~DisableForTest() { |
709 DCHECK(!g_network_change_notifier); | 709 DCHECK(!g_network_change_notifier); |
710 g_network_change_notifier = network_change_notifier_; | 710 g_network_change_notifier = network_change_notifier_; |
711 } | 711 } |
712 | 712 |
713 } // namespace net | 713 } // namespace net |
OLD | NEW |