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/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
11 #include "chrome/common/notification_service.h" | 11 #include "chrome/common/notification_service.h" |
12 #include "chrome/common/notification_type.h" | 12 #include "chrome/common/notification_type.h" |
13 | 13 |
14 namespace chromeos { | 14 namespace chromeos { |
15 | 15 |
16 using base::Time; | 16 using base::Time; |
17 using base::TimeDelta; | 17 using base::TimeDelta; |
18 | 18 |
19 // static | 19 // static |
20 NetworkStateNotifier* NetworkStateNotifier::Get() { | 20 NetworkStateNotifier* NetworkStateNotifier::GetInstance() { |
21 return Singleton<NetworkStateNotifier>::get(); | 21 return Singleton<NetworkStateNotifier>::get(); |
22 } | 22 } |
23 | 23 |
24 // static | 24 // static |
25 TimeDelta NetworkStateNotifier::GetOfflineDuration() { | 25 TimeDelta NetworkStateNotifier::GetOfflineDuration() { |
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
27 // TODO(oshima): make this instance method so that | 27 // TODO(oshima): make this instance method so that |
28 // we can mock this for ui_tests. | 28 // we can mock this for ui_tests. |
29 // http://crbug.com/4825 . | 29 // http://crbug.com/4825 . |
30 return base::Time::Now() - Get()->offline_start_time_; | 30 return base::Time::Now() - GetInstance()->offline_start_time_; |
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 // Note that this gets added as a NetworkManagerObserver | 37 // Note that this gets added as a NetworkManagerObserver |
38 // in browser_init.cc | 38 // in browser_init.cc |
39 } | 39 } |
40 | 40 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 return NetworkStateDetails::CONNECTED; | 81 return NetworkStateDetails::CONNECTED; |
82 } else if (cros->Connecting()) { | 82 } else if (cros->Connecting()) { |
83 return NetworkStateDetails::CONNECTING; | 83 return NetworkStateDetails::CONNECTING; |
84 } else { | 84 } else { |
85 return NetworkStateDetails::DISCONNECTED; | 85 return NetworkStateDetails::DISCONNECTED; |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 | 89 |
90 } // namespace chromeos | 90 } // namespace chromeos |
OLD | NEW |