OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/network_state_notifier.h" | 5 #include "chrome/browser/chromeos/network_state_notifier.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "chrome/browser/chrome_thread.h" | 9 #include "chrome/browser/chrome_thread.h" |
10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 NetworkStateNotifier::NetworkStateNotifier() | 33 NetworkStateNotifier::NetworkStateNotifier() |
34 : ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), | 34 : ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)), |
35 state_(RetrieveState()), | 35 state_(RetrieveState()), |
36 offline_start_time_(Time::Now()) { | 36 offline_start_time_(Time::Now()) { |
37 } | 37 } |
38 | 38 |
39 void NetworkStateNotifier::NetworkChanged(NetworkLibrary* cros) { | 39 void NetworkStateNotifier::NetworkChanged(NetworkLibrary* cros) { |
40 DCHECK(CrosLibrary::Get()->EnsureLoaded()); | 40 DCHECK(CrosLibrary::Get()->EnsureLoaded()); |
41 // Update the state 1 seconds later using UI thread. | 41 // Update the state 2 seconds later using UI thread. |
42 // See http://crosbug.com/4558 | 42 // See http://crosbug.com/4558 |
43 ChromeThread::PostDelayedTask( | 43 ChromeThread::PostDelayedTask( |
44 ChromeThread::UI, FROM_HERE, | 44 ChromeThread::UI, FROM_HERE, |
45 task_factory_.NewRunnableMethod( | 45 task_factory_.NewRunnableMethod( |
46 &NetworkStateNotifier::UpdateNetworkState, | 46 &NetworkStateNotifier::UpdateNetworkState, |
47 RetrieveState()), | 47 RetrieveState()), |
48 1000); | 48 2000); |
49 } | 49 } |
50 | 50 |
51 void NetworkStateNotifier::UpdateNetworkState( | 51 void NetworkStateNotifier::UpdateNetworkState( |
52 NetworkStateDetails::State new_state) { | 52 NetworkStateDetails::State new_state) { |
53 DLOG(INFO) << "UpdateNetworkState: new=" | 53 DLOG(INFO) << "UpdateNetworkState: new=" |
54 << new_state << ", old=" << state_; | 54 << new_state << ", old=" << state_; |
55 if (state_ == NetworkStateDetails::CONNECTED && | 55 if (state_ == NetworkStateDetails::CONNECTED && |
56 new_state != NetworkStateDetails::CONNECTED) { | 56 new_state != NetworkStateDetails::CONNECTED) { |
57 offline_start_time_ = Time::Now(); | 57 offline_start_time_ = Time::Now(); |
58 } | 58 } |
(...skipping 16 matching lines...) Expand all Loading... |
75 return NetworkStateDetails::CONNECTED; | 75 return NetworkStateDetails::CONNECTED; |
76 } else if (cros->Connecting()) { | 76 } else if (cros->Connecting()) { |
77 return NetworkStateDetails::CONNECTING; | 77 return NetworkStateDetails::CONNECTING; |
78 } else { | 78 } else { |
79 return NetworkStateDetails::DISCONNECTED; | 79 return NetworkStateDetails::DISCONNECTED; |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 | 83 |
84 } // namespace chromeos | 84 } // namespace chromeos |
OLD | NEW |