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

Side by Side Diff: net/android/network_change_notifier_android.cc

Issue 780293003: [NetInfo] Add MaxBandwidthChanged notification and implement on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@maxbandwidth_android
Patch Set: Don't monitor RSSI if there is no permission to act on it Created 6 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 //////////////////////////////////////////////////////////////////////////////// 5 ////////////////////////////////////////////////////////////////////////////////
6 // Threading considerations: 6 // Threading considerations:
7 // 7 //
8 // This class is designed to meet various threading guarantees starting from the 8 // This class is designed to meet various threading guarantees starting from the
9 // ones imposed by NetworkChangeNotifier: 9 // ones imposed by NetworkChangeNotifier:
10 // - The notifier can be constructed on any thread. 10 // - The notifier can be constructed on any thread.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 virtual void CleanUp() override { 91 virtual void CleanUp() override {
92 dns_config_service_.reset(); 92 dns_config_service_.reset();
93 } 93 }
94 94
95 static void NotifyNetworkChangeNotifierObservers() { 95 static void NotifyNetworkChangeNotifierObservers() {
96 NetworkChangeNotifier::NotifyObserversOfIPAddressChange(); 96 NetworkChangeNotifier::NotifyObserversOfIPAddressChange();
97 NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange(); 97 NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange();
98 } 98 }
99 99
100 static void NotifyMaxBandwidthChangedObservers(double max_bandwidth_mbps) {
pauljensen 2014/12/11 16:13:56 Can we remove this function? I don't see a reason
jkarlin 2014/12/15 19:43:55 Done.
101 NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChange(
102 max_bandwidth_mbps);
103 }
104
100 private: 105 private:
101 scoped_ptr<DnsConfigService> dns_config_service_; 106 scoped_ptr<DnsConfigService> dns_config_service_;
102 // Used to detect tunnel state changes. 107 // Used to detect tunnel state changes.
103 internal::AddressTrackerLinux address_tracker_; 108 internal::AddressTrackerLinux address_tracker_;
104 109
105 DISALLOW_COPY_AND_ASSIGN(DnsConfigServiceThread); 110 DISALLOW_COPY_AND_ASSIGN(DnsConfigServiceThread);
106 }; 111 };
107 112
108 NetworkChangeNotifierAndroid::~NetworkChangeNotifierAndroid() { 113 NetworkChangeNotifierAndroid::~NetworkChangeNotifierAndroid() {
109 delegate_->RemoveObserver(this); 114 delegate_->RemoveObserver(this);
110 } 115 }
111 116
112 NetworkChangeNotifier::ConnectionType 117 NetworkChangeNotifier::ConnectionType
113 NetworkChangeNotifierAndroid::GetCurrentConnectionType() const { 118 NetworkChangeNotifierAndroid::GetCurrentConnectionType() const {
114 return delegate_->GetCurrentConnectionType(); 119 return delegate_->GetCurrentConnectionType();
115 } 120 }
116 121
117 double NetworkChangeNotifierAndroid::GetCurrentMaxBandwidth() const { 122 double NetworkChangeNotifierAndroid::GetCurrentMaxBandwidth() const {
118 return delegate_->GetCurrentMaxBandwidth(); 123 return delegate_->GetCurrentMaxBandwidth();
119 } 124 }
120 125
121 void NetworkChangeNotifierAndroid::OnConnectionTypeChanged() { 126 void NetworkChangeNotifierAndroid::OnConnectionTypeChanged() {
122 DnsConfigServiceThread::NotifyNetworkChangeNotifierObservers(); 127 DnsConfigServiceThread::NotifyNetworkChangeNotifierObservers();
123 } 128 }
124 129
130 void NetworkChangeNotifierAndroid::OnMaxBandwidthChanged(
131 double max_bandwidth_mbps) {
132 DnsConfigServiceThread::NotifyMaxBandwidthChangedObservers(
133 max_bandwidth_mbps);
134 }
135
125 // static 136 // static
126 bool NetworkChangeNotifierAndroid::Register(JNIEnv* env) { 137 bool NetworkChangeNotifierAndroid::Register(JNIEnv* env) {
127 return NetworkChangeNotifierDelegateAndroid::Register(env); 138 return NetworkChangeNotifierDelegateAndroid::Register(env);
128 } 139 }
129 140
130 NetworkChangeNotifierAndroid::NetworkChangeNotifierAndroid( 141 NetworkChangeNotifierAndroid::NetworkChangeNotifierAndroid(
131 NetworkChangeNotifierDelegateAndroid* delegate) 142 NetworkChangeNotifierDelegateAndroid* delegate)
132 : NetworkChangeNotifier(NetworkChangeCalculatorParamsAndroid()), 143 : NetworkChangeNotifier(NetworkChangeCalculatorParamsAndroid()),
133 delegate_(delegate), 144 delegate_(delegate),
134 dns_config_service_thread_(new DnsConfigServiceThread()) { 145 dns_config_service_thread_(new DnsConfigServiceThread()) {
(...skipping 10 matching lines...) Expand all
145 // so delay IPAddressChanged so they get merged with the following 156 // so delay IPAddressChanged so they get merged with the following
146 // ConnectionTypeChanged signal. 157 // ConnectionTypeChanged signal.
147 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1); 158 params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1);
148 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1); 159 params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1);
149 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0); 160 params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0);
150 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0); 161 params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0);
151 return params; 162 return params;
152 } 163 }
153 164
154 } // namespace net 165 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698