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

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

Issue 307943004: Adds bluetooth connection type to NetworkChangeNotifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@netinfo
Patch Set: Updating spec url Created 6 years, 6 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/base/network_change_notifier.h ('k') | net/tools/net_watcher/net_watcher.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/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 "base/threading/thread_checker.h" 9 #include "base/threading/thread_checker.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 first_byte_after_connection_change_); 144 first_byte_after_connection_change_);
145 UMA_HISTOGRAM_TIMES("NCN.CM.FastestRTTOn4G", 145 UMA_HISTOGRAM_TIMES("NCN.CM.FastestRTTOn4G",
146 fastest_RTT_since_last_connection_change_); 146 fastest_RTT_since_last_connection_change_);
147 break; 147 break;
148 case NetworkChangeNotifier::CONNECTION_NONE: 148 case NetworkChangeNotifier::CONNECTION_NONE:
149 UMA_HISTOGRAM_TIMES("NCN.CM.FirstReadOnNone", 149 UMA_HISTOGRAM_TIMES("NCN.CM.FirstReadOnNone",
150 first_byte_after_connection_change_); 150 first_byte_after_connection_change_);
151 UMA_HISTOGRAM_TIMES("NCN.CM.FastestRTTOnNone", 151 UMA_HISTOGRAM_TIMES("NCN.CM.FastestRTTOnNone",
152 fastest_RTT_since_last_connection_change_); 152 fastest_RTT_since_last_connection_change_);
153 break; 153 break;
154 case NetworkChangeNotifier::CONNECTION_BLUETOOTH:
155 UMA_HISTOGRAM_TIMES("NCN.CM.FirstReadOnBluetooth",
156 first_byte_after_connection_change_);
157 UMA_HISTOGRAM_TIMES("NCN.CM.FastestRTTOnBluetooth",
158 fastest_RTT_since_last_connection_change_);
154 } 159 }
155 } 160 }
156 if (peak_kbps_since_last_connection_change_) { 161 if (peak_kbps_since_last_connection_change_) {
157 switch (last_connection_type_) { 162 switch (last_connection_type_) {
158 case NetworkChangeNotifier::CONNECTION_UNKNOWN: 163 case NetworkChangeNotifier::CONNECTION_UNKNOWN:
159 UMA_HISTOGRAM_COUNTS("NCN.CM.PeakKbpsOnUnknown", 164 UMA_HISTOGRAM_COUNTS("NCN.CM.PeakKbpsOnUnknown",
160 peak_kbps_since_last_connection_change_); 165 peak_kbps_since_last_connection_change_);
161 break; 166 break;
162 case NetworkChangeNotifier::CONNECTION_ETHERNET: 167 case NetworkChangeNotifier::CONNECTION_ETHERNET:
163 UMA_HISTOGRAM_COUNTS("NCN.CM.PeakKbpsOnEthernet", 168 UMA_HISTOGRAM_COUNTS("NCN.CM.PeakKbpsOnEthernet",
(...skipping 12 matching lines...) Expand all
176 peak_kbps_since_last_connection_change_); 181 peak_kbps_since_last_connection_change_);
177 break; 182 break;
178 case NetworkChangeNotifier::CONNECTION_4G: 183 case NetworkChangeNotifier::CONNECTION_4G:
179 UMA_HISTOGRAM_COUNTS("NCN.CM.PeakKbpsOn4G", 184 UMA_HISTOGRAM_COUNTS("NCN.CM.PeakKbpsOn4G",
180 peak_kbps_since_last_connection_change_); 185 peak_kbps_since_last_connection_change_);
181 break; 186 break;
182 case NetworkChangeNotifier::CONNECTION_NONE: 187 case NetworkChangeNotifier::CONNECTION_NONE:
183 UMA_HISTOGRAM_COUNTS("NCN.CM.PeakKbpsOnNone", 188 UMA_HISTOGRAM_COUNTS("NCN.CM.PeakKbpsOnNone",
184 peak_kbps_since_last_connection_change_); 189 peak_kbps_since_last_connection_change_);
185 break; 190 break;
191 case NetworkChangeNotifier::CONNECTION_BLUETOOTH:
192 UMA_HISTOGRAM_COUNTS("NCN.CM.PeakKbpsOnBluetooth",
193 peak_kbps_since_last_connection_change_);
194 break;
186 } 195 }
187 } 196 }
188 switch (last_connection_type_) { 197 switch (last_connection_type_) {
189 case NetworkChangeNotifier::CONNECTION_UNKNOWN: 198 case NetworkChangeNotifier::CONNECTION_UNKNOWN:
190 UMA_HISTOGRAM_LONG_TIMES("NCN.CM.TimeOnUnknown", state_duration); 199 UMA_HISTOGRAM_LONG_TIMES("NCN.CM.TimeOnUnknown", state_duration);
191 UMA_HISTOGRAM_COUNTS("NCN.CM.KBTransferedOnUnknown", kilobytes_read); 200 UMA_HISTOGRAM_COUNTS("NCN.CM.KBTransferedOnUnknown", kilobytes_read);
192 break; 201 break;
193 case NetworkChangeNotifier::CONNECTION_ETHERNET: 202 case NetworkChangeNotifier::CONNECTION_ETHERNET:
194 UMA_HISTOGRAM_LONG_TIMES("NCN.CM.TimeOnEthernet", state_duration); 203 UMA_HISTOGRAM_LONG_TIMES("NCN.CM.TimeOnEthernet", state_duration);
195 UMA_HISTOGRAM_COUNTS("NCN.CM.KBTransferedOnEthernet", kilobytes_read); 204 UMA_HISTOGRAM_COUNTS("NCN.CM.KBTransferedOnEthernet", kilobytes_read);
(...skipping 11 matching lines...) Expand all
207 UMA_HISTOGRAM_COUNTS("NCN.CM.KBTransferedOn3G", kilobytes_read); 216 UMA_HISTOGRAM_COUNTS("NCN.CM.KBTransferedOn3G", kilobytes_read);
208 break; 217 break;
209 case NetworkChangeNotifier::CONNECTION_4G: 218 case NetworkChangeNotifier::CONNECTION_4G:
210 UMA_HISTOGRAM_LONG_TIMES("NCN.CM.TimeOn4G", state_duration); 219 UMA_HISTOGRAM_LONG_TIMES("NCN.CM.TimeOn4G", state_duration);
211 UMA_HISTOGRAM_COUNTS("NCN.CM.KBTransferedOn4G", kilobytes_read); 220 UMA_HISTOGRAM_COUNTS("NCN.CM.KBTransferedOn4G", kilobytes_read);
212 break; 221 break;
213 case NetworkChangeNotifier::CONNECTION_NONE: 222 case NetworkChangeNotifier::CONNECTION_NONE:
214 UMA_HISTOGRAM_LONG_TIMES("NCN.CM.TimeOnNone", state_duration); 223 UMA_HISTOGRAM_LONG_TIMES("NCN.CM.TimeOnNone", state_duration);
215 UMA_HISTOGRAM_COUNTS("NCN.CM.KBTransferedOnNone", kilobytes_read); 224 UMA_HISTOGRAM_COUNTS("NCN.CM.KBTransferedOnNone", kilobytes_read);
216 break; 225 break;
226 case NetworkChangeNotifier::CONNECTION_BLUETOOTH:
227 UMA_HISTOGRAM_LONG_TIMES("NCN.CM.TimeOnBluetooth", state_duration);
228 UMA_HISTOGRAM_COUNTS("NCN.CM.KBTransferedOnBluetooth", kilobytes_read);
229 break;
217 } 230 }
218 231
219 if (type != NetworkChangeNotifier::CONNECTION_NONE) { 232 if (type != NetworkChangeNotifier::CONNECTION_NONE) {
220 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OnlineChange", state_duration); 233 UMA_HISTOGRAM_MEDIUM_TIMES("NCN.OnlineChange", state_duration);
221 234
222 if (offline_packets_received_) { 235 if (offline_packets_received_) {
223 if ((now - last_offline_packet_received_) < 236 if ((now - last_offline_packet_received_) <
224 base::TimeDelta::FromSeconds(5)) { 237 base::TimeDelta::FromSeconds(5)) {
225 // We can compare this sum with the sum of NCN.OfflineDataRecv. 238 // We can compare this sum with the sum of NCN.OfflineDataRecv.
226 UMA_HISTOGRAM_COUNTS_10000( 239 UMA_HISTOGRAM_COUNTS_10000(
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // static 546 // static
534 const char* NetworkChangeNotifier::ConnectionTypeToString( 547 const char* NetworkChangeNotifier::ConnectionTypeToString(
535 ConnectionType type) { 548 ConnectionType type) {
536 static const char* kConnectionTypeNames[] = { 549 static const char* kConnectionTypeNames[] = {
537 "CONNECTION_UNKNOWN", 550 "CONNECTION_UNKNOWN",
538 "CONNECTION_ETHERNET", 551 "CONNECTION_ETHERNET",
539 "CONNECTION_WIFI", 552 "CONNECTION_WIFI",
540 "CONNECTION_2G", 553 "CONNECTION_2G",
541 "CONNECTION_3G", 554 "CONNECTION_3G",
542 "CONNECTION_4G", 555 "CONNECTION_4G",
543 "CONNECTION_NONE" 556 "CONNECTION_NONE",
557 "CONNECTION_BLUETOOTH"
544 }; 558 };
545 COMPILE_ASSERT( 559 COMPILE_ASSERT(
546 arraysize(kConnectionTypeNames) == 560 arraysize(kConnectionTypeNames) ==
547 NetworkChangeNotifier::CONNECTION_NONE + 1, 561 NetworkChangeNotifier::CONNECTION_LAST + 1,
548 ConnectionType_name_count_mismatch); 562 ConnectionType_name_count_mismatch);
549 if (type < CONNECTION_UNKNOWN || type > CONNECTION_NONE) { 563 if (type < CONNECTION_UNKNOWN || type > CONNECTION_LAST) {
550 NOTREACHED(); 564 NOTREACHED();
551 return "CONNECTION_INVALID"; 565 return "CONNECTION_INVALID";
552 } 566 }
553 return kConnectionTypeNames[type]; 567 return kConnectionTypeNames[type];
554 } 568 }
555 569
556 // static 570 // static
557 void NetworkChangeNotifier::NotifyDataReceived(const URLRequest& request, 571 void NetworkChangeNotifier::NotifyDataReceived(const URLRequest& request,
558 int bytes_read) { 572 int bytes_read) {
559 if (!g_network_change_notifier || 573 if (!g_network_change_notifier ||
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 switch (type) { 632 switch (type) {
619 case CONNECTION_2G: 633 case CONNECTION_2G:
620 case CONNECTION_3G: 634 case CONNECTION_3G:
621 case CONNECTION_4G: 635 case CONNECTION_4G:
622 is_cellular = true; 636 is_cellular = true;
623 break; 637 break;
624 case CONNECTION_UNKNOWN: 638 case CONNECTION_UNKNOWN:
625 case CONNECTION_ETHERNET: 639 case CONNECTION_ETHERNET:
626 case CONNECTION_WIFI: 640 case CONNECTION_WIFI:
627 case CONNECTION_NONE: 641 case CONNECTION_NONE:
642 case CONNECTION_BLUETOOTH:
628 is_cellular = false; 643 is_cellular = false;
629 break; 644 break;
630 } 645 }
631 return is_cellular; 646 return is_cellular;
632 } 647 }
633 648
634 // static 649 // static
635 NetworkChangeNotifier* NetworkChangeNotifier::CreateMock() { 650 NetworkChangeNotifier* NetworkChangeNotifier::CreateMock() {
636 return new MockNetworkChangeNotifier(); 651 return new MockNetworkChangeNotifier();
637 } 652 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 DCHECK(g_network_change_notifier); 785 DCHECK(g_network_change_notifier);
771 g_network_change_notifier = NULL; 786 g_network_change_notifier = NULL;
772 } 787 }
773 788
774 NetworkChangeNotifier::DisableForTest::~DisableForTest() { 789 NetworkChangeNotifier::DisableForTest::~DisableForTest() {
775 DCHECK(!g_network_change_notifier); 790 DCHECK(!g_network_change_notifier);
776 g_network_change_notifier = network_change_notifier_; 791 g_network_change_notifier = network_change_notifier_;
777 } 792 }
778 793
779 } // namespace net 794 } // namespace net
OLDNEW
« no previous file with comments | « net/base/network_change_notifier.h ('k') | net/tools/net_watcher/net_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698