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 "chrome/browser/chromeos/cros/network_library.h" | 5 #include "chrome/browser/chromeos/cros/network_library.h" |
6 | 6 |
7 #include <dbus/dbus-glib.h> | 7 #include <dbus/dbus-glib.h> |
8 | 8 |
9 #include "base/i18n/icu_encoding_detection.h" | 9 #include "base/i18n/icu_encoding_detection.h" |
10 #include "base/i18n/icu_string_conversions.h" | 10 #include "base/i18n/icu_string_conversions.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 return new Network("fake_service_path", type); | 281 return new Network("fake_service_path", type); |
282 } | 282 } |
283 | 283 |
284 void Network::SetState(ConnectionState new_state) { | 284 void Network::SetState(ConnectionState new_state) { |
285 if (new_state == state_) | 285 if (new_state == state_) |
286 return; | 286 return; |
287 if (state_ == STATE_CONNECT_REQUESTED && new_state == STATE_IDLE) { | 287 if (state_ == STATE_CONNECT_REQUESTED && new_state == STATE_IDLE) { |
288 // CONNECT_REQUESTED is set internally. Shill/flimflam do not update the | 288 // CONNECT_REQUESTED is set internally. Shill/flimflam do not update the |
289 // state immediately, so ignore any Idle state updates sent while a | 289 // state immediately, so ignore any Idle state updates sent while a |
290 // connection attempt is in progress. | 290 // connection attempt is in progress. |
| 291 VLOG(2) << "Ignoring idle state change after connection request."; |
291 return; | 292 return; |
292 } | 293 } |
293 ConnectionState old_state = state_; | 294 ConnectionState old_state = state_; |
| 295 VLOG(2) << "Entering new state: " << ConnectionStateString(new_state); |
294 state_ = new_state; | 296 state_ = new_state; |
295 if (!IsConnectingState(new_state)) | 297 if (!IsConnectingState(new_state)) |
296 set_connection_started(false); | 298 set_connection_started(false); |
297 if (new_state == STATE_FAILURE) { | 299 if (new_state == STATE_FAILURE) { |
| 300 VLOG(2) << "Detected Failure state."; |
298 if (old_state != STATE_UNKNOWN && | 301 if (old_state != STATE_UNKNOWN && |
299 old_state != STATE_IDLE) { | 302 old_state != STATE_IDLE) { |
300 // New failure, the user needs to be notified. | 303 // New failure, the user needs to be notified. |
301 // Transition STATE_IDLE -> STATE_FAILURE sometimes happens on resume | 304 // Transition STATE_IDLE -> STATE_FAILURE sometimes happens on resume |
302 // but is not an actual failure as network device is not ready yet. | 305 // but is not an actual failure as network device is not ready yet. |
303 notify_failure_ = true; | 306 notify_failure_ = true; |
304 // Normally error_ should be set, but if it is not we need to set it to | 307 // Normally error_ should be set, but if it is not we need to set it to |
305 // something here so that the retry logic will be triggered. | 308 // something here so that the retry logic will be triggered. |
306 if (error_ == ERROR_NO_ERROR) | 309 if (error_ == ERROR_NO_ERROR) { |
| 310 VLOG(2) << "Detected NO_ERROR error state. Setting to UNKNOWN."; |
307 error_ = ERROR_UNKNOWN; | 311 error_ = ERROR_UNKNOWN; |
| 312 } |
308 } | 313 } |
309 } else { | 314 } else { |
310 // State changed, so refresh IP address. | 315 // State changed, so refresh IP address. |
311 // Note: blocking DBus call. TODO(stevenjb): refactor this. | 316 // Note: blocking DBus call. TODO(stevenjb): refactor this. |
312 InitIPAddress(); | 317 InitIPAddress(); |
313 } | 318 } |
314 VLOG(1) << name() << ".State [" << service_path() << "]: " << GetStateString() | 319 VLOG(1) << name() << ".State [" << service_path() << "]: " << GetStateString() |
315 << " (was: " << ConnectionStateString(old_state) << ")"; | 320 << " (was: " << ConnectionStateString(old_state) << ")"; |
316 } | 321 } |
317 | 322 |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 NetworkLibrary* impl; | 1317 NetworkLibrary* impl; |
1313 if (stub) | 1318 if (stub) |
1314 impl = new NetworkLibraryImplStub(); | 1319 impl = new NetworkLibraryImplStub(); |
1315 else | 1320 else |
1316 impl = new NetworkLibraryImplCros(); | 1321 impl = new NetworkLibraryImplCros(); |
1317 impl->Init(); | 1322 impl->Init(); |
1318 return impl; | 1323 return impl; |
1319 } | 1324 } |
1320 | 1325 |
1321 } // namespace chromeos | 1326 } // namespace chromeos |
OLD | NEW |