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

Side by Side Diff: chromeos/network/network_change_notifier_chromeos.cc

Issue 1306653003: Add connection type to NCN::MaxBandwidthChanged (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove extra space in comment Created 5 years, 3 months 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Re-evaluate connection state if we are offline since there is little 95 // Re-evaluate connection state if we are offline since there is little
96 // cost to doing so. Since we are in the context of a const method, 96 // cost to doing so. Since we are in the context of a const method,
97 // this is done through a closure that holds a non-const reference to 97 // this is done through a closure that holds a non-const reference to
98 // |this|, to allow PollForState() to modify our cached state. 98 // |this|, to allow PollForState() to modify our cached state.
99 // TODO(gauravsh): Figure out why we would have missed this notification. 99 // TODO(gauravsh): Figure out why we would have missed this notification.
100 if (connection_type_ == CONNECTION_NONE) 100 if (connection_type_ == CONNECTION_NONE)
101 task_runner_->PostTask(FROM_HERE, poll_callback_); 101 task_runner_->PostTask(FROM_HERE, poll_callback_);
102 return connection_type_; 102 return connection_type_;
103 } 103 }
104 104
105 double NetworkChangeNotifierChromeos::GetCurrentMaxBandwidth() const { 105 void NetworkChangeNotifierChromeos::GetCurrentMaxBandwidthAndConnectionType(
106 return max_bandwidth_mbps_; 106 double* max_bandwidth_mbps,
107 ConnectionType* connection_type) const {
108 *connection_type = connection_type_;
109 *max_bandwidth_mbps = max_bandwidth_mbps_;
107 } 110 }
108 111
109 void NetworkChangeNotifierChromeos::SuspendDone( 112 void NetworkChangeNotifierChromeos::SuspendDone(
110 const base::TimeDelta& sleep_duration) { 113 const base::TimeDelta& sleep_duration) {
111 // Force invalidation of network resources on resume. 114 // Force invalidation of network resources on resume.
112 NetworkChangeNotifier::NotifyObserversOfIPAddressChange(); 115 NetworkChangeNotifier::NotifyObserversOfIPAddressChange();
113 } 116 }
114 117
115 118
116 void NetworkChangeNotifierChromeos::DefaultNetworkChanged( 119 void NetworkChangeNotifierChromeos::DefaultNetworkChanged(
117 const chromeos::NetworkState* default_network) { 120 const chromeos::NetworkState* default_network) {
118 bool connection_type_changed = false; 121 bool connection_type_changed = false;
119 bool ip_address_changed = false; 122 bool ip_address_changed = false;
120 bool dns_changed = false; 123 bool dns_changed = false;
121 bool max_bandwidth_changed = false; 124 bool max_bandwidth_changed = false;
122 125
123 UpdateState(default_network, &connection_type_changed, &ip_address_changed, 126 UpdateState(default_network, &connection_type_changed, &ip_address_changed,
124 &dns_changed, &max_bandwidth_changed); 127 &dns_changed, &max_bandwidth_changed);
125 128
126 if (connection_type_changed) 129 if (connection_type_changed)
127 NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange(); 130 NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange();
128 if (ip_address_changed) 131 if (ip_address_changed)
129 NetworkChangeNotifier::NotifyObserversOfIPAddressChange(); 132 NetworkChangeNotifier::NotifyObserversOfIPAddressChange();
130 if (dns_changed) 133 if (dns_changed)
131 dns_config_service_->OnNetworkChange(); 134 dns_config_service_->OnNetworkChange();
132 if (max_bandwidth_changed) 135 if (max_bandwidth_changed || connection_type_changed) {
133 NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChange( 136 NetworkChangeNotifier::NotifyObserversOfMaxBandwidthChange(
134 max_bandwidth_mbps_); 137 max_bandwidth_mbps_, connection_type_);
138 }
135 } 139 }
136 140
137 void NetworkChangeNotifierChromeos::UpdateState( 141 void NetworkChangeNotifierChromeos::UpdateState(
138 const chromeos::NetworkState* default_network, 142 const chromeos::NetworkState* default_network,
139 bool* connection_type_changed, 143 bool* connection_type_changed,
140 bool* ip_address_changed, 144 bool* ip_address_changed,
141 bool* dns_changed, 145 bool* dns_changed,
142 bool* max_bandwidth_changed) { 146 bool* max_bandwidth_changed) {
143 *connection_type_changed = false; 147 *connection_type_changed = false;
144 *ip_address_changed = false; 148 *ip_address_changed = false;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // produce a single signal when switching between network connections. 303 // produce a single signal when switching between network connections.
300 params.ip_address_offline_delay_ = base::TimeDelta::FromMilliseconds(4000); 304 params.ip_address_offline_delay_ = base::TimeDelta::FromMilliseconds(4000);
301 params.ip_address_online_delay_ = base::TimeDelta::FromMilliseconds(1000); 305 params.ip_address_online_delay_ = base::TimeDelta::FromMilliseconds(1000);
302 params.connection_type_offline_delay_ = 306 params.connection_type_offline_delay_ =
303 base::TimeDelta::FromMilliseconds(500); 307 base::TimeDelta::FromMilliseconds(500);
304 params.connection_type_online_delay_ = base::TimeDelta::FromMilliseconds(500); 308 params.connection_type_online_delay_ = base::TimeDelta::FromMilliseconds(500);
305 return params; 309 return params;
306 } 310 }
307 311
308 } // namespace chromeos 312 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_change_notifier_chromeos.h ('k') | net/android/network_change_notifier_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698