| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/net/network_change_notifier_chromeos.h" | 5 #include "chrome/browser/chromeos/net/network_change_notifier_chromeos.h" |
| 6 | 6 |
| 7 #include "base/task.h" | 7 #include "base/task.h" |
| 8 #include "chrome/browser/chromeos/cros/cros_library.h" | 8 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 9 #include "content/browser/browser_thread.h" | 9 #include "content/browser/browser_thread.h" |
| 10 | 10 |
| 11 namespace chromeos { | 11 namespace chromeos { |
| 12 | 12 |
| 13 NetworkChangeNotifierChromeos::NetworkChangeNotifierChromeos() | 13 NetworkChangeNotifierChromeos::NetworkChangeNotifierChromeos() |
| 14 : has_active_network_(false), | 14 : has_active_network_(false), |
| 15 connection_state_(chromeos::STATE_UNKNOWN), | 15 connection_state_(chromeos::STATE_UNKNOWN) { |
| 16 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | |
| 17 | 16 |
| 18 chromeos::NetworkLibrary* lib = | 17 chromeos::NetworkLibrary* lib = |
| 19 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 18 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 20 lib->AddNetworkManagerObserver(this); | 19 lib->AddNetworkManagerObserver(this); |
| 21 | 20 |
| 22 chromeos::PowerLibrary* power = | 21 chromeos::PowerLibrary* power = |
| 23 chromeos::CrosLibrary::Get()->GetPowerLibrary(); | 22 chromeos::CrosLibrary::Get()->GetPowerLibrary(); |
| 24 power->AddObserver(this); | 23 power->AddObserver(this); |
| 25 } | 24 } |
| 26 | 25 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // c) switched to/from captive portal | 102 // c) switched to/from captive portal |
| 104 chromeos::ConnectionState new_connection_state = network->connection_state(); | 103 chromeos::ConnectionState new_connection_state = network->connection_state(); |
| 105 bool is_online = (new_connection_state == chromeos::STATE_ONLINE); | 104 bool is_online = (new_connection_state == chromeos::STATE_ONLINE); |
| 106 bool was_online = (connection_state_ == chromeos::STATE_ONLINE); | 105 bool was_online = (connection_state_ == chromeos::STATE_ONLINE); |
| 107 bool is_portal = (new_connection_state == chromeos::STATE_PORTAL); | 106 bool is_portal = (new_connection_state == chromeos::STATE_PORTAL); |
| 108 bool was_portal = (connection_state_ == chromeos::STATE_PORTAL); | 107 bool was_portal = (connection_state_ == chromeos::STATE_PORTAL); |
| 109 | 108 |
| 110 if (is_online != was_online || is_portal != was_portal) { | 109 if (is_online != was_online || is_portal != was_portal) { |
| 111 BrowserThread::PostTask( | 110 BrowserThread::PostTask( |
| 112 BrowserThread::IO, FROM_HERE, | 111 BrowserThread::IO, FROM_HERE, |
| 113 method_factory_.NewRunnableMethod( | 112 NewRunnableFunction( |
| 114 &NetworkChangeNotifierChromeos::NotifyObserversOfOnlineStateChange)); | 113 &NetworkChangeNotifierChromeos::NotifyObserversOfOnlineStateChange)); |
| 115 } | 114 } |
| 116 connection_state_ = new_connection_state; | 115 connection_state_ = new_connection_state; |
| 117 } | 116 } |
| 118 | 117 |
| 119 } // namespace net | 118 } // namespace net |
| OLD | NEW |