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 <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 Loading... | |
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_) { | |
154 VLOG(1) <<"DNS servers changed. New DNS servers are:"; | |
155 for (size_t i = 0; i < default_network->dns_servers().size(); ++i) | |
156 VLOG(1) << default_network->dns_servers()[i] << ","; | |
stevenjb
2013/03/29 00:21:36
Hey look:
base::JoinString(default_network->dns_se
gauravsh
2013/03/29 00:41:50
Done.
| |
150 *dns_changed = true; | 157 *dns_changed = true; |
151 } | 158 } |
159 | |
152 connection_type_ = new_connection_type; | 160 connection_type_ = new_connection_type; |
153 service_path_ = default_network->path(); | 161 service_path_ = default_network->path(); |
154 ip_address_ = default_network->ip_address(); | 162 ip_address_ = default_network->ip_address(); |
163 dns_servers_ = default_network->dns_servers(); | |
155 } | 164 } |
156 | 165 |
157 // static | 166 // static |
158 net::NetworkChangeNotifier::ConnectionType | 167 net::NetworkChangeNotifier::ConnectionType |
159 NetworkChangeNotifierChromeos::ConnectionTypeFromShill( | 168 NetworkChangeNotifierChromeos::ConnectionTypeFromShill( |
160 const std::string& type, const std::string& technology) { | 169 const std::string& type, const std::string& technology) { |
161 if (type == flimflam::kTypeEthernet) | 170 if (type == flimflam::kTypeEthernet) |
162 return CONNECTION_ETHERNET; | 171 return CONNECTION_ETHERNET; |
163 else if (type == flimflam::kTypeWifi) | 172 else if (type == flimflam::kTypeWifi) |
164 return CONNECTION_WIFI; | 173 return CONNECTION_WIFI; |
(...skipping 27 matching lines...) Expand all Loading... | |
192 params.ip_address_offline_delay_ = base::TimeDelta::FromMilliseconds(4000); | 201 params.ip_address_offline_delay_ = base::TimeDelta::FromMilliseconds(4000); |
193 params.ip_address_online_delay_ = base::TimeDelta::FromMilliseconds(1000); | 202 params.ip_address_online_delay_ = base::TimeDelta::FromMilliseconds(1000); |
194 params.connection_type_offline_delay_ = | 203 params.connection_type_offline_delay_ = |
195 base::TimeDelta::FromMilliseconds(500); | 204 base::TimeDelta::FromMilliseconds(500); |
196 params.connection_type_online_delay_ = base::TimeDelta::FromMilliseconds(500); | 205 params.connection_type_online_delay_ = base::TimeDelta::FromMilliseconds(500); |
197 return params; | 206 return params; |
198 } | 207 } |
199 | 208 |
200 } // namespace chromeos | 209 } // namespace chromeos |
201 | 210 |
OLD | NEW |