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/net/network_change_notifier_chromeos.h" | 5 #include "chrome/browser/chromeos/net/network_change_notifier_chromeos.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/chromeos/cros/cros_library.h" | 8 #include "chrome/browser/chromeos/cros/cros_library.h" |
9 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 NetworkChangeNotifierChromeos::NetworkChangeNotifierChromeos() | 29 NetworkChangeNotifierChromeos::NetworkChangeNotifierChromeos() |
30 : has_active_network_(false), | 30 : has_active_network_(false), |
31 connection_state_(chromeos::STATE_UNKNOWN), | 31 connection_state_(chromeos::STATE_UNKNOWN), |
32 is_online_(false), | 32 is_online_(false), |
33 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 33 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
34 BrowserThread::PostDelayedTask( | 34 BrowserThread::PostDelayedTask( |
35 BrowserThread::UI, FROM_HERE, | 35 BrowserThread::UI, FROM_HERE, |
36 base::Bind( | 36 base::Bind( |
37 &NetworkChangeNotifierChromeos::UpdateInitialState, this), | 37 &NetworkChangeNotifierChromeos::UpdateInitialState, this), |
38 kInitialNotificationCheckDelayMS); | 38 base::TimeDelta::FromMilliseconds(kInitialNotificationCheckDelayMS)); |
39 } | 39 } |
40 | 40 |
41 NetworkChangeNotifierChromeos::~NetworkChangeNotifierChromeos() { | 41 NetworkChangeNotifierChromeos::~NetworkChangeNotifierChromeos() { |
42 } | 42 } |
43 | 43 |
44 void NetworkChangeNotifierChromeos::Init() { | 44 void NetworkChangeNotifierChromeos::Init() { |
45 chromeos::NetworkLibrary* network_library = | 45 chromeos::NetworkLibrary* network_library = |
46 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 46 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
47 network_library->AddNetworkManagerObserver(this); | 47 network_library->AddNetworkManagerObserver(this); |
48 | 48 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 189 } |
190 return; | 190 return; |
191 } | 191 } |
192 | 192 |
193 is_online_ = is_online; | 193 is_online_ = is_online; |
194 BrowserThread::PostDelayedTask( | 194 BrowserThread::PostDelayedTask( |
195 BrowserThread::UI, FROM_HERE, | 195 BrowserThread::UI, FROM_HERE, |
196 base::Bind( | 196 base::Bind( |
197 &NetworkChangeNotifierChromeos::ReportOnlineStateChangeOnUIThread, | 197 &NetworkChangeNotifierChromeos::ReportOnlineStateChangeOnUIThread, |
198 weak_factory_.GetWeakPtr()), | 198 weak_factory_.GetWeakPtr()), |
199 kOnlineNotificationDelayMS); | 199 base::TimeDelta::FromMilliseconds(kOnlineNotificationDelayMS)); |
200 } | 200 } |
201 | 201 |
202 void NetworkChangeNotifierChromeos::ReportOnlineStateChangeOnUIThread() { | 202 void NetworkChangeNotifierChromeos::ReportOnlineStateChangeOnUIThread() { |
203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
204 | 204 |
205 BrowserThread::PostTask( | 205 BrowserThread::PostTask( |
206 BrowserThread::IO, FROM_HERE, | 206 BrowserThread::IO, FROM_HERE, |
207 base::Bind( | 207 base::Bind( |
208 &NetworkChangeNotifierChromeos::NotifyObserversOfOnlineStateChange)); | 208 &NetworkChangeNotifierChromeos::NotifyObserversOfOnlineStateChange)); |
209 } | 209 } |
210 | 210 |
211 // static | 211 // static |
212 void NetworkChangeNotifierChromeos::UpdateInitialState( | 212 void NetworkChangeNotifierChromeos::UpdateInitialState( |
213 NetworkChangeNotifierChromeos* self) { | 213 NetworkChangeNotifierChromeos* self) { |
214 chromeos::NetworkLibrary* net = | 214 chromeos::NetworkLibrary* net = |
215 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 215 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
216 self->UpdateNetworkState(net); | 216 self->UpdateNetworkState(net); |
217 } | 217 } |
218 | 218 |
219 } // namespace chromeos | 219 } // namespace chromeos |
OLD | NEW |