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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 g_network_change_notifier->NotifyObserversOfNetworkChangeImpl(type); | 785 g_network_change_notifier->NotifyObserversOfNetworkChangeImpl(type); |
786 } | 786 } |
787 | 787 |
788 // static | 788 // static |
789 void NetworkChangeNotifier::NotifyObserversOfInitialDNSConfigReadForTests() { | 789 void NetworkChangeNotifier::NotifyObserversOfInitialDNSConfigReadForTests() { |
790 if (g_network_change_notifier) | 790 if (g_network_change_notifier) |
791 g_network_change_notifier->NotifyObserversOfInitialDNSConfigReadImpl(); | 791 g_network_change_notifier->NotifyObserversOfInitialDNSConfigReadImpl(); |
792 } | 792 } |
793 | 793 |
794 // static | 794 // static |
| 795 void NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChangeForTests( |
| 796 ConnectionType type, |
| 797 double max_bandwidth) { |
| 798 if (g_network_change_notifier) |
| 799 g_network_change_notifier->NotifyObserversOfMaxBandwidthChangeImpl( |
| 800 type, max_bandwidth); |
| 801 } |
| 802 |
| 803 // static |
795 void NetworkChangeNotifier::SetTestNotificationsOnly(bool test_only) { | 804 void NetworkChangeNotifier::SetTestNotificationsOnly(bool test_only) { |
796 DCHECK(!g_network_change_notifier); | 805 DCHECK(!g_network_change_notifier); |
797 NetworkChangeNotifier::test_notifications_only_ = test_only; | 806 NetworkChangeNotifier::test_notifications_only_ = test_only; |
798 } | 807 } |
799 | 808 |
800 NetworkChangeNotifier::NetworkChangeNotifier( | 809 NetworkChangeNotifier::NetworkChangeNotifier( |
801 const NetworkChangeCalculatorParams& params | 810 const NetworkChangeCalculatorParams& params |
802 /*= NetworkChangeCalculatorParams()*/) | 811 /*= NetworkChangeCalculatorParams()*/) |
803 : ip_address_observer_list_( | 812 : ip_address_observer_list_( |
804 new base::ObserverListThreadSafe<IPAddressObserver>( | 813 new base::ObserverListThreadSafe<IPAddressObserver>( |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 void NetworkChangeNotifier::NotifyObserversOfNetworkChange( | 944 void NetworkChangeNotifier::NotifyObserversOfNetworkChange( |
936 ConnectionType type) { | 945 ConnectionType type) { |
937 if (g_network_change_notifier && | 946 if (g_network_change_notifier && |
938 !NetworkChangeNotifier::test_notifications_only_) { | 947 !NetworkChangeNotifier::test_notifications_only_) { |
939 g_network_change_notifier->NotifyObserversOfNetworkChangeImpl(type); | 948 g_network_change_notifier->NotifyObserversOfNetworkChangeImpl(type); |
940 } | 949 } |
941 } | 950 } |
942 | 951 |
943 // static | 952 // static |
944 void NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChange( | 953 void NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChange( |
| 954 ConnectionType type, |
945 double max_bandwidth_mbps) { | 955 double max_bandwidth_mbps) { |
946 if (g_network_change_notifier && | 956 if (g_network_change_notifier && |
947 !NetworkChangeNotifier::test_notifications_only_) { | 957 !NetworkChangeNotifier::test_notifications_only_) { |
948 g_network_change_notifier->NotifyObserversOfMaxBandwidthChangeImpl( | 958 g_network_change_notifier->NotifyObserversOfMaxBandwidthChangeImpl( |
949 max_bandwidth_mbps); | 959 type, max_bandwidth_mbps); |
950 } | 960 } |
951 } | 961 } |
952 | 962 |
953 // static | 963 // static |
954 void NetworkChangeNotifier::NotifyObserversOfDNSChange() { | 964 void NetworkChangeNotifier::NotifyObserversOfDNSChange() { |
955 if (g_network_change_notifier && | 965 if (g_network_change_notifier && |
956 !NetworkChangeNotifier::test_notifications_only_) { | 966 !NetworkChangeNotifier::test_notifications_only_) { |
957 g_network_change_notifier->NotifyObserversOfDNSChangeImpl(); | 967 g_network_change_notifier->NotifyObserversOfDNSChangeImpl(); |
958 } | 968 } |
959 } | 969 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 void NetworkChangeNotifier::NotifyObserversOfDNSChangeImpl() { | 1018 void NetworkChangeNotifier::NotifyObserversOfDNSChangeImpl() { |
1009 resolver_state_observer_list_->Notify(FROM_HERE, &DNSObserver::OnDNSChanged); | 1019 resolver_state_observer_list_->Notify(FROM_HERE, &DNSObserver::OnDNSChanged); |
1010 } | 1020 } |
1011 | 1021 |
1012 void NetworkChangeNotifier::NotifyObserversOfInitialDNSConfigReadImpl() { | 1022 void NetworkChangeNotifier::NotifyObserversOfInitialDNSConfigReadImpl() { |
1013 resolver_state_observer_list_->Notify(FROM_HERE, | 1023 resolver_state_observer_list_->Notify(FROM_HERE, |
1014 &DNSObserver::OnInitialDNSConfigRead); | 1024 &DNSObserver::OnInitialDNSConfigRead); |
1015 } | 1025 } |
1016 | 1026 |
1017 void NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChangeImpl( | 1027 void NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChangeImpl( |
| 1028 ConnectionType type, |
1018 double max_bandwidth_mbps) { | 1029 double max_bandwidth_mbps) { |
1019 max_bandwidth_observer_list_->Notify( | 1030 max_bandwidth_observer_list_->Notify( |
1020 FROM_HERE, &MaxBandwidthObserver::OnMaxBandwidthChanged, | 1031 FROM_HERE, &MaxBandwidthObserver::OnMaxBandwidthChanged, type, |
1021 max_bandwidth_mbps); | 1032 max_bandwidth_mbps); |
1022 } | 1033 } |
1023 | 1034 |
1024 NetworkChangeNotifier::DisableForTest::DisableForTest() | 1035 NetworkChangeNotifier::DisableForTest::DisableForTest() |
1025 : network_change_notifier_(g_network_change_notifier) { | 1036 : network_change_notifier_(g_network_change_notifier) { |
1026 DCHECK(g_network_change_notifier); | 1037 DCHECK(g_network_change_notifier); |
1027 g_network_change_notifier = NULL; | 1038 g_network_change_notifier = NULL; |
1028 } | 1039 } |
1029 | 1040 |
1030 NetworkChangeNotifier::DisableForTest::~DisableForTest() { | 1041 NetworkChangeNotifier::DisableForTest::~DisableForTest() { |
1031 DCHECK(!g_network_change_notifier); | 1042 DCHECK(!g_network_change_notifier); |
1032 g_network_change_notifier = network_change_notifier_; | 1043 g_network_change_notifier = network_change_notifier_; |
1033 } | 1044 } |
1034 | 1045 |
1035 void NetworkChangeNotifier::DNSObserver::OnInitialDNSConfigRead() { | 1046 void NetworkChangeNotifier::DNSObserver::OnInitialDNSConfigRead() { |
1036 } | 1047 } |
1037 | 1048 |
1038 } // namespace net | 1049 } // namespace net |
OLD | NEW |