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

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

Issue 1306423004: [NetInfo] Browser changes to support connection.downlinkMax (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor browser test fix Created 5 years, 3 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') | no next file » | 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 <limits> 7 #include <limits>
8 8
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 *connection_type = CONNECTION_UNKNOWN; 549 *connection_type = CONNECTION_UNKNOWN;
550 *max_bandwidth_mbps = GetMaxBandwidthForConnectionSubtype(SUBTYPE_UNKNOWN); 550 *max_bandwidth_mbps = GetMaxBandwidthForConnectionSubtype(SUBTYPE_UNKNOWN);
551 return; 551 return;
552 } 552 }
553 553
554 g_network_change_notifier->GetCurrentMaxBandwidthAndConnectionType( 554 g_network_change_notifier->GetCurrentMaxBandwidthAndConnectionType(
555 max_bandwidth_mbps, connection_type); 555 max_bandwidth_mbps, connection_type);
556 } 556 }
557 557
558 // static 558 // static
559 double NetworkChangeNotifier::GetMaxBandwidthForConnectionSubtype(
560 ConnectionSubtype subtype) {
561 switch (subtype) {
562 case SUBTYPE_GSM:
563 return 0.01;
564 case SUBTYPE_IDEN:
565 return 0.064;
566 case SUBTYPE_CDMA:
567 return 0.115;
568 case SUBTYPE_1XRTT:
569 return 0.153;
570 case SUBTYPE_GPRS:
571 return 0.237;
572 case SUBTYPE_EDGE:
573 return 0.384;
574 case SUBTYPE_UMTS:
575 return 2.0;
576 case SUBTYPE_EVDO_REV_0:
577 return 2.46;
578 case SUBTYPE_EVDO_REV_A:
579 return 3.1;
580 case SUBTYPE_HSPA:
581 return 3.6;
582 case SUBTYPE_EVDO_REV_B:
583 return 14.7;
584 case SUBTYPE_HSDPA:
585 return 14.3;
586 case SUBTYPE_HSUPA:
587 return 14.4;
588 case SUBTYPE_EHRPD:
589 return 21.0;
590 case SUBTYPE_HSPAP:
591 return 42.0;
592 case SUBTYPE_LTE:
593 return 100.0;
594 case SUBTYPE_LTE_ADVANCED:
595 return 100.0;
596 case SUBTYPE_BLUETOOTH_1_2:
597 return 1.0;
598 case SUBTYPE_BLUETOOTH_2_1:
599 return 3.0;
600 case SUBTYPE_BLUETOOTH_3_0:
601 return 24.0;
602 case SUBTYPE_BLUETOOTH_4_0:
603 return 1.0;
604 case SUBTYPE_ETHERNET:
605 return 10.0;
606 case SUBTYPE_FAST_ETHERNET:
607 return 100.0;
608 case SUBTYPE_GIGABIT_ETHERNET:
609 return 1000.0;
610 case SUBTYPE_10_GIGABIT_ETHERNET:
611 return 10000.0;
612 case SUBTYPE_WIFI_B:
613 return 11.0;
614 case SUBTYPE_WIFI_G:
615 return 54.0;
616 case SUBTYPE_WIFI_N:
617 return 600.0;
618 case SUBTYPE_WIFI_AC:
619 return 1300.0;
620 case SUBTYPE_WIFI_AD:
621 return 7000.0;
622 case SUBTYPE_UNKNOWN:
623 return std::numeric_limits<double>::infinity();
624 case SUBTYPE_NONE:
625 return 0.0;
626 case SUBTYPE_OTHER:
627 return std::numeric_limits<double>::infinity();
628 }
629 NOTREACHED();
630 return std::numeric_limits<double>::infinity();
631 }
632
633 // static
559 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) { 634 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) {
560 if (!g_network_change_notifier) { 635 if (!g_network_change_notifier) {
561 *config = DnsConfig(); 636 *config = DnsConfig();
562 } else { 637 } else {
563 g_network_change_notifier->network_state_->GetDnsConfig(config); 638 g_network_change_notifier->network_state_->GetDnsConfig(config);
564 } 639 }
565 } 640 }
566 641
567 // static 642 // static
568 const char* NetworkChangeNotifier::ConnectionTypeToString( 643 const char* NetworkChangeNotifier::ConnectionTypeToString(
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 // should be overridden to provide specific bandwidth data based on the 929 // should be overridden to provide specific bandwidth data based on the
855 // platform. 930 // platform.
856 *connection_type = GetCurrentConnectionType(); 931 *connection_type = GetCurrentConnectionType();
857 *max_bandwidth_mbps = 932 *max_bandwidth_mbps =
858 *connection_type == CONNECTION_NONE 933 *connection_type == CONNECTION_NONE
859 ? GetMaxBandwidthForConnectionSubtype(SUBTYPE_NONE) 934 ? GetMaxBandwidthForConnectionSubtype(SUBTYPE_NONE)
860 : GetMaxBandwidthForConnectionSubtype(SUBTYPE_UNKNOWN); 935 : GetMaxBandwidthForConnectionSubtype(SUBTYPE_UNKNOWN);
861 } 936 }
862 937
863 // static 938 // static
864 double NetworkChangeNotifier::GetMaxBandwidthForConnectionSubtype(
865 ConnectionSubtype subtype) {
866 switch (subtype) {
867 case SUBTYPE_GSM:
868 return 0.01;
869 case SUBTYPE_IDEN:
870 return 0.064;
871 case SUBTYPE_CDMA:
872 return 0.115;
873 case SUBTYPE_1XRTT:
874 return 0.153;
875 case SUBTYPE_GPRS:
876 return 0.237;
877 case SUBTYPE_EDGE:
878 return 0.384;
879 case SUBTYPE_UMTS:
880 return 2.0;
881 case SUBTYPE_EVDO_REV_0:
882 return 2.46;
883 case SUBTYPE_EVDO_REV_A:
884 return 3.1;
885 case SUBTYPE_HSPA:
886 return 3.6;
887 case SUBTYPE_EVDO_REV_B:
888 return 14.7;
889 case SUBTYPE_HSDPA:
890 return 14.3;
891 case SUBTYPE_HSUPA:
892 return 14.4;
893 case SUBTYPE_EHRPD:
894 return 21.0;
895 case SUBTYPE_HSPAP:
896 return 42.0;
897 case SUBTYPE_LTE:
898 return 100.0;
899 case SUBTYPE_LTE_ADVANCED:
900 return 100.0;
901 case SUBTYPE_BLUETOOTH_1_2:
902 return 1.0;
903 case SUBTYPE_BLUETOOTH_2_1:
904 return 3.0;
905 case SUBTYPE_BLUETOOTH_3_0:
906 return 24.0;
907 case SUBTYPE_BLUETOOTH_4_0:
908 return 1.0;
909 case SUBTYPE_ETHERNET:
910 return 10.0;
911 case SUBTYPE_FAST_ETHERNET:
912 return 100.0;
913 case SUBTYPE_GIGABIT_ETHERNET:
914 return 1000.0;
915 case SUBTYPE_10_GIGABIT_ETHERNET:
916 return 10000.0;
917 case SUBTYPE_WIFI_B:
918 return 11.0;
919 case SUBTYPE_WIFI_G:
920 return 54.0;
921 case SUBTYPE_WIFI_N:
922 return 600.0;
923 case SUBTYPE_WIFI_AC:
924 return 1300.0;
925 case SUBTYPE_WIFI_AD:
926 return 7000.0;
927 case SUBTYPE_UNKNOWN:
928 return std::numeric_limits<double>::infinity();
929 case SUBTYPE_NONE:
930 return 0.0;
931 case SUBTYPE_OTHER:
932 return std::numeric_limits<double>::infinity();
933 }
934 NOTREACHED();
935 return std::numeric_limits<double>::infinity();
936 }
937
938 // static
939 void NetworkChangeNotifier::NotifyObserversOfIPAddressChange() { 939 void NetworkChangeNotifier::NotifyObserversOfIPAddressChange() {
940 if (g_network_change_notifier && 940 if (g_network_change_notifier &&
941 !NetworkChangeNotifier::test_notifications_only_) { 941 !NetworkChangeNotifier::test_notifications_only_) {
942 g_network_change_notifier->NotifyObserversOfIPAddressChangeImpl(); 942 g_network_change_notifier->NotifyObserversOfIPAddressChangeImpl();
943 } 943 }
944 } 944 }
945 945
946 // static 946 // static
947 void NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange() { 947 void NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange() {
948 if (g_network_change_notifier && 948 if (g_network_change_notifier &&
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 1052
1053 NetworkChangeNotifier::DisableForTest::~DisableForTest() { 1053 NetworkChangeNotifier::DisableForTest::~DisableForTest() {
1054 DCHECK(!g_network_change_notifier); 1054 DCHECK(!g_network_change_notifier);
1055 g_network_change_notifier = network_change_notifier_; 1055 g_network_change_notifier = network_change_notifier_;
1056 } 1056 }
1057 1057
1058 void NetworkChangeNotifier::DNSObserver::OnInitialDNSConfigRead() { 1058 void NetworkChangeNotifier::DNSObserver::OnInitialDNSConfigRead() {
1059 } 1059 }
1060 1060
1061 } // namespace net 1061 } // namespace net
OLDNEW
« no previous file with comments | « net/base/network_change_notifier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698