| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 SinceLast(&last_network_change_)); | 241 SinceLast(&last_network_change_)); |
| 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()) || !request.url().SchemeIsHttp()) { |
| 252 !(request.url().SchemeIs("http") || request.url().SchemeIs("https"))) { | |
| 253 return; | 252 return; |
| 254 } | 253 } |
| 255 | 254 |
| 256 base::TimeTicks now = base::TimeTicks::Now(); | 255 base::TimeTicks now = base::TimeTicks::Now(); |
| 257 base::TimeDelta request_duration = now - request.creation_time(); | 256 base::TimeDelta request_duration = now - request.creation_time(); |
| 258 if (bytes_read_since_last_connection_change_ == 0) { | 257 if (bytes_read_since_last_connection_change_ == 0) { |
| 259 first_byte_after_connection_change_ = now - last_connection_change_; | 258 first_byte_after_connection_change_ = now - last_connection_change_; |
| 260 fastest_RTT_since_last_connection_change_ = request_duration; | 259 fastest_RTT_since_last_connection_change_ = request_duration; |
| 261 } | 260 } |
| 262 bytes_read_since_last_connection_change_ += bytes_read; | 261 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); | 703 DCHECK(g_network_change_notifier); |
| 705 g_network_change_notifier = NULL; | 704 g_network_change_notifier = NULL; |
| 706 } | 705 } |
| 707 | 706 |
| 708 NetworkChangeNotifier::DisableForTest::~DisableForTest() { | 707 NetworkChangeNotifier::DisableForTest::~DisableForTest() { |
| 709 DCHECK(!g_network_change_notifier); | 708 DCHECK(!g_network_change_notifier); |
| 710 g_network_change_notifier = network_change_notifier_; | 709 g_network_change_notifier = network_change_notifier_; |
| 711 } | 710 } |
| 712 | 711 |
| 713 } // namespace net | 712 } // namespace net |
| OLD | NEW |