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 <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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 } | 542 } |
543 | 543 |
544 // static | 544 // static |
545 double NetworkChangeNotifier::GetMaxBandwidth() { | 545 double NetworkChangeNotifier::GetMaxBandwidth() { |
546 return g_network_change_notifier ? | 546 return g_network_change_notifier ? |
547 g_network_change_notifier->GetCurrentMaxBandwidth() : | 547 g_network_change_notifier->GetCurrentMaxBandwidth() : |
548 std::numeric_limits<double>::infinity(); | 548 std::numeric_limits<double>::infinity(); |
549 } | 549 } |
550 | 550 |
551 // static | 551 // static |
| 552 double NetworkChangeNotifier::GetMaxBandwidthForConnectionSubtype( |
| 553 ConnectionSubtype subtype) { |
| 554 switch (subtype) { |
| 555 case SUBTYPE_GSM: |
| 556 return 0.01; |
| 557 case SUBTYPE_IDEN: |
| 558 return 0.064; |
| 559 case SUBTYPE_CDMA: |
| 560 return 0.115; |
| 561 case SUBTYPE_1XRTT: |
| 562 return 0.153; |
| 563 case SUBTYPE_GPRS: |
| 564 return 0.237; |
| 565 case SUBTYPE_EDGE: |
| 566 return 0.384; |
| 567 case SUBTYPE_UMTS: |
| 568 return 2.0; |
| 569 case SUBTYPE_EVDO_REV_0: |
| 570 return 2.46; |
| 571 case SUBTYPE_EVDO_REV_A: |
| 572 return 3.1; |
| 573 case SUBTYPE_HSPA: |
| 574 return 3.6; |
| 575 case SUBTYPE_EVDO_REV_B: |
| 576 return 14.7; |
| 577 case SUBTYPE_HSDPA: |
| 578 return 14.3; |
| 579 case SUBTYPE_HSUPA: |
| 580 return 14.4; |
| 581 case SUBTYPE_EHRPD: |
| 582 return 21.0; |
| 583 case SUBTYPE_HSPAP: |
| 584 return 42.0; |
| 585 case SUBTYPE_LTE: |
| 586 return 100.0; |
| 587 case SUBTYPE_LTE_ADVANCED: |
| 588 return 100.0; |
| 589 case SUBTYPE_BLUETOOTH_1_2: |
| 590 return 1.0; |
| 591 case SUBTYPE_BLUETOOTH_2_1: |
| 592 return 3.0; |
| 593 case SUBTYPE_BLUETOOTH_3_0: |
| 594 return 24.0; |
| 595 case SUBTYPE_BLUETOOTH_4_0: |
| 596 return 1.0; |
| 597 case SUBTYPE_ETHERNET: |
| 598 return 10.0; |
| 599 case SUBTYPE_FAST_ETHERNET: |
| 600 return 100.0; |
| 601 case SUBTYPE_GIGABIT_ETHERNET: |
| 602 return 1000.0; |
| 603 case SUBTYPE_10_GIGABIT_ETHERNET: |
| 604 return 10000.0; |
| 605 case SUBTYPE_WIFI_B: |
| 606 return 11.0; |
| 607 case SUBTYPE_WIFI_G: |
| 608 return 54.0; |
| 609 case SUBTYPE_WIFI_N: |
| 610 return 600.0; |
| 611 case SUBTYPE_WIFI_AC: |
| 612 return 1300.0; |
| 613 case SUBTYPE_WIFI_AD: |
| 614 return 7000.0; |
| 615 case SUBTYPE_UNKNOWN: |
| 616 return std::numeric_limits<double>::infinity(); |
| 617 case SUBTYPE_NONE: |
| 618 return 0.0; |
| 619 case SUBTYPE_OTHER: |
| 620 return std::numeric_limits<double>::infinity(); |
| 621 } |
| 622 NOTREACHED(); |
| 623 return std::numeric_limits<double>::infinity(); |
| 624 } |
| 625 |
| 626 // static |
552 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) { | 627 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) { |
553 if (!g_network_change_notifier) { | 628 if (!g_network_change_notifier) { |
554 *config = DnsConfig(); | 629 *config = DnsConfig(); |
555 } else { | 630 } else { |
556 g_network_change_notifier->network_state_->GetDnsConfig(config); | 631 g_network_change_notifier->network_state_->GetDnsConfig(config); |
557 } | 632 } |
558 } | 633 } |
559 | 634 |
560 // static | 635 // static |
561 const char* NetworkChangeNotifier::ConnectionTypeToString( | 636 const char* NetworkChangeNotifier::ConnectionTypeToString( |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 double NetworkChangeNotifier::GetCurrentMaxBandwidth() const { | 917 double NetworkChangeNotifier::GetCurrentMaxBandwidth() const { |
843 // This default implementation conforms to the NetInfo V3 specification but | 918 // This default implementation conforms to the NetInfo V3 specification but |
844 // should be overridden to provide specific bandwidth data based on the | 919 // should be overridden to provide specific bandwidth data based on the |
845 // platform. | 920 // platform. |
846 if (GetCurrentConnectionType() == CONNECTION_NONE) | 921 if (GetCurrentConnectionType() == CONNECTION_NONE) |
847 return 0.0; | 922 return 0.0; |
848 return std::numeric_limits<double>::infinity(); | 923 return std::numeric_limits<double>::infinity(); |
849 } | 924 } |
850 | 925 |
851 // static | 926 // static |
852 double NetworkChangeNotifier::GetMaxBandwidthForConnectionSubtype( | |
853 ConnectionSubtype subtype) { | |
854 switch (subtype) { | |
855 case SUBTYPE_GSM: | |
856 return 0.01; | |
857 case SUBTYPE_IDEN: | |
858 return 0.064; | |
859 case SUBTYPE_CDMA: | |
860 return 0.115; | |
861 case SUBTYPE_1XRTT: | |
862 return 0.153; | |
863 case SUBTYPE_GPRS: | |
864 return 0.237; | |
865 case SUBTYPE_EDGE: | |
866 return 0.384; | |
867 case SUBTYPE_UMTS: | |
868 return 2.0; | |
869 case SUBTYPE_EVDO_REV_0: | |
870 return 2.46; | |
871 case SUBTYPE_EVDO_REV_A: | |
872 return 3.1; | |
873 case SUBTYPE_HSPA: | |
874 return 3.6; | |
875 case SUBTYPE_EVDO_REV_B: | |
876 return 14.7; | |
877 case SUBTYPE_HSDPA: | |
878 return 14.3; | |
879 case SUBTYPE_HSUPA: | |
880 return 14.4; | |
881 case SUBTYPE_EHRPD: | |
882 return 21.0; | |
883 case SUBTYPE_HSPAP: | |
884 return 42.0; | |
885 case SUBTYPE_LTE: | |
886 return 100.0; | |
887 case SUBTYPE_LTE_ADVANCED: | |
888 return 100.0; | |
889 case SUBTYPE_BLUETOOTH_1_2: | |
890 return 1.0; | |
891 case SUBTYPE_BLUETOOTH_2_1: | |
892 return 3.0; | |
893 case SUBTYPE_BLUETOOTH_3_0: | |
894 return 24.0; | |
895 case SUBTYPE_BLUETOOTH_4_0: | |
896 return 1.0; | |
897 case SUBTYPE_ETHERNET: | |
898 return 10.0; | |
899 case SUBTYPE_FAST_ETHERNET: | |
900 return 100.0; | |
901 case SUBTYPE_GIGABIT_ETHERNET: | |
902 return 1000.0; | |
903 case SUBTYPE_10_GIGABIT_ETHERNET: | |
904 return 10000.0; | |
905 case SUBTYPE_WIFI_B: | |
906 return 11.0; | |
907 case SUBTYPE_WIFI_G: | |
908 return 54.0; | |
909 case SUBTYPE_WIFI_N: | |
910 return 600.0; | |
911 case SUBTYPE_WIFI_AC: | |
912 return 1300.0; | |
913 case SUBTYPE_WIFI_AD: | |
914 return 7000.0; | |
915 case SUBTYPE_UNKNOWN: | |
916 return std::numeric_limits<double>::infinity(); | |
917 case SUBTYPE_NONE: | |
918 return 0.0; | |
919 case SUBTYPE_OTHER: | |
920 return std::numeric_limits<double>::infinity(); | |
921 } | |
922 NOTREACHED(); | |
923 return std::numeric_limits<double>::infinity(); | |
924 } | |
925 | |
926 // static | |
927 void NetworkChangeNotifier::NotifyObserversOfIPAddressChange() { | 927 void NetworkChangeNotifier::NotifyObserversOfIPAddressChange() { |
928 if (g_network_change_notifier && | 928 if (g_network_change_notifier && |
929 !NetworkChangeNotifier::test_notifications_only_) { | 929 !NetworkChangeNotifier::test_notifications_only_) { |
930 g_network_change_notifier->NotifyObserversOfIPAddressChangeImpl(); | 930 g_network_change_notifier->NotifyObserversOfIPAddressChangeImpl(); |
931 } | 931 } |
932 } | 932 } |
933 | 933 |
934 // static | 934 // static |
935 void NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange() { | 935 void NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange() { |
936 if (g_network_change_notifier && | 936 if (g_network_change_notifier && |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 | 1040 |
1041 NetworkChangeNotifier::DisableForTest::~DisableForTest() { | 1041 NetworkChangeNotifier::DisableForTest::~DisableForTest() { |
1042 DCHECK(!g_network_change_notifier); | 1042 DCHECK(!g_network_change_notifier); |
1043 g_network_change_notifier = network_change_notifier_; | 1043 g_network_change_notifier = network_change_notifier_; |
1044 } | 1044 } |
1045 | 1045 |
1046 void NetworkChangeNotifier::DNSObserver::OnInitialDNSConfigRead() { | 1046 void NetworkChangeNotifier::DNSObserver::OnInitialDNSConfigRead() { |
1047 } | 1047 } |
1048 | 1048 |
1049 } // namespace net | 1049 } // namespace net |
OLD | NEW |