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

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

Issue 1454313002: Adding platform support check for NetworkObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@home
Patch Set: Addresses pauljensen's comments Created 5 years 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
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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 case SUBTYPE_NONE: 627 case SUBTYPE_NONE:
628 return 0.0; 628 return 0.0;
629 case SUBTYPE_OTHER: 629 case SUBTYPE_OTHER:
630 return std::numeric_limits<double>::infinity(); 630 return std::numeric_limits<double>::infinity();
631 } 631 }
632 NOTREACHED(); 632 NOTREACHED();
633 return std::numeric_limits<double>::infinity(); 633 return std::numeric_limits<double>::infinity();
634 } 634 }
635 635
636 // static 636 // static
637 bool NetworkChangeNotifier::AreNetworkHandlesSupported() {
638 if (g_network_change_notifier) {
639 return g_network_change_notifier->AreNetworkHandlesCurrentlySupported();
640 }
641 return false;
642 }
643
644 // static
637 void NetworkChangeNotifier::GetConnectedNetworks(NetworkList* network_list) { 645 void NetworkChangeNotifier::GetConnectedNetworks(NetworkList* network_list) {
646 DCHECK(AreNetworkHandlesSupported());
638 if (g_network_change_notifier) { 647 if (g_network_change_notifier) {
639 g_network_change_notifier->GetCurrentConnectedNetworks(network_list); 648 g_network_change_notifier->GetCurrentConnectedNetworks(network_list);
640 } else { 649 } else {
641 network_list->clear(); 650 network_list->clear();
642 } 651 }
643 } 652 }
644 653
645 // static 654 // static
646 NetworkChangeNotifier::ConnectionType 655 NetworkChangeNotifier::ConnectionType
647 NetworkChangeNotifier::GetNetworkConnectionType(NetworkHandle network) { 656 NetworkChangeNotifier::GetNetworkConnectionType(NetworkHandle network) {
657 DCHECK(AreNetworkHandlesSupported());
648 return g_network_change_notifier 658 return g_network_change_notifier
649 ? g_network_change_notifier->GetCurrentNetworkConnectionType( 659 ? g_network_change_notifier->GetCurrentNetworkConnectionType(
650 network) 660 network)
651 : CONNECTION_UNKNOWN; 661 : CONNECTION_UNKNOWN;
652 } 662 }
653 663
654 // static 664 // static
655 NetworkChangeNotifier::NetworkHandle 665 NetworkChangeNotifier::NetworkHandle
656 NetworkChangeNotifier::GetDefaultNetwork() { 666 NetworkChangeNotifier::GetDefaultNetwork() {
667 DCHECK(AreNetworkHandlesSupported());
657 return g_network_change_notifier 668 return g_network_change_notifier
658 ? g_network_change_notifier->GetCurrentDefaultNetwork() 669 ? g_network_change_notifier->GetCurrentDefaultNetwork()
659 : kInvalidNetworkHandle; 670 : kInvalidNetworkHandle;
660 } 671 }
661 672
662 // static 673 // static
663 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) { 674 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) {
664 if (!g_network_change_notifier) { 675 if (!g_network_change_notifier) {
665 *config = DnsConfig(); 676 *config = DnsConfig();
666 } else { 677 } else {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 } 841 }
831 842
832 void NetworkChangeNotifier::AddMaxBandwidthObserver( 843 void NetworkChangeNotifier::AddMaxBandwidthObserver(
833 MaxBandwidthObserver* observer) { 844 MaxBandwidthObserver* observer) {
834 if (g_network_change_notifier) { 845 if (g_network_change_notifier) {
835 g_network_change_notifier->max_bandwidth_observer_list_->AddObserver( 846 g_network_change_notifier->max_bandwidth_observer_list_->AddObserver(
836 observer); 847 observer);
837 } 848 }
838 } 849 }
839 850
840 void NetworkChangeNotifier::AddNetworkObserver(NetworkObserver* observer) { 851 void NetworkChangeNotifier::AddNetworkObserver(NetworkObserver* observer) {
pauljensen 2015/11/30 20:23:48 DCHECK(AreNetworkHandlesSupported());
Jana 2015/11/30 22:31:06 Done.
841 if (g_network_change_notifier) { 852 if (g_network_change_notifier) {
842 g_network_change_notifier->network_observer_list_->AddObserver(observer); 853 g_network_change_notifier->network_observer_list_->AddObserver(observer);
843 } 854 }
844 } 855 }
845 856
846 void NetworkChangeNotifier::RemoveIPAddressObserver( 857 void NetworkChangeNotifier::RemoveIPAddressObserver(
847 IPAddressObserver* observer) { 858 IPAddressObserver* observer) {
848 if (g_network_change_notifier) { 859 if (g_network_change_notifier) {
849 g_network_change_notifier->ip_address_observer_list_->RemoveObserver( 860 g_network_change_notifier->ip_address_observer_list_->RemoveObserver(
850 observer); 861 observer);
(...skipping 24 matching lines...) Expand all
875 } 886 }
876 887
877 void NetworkChangeNotifier::RemoveMaxBandwidthObserver( 888 void NetworkChangeNotifier::RemoveMaxBandwidthObserver(
878 MaxBandwidthObserver* observer) { 889 MaxBandwidthObserver* observer) {
879 if (g_network_change_notifier) { 890 if (g_network_change_notifier) {
880 g_network_change_notifier->max_bandwidth_observer_list_->RemoveObserver( 891 g_network_change_notifier->max_bandwidth_observer_list_->RemoveObserver(
881 observer); 892 observer);
882 } 893 }
883 } 894 }
884 895
885 void NetworkChangeNotifier::RemoveNetworkObserver(NetworkObserver* observer) { 896 void NetworkChangeNotifier::RemoveNetworkObserver(NetworkObserver* observer) {
pauljensen 2015/11/30 20:23:48 DCHECK(AreNetworkHandlesSupported());
Jana 2015/11/30 22:31:06 Done.
886 if (g_network_change_notifier) { 897 if (g_network_change_notifier) {
887 g_network_change_notifier->network_observer_list_->RemoveObserver(observer); 898 g_network_change_notifier->network_observer_list_->RemoveObserver(observer);
888 } 899 }
889 } 900 }
890 901
891 // static 902 // static
892 void NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests() { 903 void NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests() {
893 if (g_network_change_notifier) 904 if (g_network_change_notifier)
894 g_network_change_notifier->NotifyObserversOfIPAddressChangeImpl(); 905 g_network_change_notifier->NotifyObserversOfIPAddressChangeImpl();
895 } 906 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 // This default implementation conforms to the NetInfo V3 specification but 982 // This default implementation conforms to the NetInfo V3 specification but
972 // should be overridden to provide specific bandwidth data based on the 983 // should be overridden to provide specific bandwidth data based on the
973 // platform. 984 // platform.
974 *connection_type = GetCurrentConnectionType(); 985 *connection_type = GetCurrentConnectionType();
975 *max_bandwidth_mbps = 986 *max_bandwidth_mbps =
976 *connection_type == CONNECTION_NONE 987 *connection_type == CONNECTION_NONE
977 ? GetMaxBandwidthForConnectionSubtype(SUBTYPE_NONE) 988 ? GetMaxBandwidthForConnectionSubtype(SUBTYPE_NONE)
978 : GetMaxBandwidthForConnectionSubtype(SUBTYPE_UNKNOWN); 989 : GetMaxBandwidthForConnectionSubtype(SUBTYPE_UNKNOWN);
979 } 990 }
980 991
992 bool NetworkChangeNotifier::AreNetworkHandlesCurrentlySupported() const {
993 return false;
994 }
995
981 void NetworkChangeNotifier::GetCurrentConnectedNetworks( 996 void NetworkChangeNotifier::GetCurrentConnectedNetworks(
982 NetworkList* network_list) const { 997 NetworkList* network_list) const {
983 network_list->clear(); 998 network_list->clear();
984 } 999 }
985 1000
986 NetworkChangeNotifier::ConnectionType 1001 NetworkChangeNotifier::ConnectionType
987 NetworkChangeNotifier::GetCurrentNetworkConnectionType( 1002 NetworkChangeNotifier::GetCurrentNetworkConnectionType(
988 NetworkHandle network) const { 1003 NetworkHandle network) const {
989 return CONNECTION_UNKNOWN; 1004 return CONNECTION_UNKNOWN;
990 } 1005 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 1160
1146 NetworkChangeNotifier::DisableForTest::~DisableForTest() { 1161 NetworkChangeNotifier::DisableForTest::~DisableForTest() {
1147 DCHECK(!g_network_change_notifier); 1162 DCHECK(!g_network_change_notifier);
1148 g_network_change_notifier = network_change_notifier_; 1163 g_network_change_notifier = network_change_notifier_;
1149 } 1164 }
1150 1165
1151 void NetworkChangeNotifier::DNSObserver::OnInitialDNSConfigRead() { 1166 void NetworkChangeNotifier::DNSObserver::OnInitialDNSConfigRead() {
1152 } 1167 }
1153 1168
1154 } // namespace net 1169 } // namespace net
OLDNEW
« net/base/network_change_notifier.h ('K') | « net/base/network_change_notifier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698