| 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" |
| 11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "net/base/net_errors.h" |
| 14 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
| 15 #include "net/base/network_change_notifier_factory.h" | 16 #include "net/base/network_change_notifier_factory.h" |
| 16 #include "net/base/network_interfaces.h" | 17 #include "net/base/network_interfaces.h" |
| 17 #include "net/dns/dns_config_service.h" | 18 #include "net/dns/dns_config_service.h" |
| 18 #include "net/url_request/url_request.h" | 19 #include "net/url_request/url_request.h" |
| 19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 20 | 21 |
| 21 #if defined(OS_ANDROID) | 22 #if defined(OS_ANDROID) |
| 22 #include "base/metrics/sparse_histogram.h" | 23 #include "base/metrics/sparse_histogram.h" |
| 23 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 // static | 646 // static |
| 646 NetworkChangeNotifier::ConnectionType | 647 NetworkChangeNotifier::ConnectionType |
| 647 NetworkChangeNotifier::GetNetworkConnectionType(NetworkHandle network) { | 648 NetworkChangeNotifier::GetNetworkConnectionType(NetworkHandle network) { |
| 648 return g_network_change_notifier | 649 return g_network_change_notifier |
| 649 ? g_network_change_notifier->GetCurrentNetworkConnectionType( | 650 ? g_network_change_notifier->GetCurrentNetworkConnectionType( |
| 650 network) | 651 network) |
| 651 : CONNECTION_UNKNOWN; | 652 : CONNECTION_UNKNOWN; |
| 652 } | 653 } |
| 653 | 654 |
| 654 // static | 655 // static |
| 655 NetworkChangeNotifier::NetworkHandle | 656 int NetworkChangeNotifier::GetDefaultNetwork( |
| 656 NetworkChangeNotifier::GetDefaultNetwork() { | 657 NetworkChangeNotifier::NetworkHandle* network) { |
| 657 return g_network_change_notifier | 658 return g_network_change_notifier |
| 658 ? g_network_change_notifier->GetCurrentDefaultNetwork() | 659 ? g_network_change_notifier->GetCurrentDefaultNetwork(network) |
| 659 : kInvalidNetworkHandle; | 660 : ERR_FAILED; |
| 660 } | 661 } |
| 661 | 662 |
| 662 // static | 663 // static |
| 663 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) { | 664 void NetworkChangeNotifier::GetDnsConfig(DnsConfig* config) { |
| 664 if (!g_network_change_notifier) { | 665 if (!g_network_change_notifier) { |
| 665 *config = DnsConfig(); | 666 *config = DnsConfig(); |
| 666 } else { | 667 } else { |
| 667 g_network_change_notifier->network_state_->GetDnsConfig(config); | 668 g_network_change_notifier->network_state_->GetDnsConfig(config); |
| 668 } | 669 } |
| 669 } | 670 } |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 NetworkList* network_list) const { | 983 NetworkList* network_list) const { |
| 983 network_list->clear(); | 984 network_list->clear(); |
| 984 } | 985 } |
| 985 | 986 |
| 986 NetworkChangeNotifier::ConnectionType | 987 NetworkChangeNotifier::ConnectionType |
| 987 NetworkChangeNotifier::GetCurrentNetworkConnectionType( | 988 NetworkChangeNotifier::GetCurrentNetworkConnectionType( |
| 988 NetworkHandle network) const { | 989 NetworkHandle network) const { |
| 989 return CONNECTION_UNKNOWN; | 990 return CONNECTION_UNKNOWN; |
| 990 } | 991 } |
| 991 | 992 |
| 992 NetworkChangeNotifier::NetworkHandle | 993 int NetworkChangeNotifier::GetCurrentDefaultNetwork( |
| 993 NetworkChangeNotifier::GetCurrentDefaultNetwork() const { | 994 NetworkChangeNotifier::NetworkHandle* network) const { |
| 994 return kInvalidNetworkHandle; | 995 return ERR_NOT_IMPLEMENTED; |
| 995 } | 996 } |
| 996 | 997 |
| 997 // static | 998 // static |
| 998 void NetworkChangeNotifier::NotifyObserversOfIPAddressChange() { | 999 void NetworkChangeNotifier::NotifyObserversOfIPAddressChange() { |
| 999 if (g_network_change_notifier && | 1000 if (g_network_change_notifier && |
| 1000 !NetworkChangeNotifier::test_notifications_only_) { | 1001 !NetworkChangeNotifier::test_notifications_only_) { |
| 1001 g_network_change_notifier->NotifyObserversOfIPAddressChangeImpl(); | 1002 g_network_change_notifier->NotifyObserversOfIPAddressChangeImpl(); |
| 1002 } | 1003 } |
| 1003 } | 1004 } |
| 1004 | 1005 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 | 1146 |
| 1146 NetworkChangeNotifier::DisableForTest::~DisableForTest() { | 1147 NetworkChangeNotifier::DisableForTest::~DisableForTest() { |
| 1147 DCHECK(!g_network_change_notifier); | 1148 DCHECK(!g_network_change_notifier); |
| 1148 g_network_change_notifier = network_change_notifier_; | 1149 g_network_change_notifier = network_change_notifier_; |
| 1149 } | 1150 } |
| 1150 | 1151 |
| 1151 void NetworkChangeNotifier::DNSObserver::OnInitialDNSConfigRead() { | 1152 void NetworkChangeNotifier::DNSObserver::OnInitialDNSConfigRead() { |
| 1152 } | 1153 } |
| 1153 | 1154 |
| 1154 } // namespace net | 1155 } // namespace net |
| OLD | NEW |