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

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

Issue 12634019: NetworkChangeNotifierChromeos: Handle IPConfig property changes on the default network (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: AddServiceWithIPConfig Created 7 years, 9 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 | Annotate | Revision Log
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 "chromeos/dbus/dbus_thread_manager.h" 9 #include "chromeos/dbus/dbus_thread_manager.h"
10 #include "chromeos/network/network_change_notifier_chromeos.h" 10 #include "chromeos/network/network_change_notifier_chromeos.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 105
106 void NetworkChangeNotifierChromeos::UpdateState( 106 void NetworkChangeNotifierChromeos::UpdateState(
107 const chromeos::NetworkState* default_network, 107 const chromeos::NetworkState* default_network,
108 bool* connection_type_changed, 108 bool* connection_type_changed,
109 bool* ip_address_changed, 109 bool* ip_address_changed,
110 bool* dns_changed) { 110 bool* dns_changed) {
111 *connection_type_changed = false; 111 *connection_type_changed = false;
112 *ip_address_changed = false; 112 *ip_address_changed = false;
113 *dns_changed = false; 113 *dns_changed = false;
114 // TODO(gauravsh): DNS changes will be detected once ip config
115 // support is hooked into NetworkStateHandler. For now,
116 // we report a DNS change on changes to the default network (including
117 // loss).
118 if (!default_network || !default_network->IsConnectedState()) { 114 if (!default_network || !default_network->IsConnectedState()) {
119 // If we lost a default network, we must update our state and notify 115 // If we lost a default network, we must update our state and notify
120 // observers, otherwise we have nothing do. (Under normal circumstances, 116 // observers, otherwise we have nothing to do. (Under normal circumstances,
121 // we should never get duplicate no default network notifications). 117 // we should never get duplicate no default network notifications).
122 if (connection_type_ != CONNECTION_NONE) { 118 if (connection_type_ != CONNECTION_NONE) {
119 VLOG(1) << "Lost default network!";
123 *ip_address_changed = true; 120 *ip_address_changed = true;
124 *dns_changed = true; 121 *dns_changed = true;
125 *connection_type_changed = true; 122 *connection_type_changed = true;
126 connection_type_ = CONNECTION_NONE; 123 connection_type_ = CONNECTION_NONE;
127 service_path_.clear(); 124 service_path_.clear();
128 ip_address_.clear(); 125 ip_address_.clear();
126 dns_servers_.clear();
129 } 127 }
130 return; 128 return;
131 } 129 }
132 130
133 // We do have a default network and it is connected. 131 // We do have a default network and it is connected.
134 net::NetworkChangeNotifier::ConnectionType new_connection_type = 132 net::NetworkChangeNotifier::ConnectionType new_connection_type =
135 ConnectionTypeFromShill(default_network->type(), 133 ConnectionTypeFromShill(default_network->type(),
136 default_network->technology()); 134 default_network->technology());
137 if (new_connection_type != connection_type_) { 135 if (new_connection_type != connection_type_) {
138 VLOG(1) << "Connection type changed from " << connection_type_ << " -> " 136 VLOG(1) << "Connection type changed from " << connection_type_ << " -> "
139 << new_connection_type; 137 << new_connection_type;
140 *connection_type_changed = true; 138 *connection_type_changed = true;
139 }
140 if (default_network->path() != service_path_) {
141 VLOG(1) << "Service path changed from " << service_path_ << " -> "
142 << default_network->path();
143 // If we had a default network service change, network resources
144 // must always be invalidated.
145 *ip_address_changed = true;
141 *dns_changed = true; 146 *dns_changed = true;
142 } 147 }
143 if (default_network->path() != service_path_ || 148 if (default_network->ip_address() != ip_address_) {
144 default_network->ip_address() != ip_address_) {
145 VLOG(1) << "Service path changed from " << service_path_ << " -> "
146 << default_network->path();
147 VLOG(1) << "IP Address changed from " << ip_address_ << " -> " 149 VLOG(1) << "IP Address changed from " << ip_address_ << " -> "
148 << default_network->ip_address(); 150 << default_network->ip_address();
149 *ip_address_changed = true; 151 *ip_address_changed = true;
152 }
153 if (default_network->dns_servers() != dns_servers_) {
pneubeck (no reviews) 2013/03/28 10:37:54 Not for this CL, but maybe for future changes: If
gauravsh 2013/03/28 18:48:54 Perhaps. That'd be fine with the current implement
stevenjb 2013/03/28 19:27:13 I would prefer to avoid the bookkeeping overhead o
154 VLOG(1) <<"DNSservers changed from " << dns_servers_ << " -> "
155 << default_network->dns_servers();
150 *dns_changed = true; 156 *dns_changed = true;
151 } 157 }
158
152 connection_type_ = new_connection_type; 159 connection_type_ = new_connection_type;
153 service_path_ = default_network->path(); 160 service_path_ = default_network->path();
154 ip_address_ = default_network->ip_address(); 161 ip_address_ = default_network->ip_address();
162 dns_servers_ = default_network->dns_servers();
155 } 163 }
156 164
157 // static 165 // static
158 net::NetworkChangeNotifier::ConnectionType 166 net::NetworkChangeNotifier::ConnectionType
159 NetworkChangeNotifierChromeos::ConnectionTypeFromShill( 167 NetworkChangeNotifierChromeos::ConnectionTypeFromShill(
160 const std::string& type, const std::string& technology) { 168 const std::string& type, const std::string& technology) {
161 if (type == flimflam::kTypeEthernet) 169 if (type == flimflam::kTypeEthernet)
162 return CONNECTION_ETHERNET; 170 return CONNECTION_ETHERNET;
163 else if (type == flimflam::kTypeWifi) 171 else if (type == flimflam::kTypeWifi)
164 return CONNECTION_WIFI; 172 return CONNECTION_WIFI;
(...skipping 27 matching lines...) Expand all
192 params.ip_address_offline_delay_ = base::TimeDelta::FromMilliseconds(4000); 200 params.ip_address_offline_delay_ = base::TimeDelta::FromMilliseconds(4000);
193 params.ip_address_online_delay_ = base::TimeDelta::FromMilliseconds(1000); 201 params.ip_address_online_delay_ = base::TimeDelta::FromMilliseconds(1000);
194 params.connection_type_offline_delay_ = 202 params.connection_type_offline_delay_ =
195 base::TimeDelta::FromMilliseconds(500); 203 base::TimeDelta::FromMilliseconds(500);
196 params.connection_type_online_delay_ = base::TimeDelta::FromMilliseconds(500); 204 params.connection_type_online_delay_ = base::TimeDelta::FromMilliseconds(500);
197 return params; 205 return params;
198 } 206 }
199 207
200 } // namespace chromeos 208 } // namespace chromeos
201 209
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698