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 #ifndef CHROME_BROWSER_CHROMEOS_NETWORK_STATE_NOTIFIER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NETWORK_STATE_NOTIFIER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_NETWORK_STATE_NOTIFIER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NETWORK_STATE_NOTIFIER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/chromeos/cros/network_library.h" | 9 #include "chrome/browser/chromeos/cros/network_library.h" |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // when network is connected. | 54 // when network is connected. |
55 static base::TimeDelta GetOfflineDuration(); | 55 static base::TimeDelta GetOfflineDuration(); |
56 | 56 |
57 // Returns true if the network is connected. | 57 // Returns true if the network is connected. |
58 static bool is_connected() { | 58 static bool is_connected() { |
59 return Get()->state_ == NetworkStateDetails::CONNECTED; | 59 return Get()->state_ == NetworkStateDetails::CONNECTED; |
60 } | 60 } |
61 | 61 |
62 // NetworkLibrary::Observer implementation. | 62 // NetworkLibrary::Observer implementation. |
63 virtual void NetworkChanged(NetworkLibrary* cros); | 63 virtual void NetworkChanged(NetworkLibrary* cros); |
64 virtual void NetworkTraffic(NetworkLibrary* cros, int traffic_type) {} | |
65 | 64 |
66 private: | 65 private: |
67 friend struct DefaultSingletonTraits<NetworkStateNotifier>; | 66 friend struct DefaultSingletonTraits<NetworkStateNotifier>; |
68 | 67 |
69 // Retrieve the current state from libcros. | 68 // Retrieve the current state from libcros. |
70 static NetworkStateDetails::State RetrieveState(); | 69 static NetworkStateDetails::State RetrieveState(); |
71 | 70 |
72 NetworkStateNotifier(); | 71 NetworkStateNotifier(); |
73 virtual ~NetworkStateNotifier() {} | 72 virtual ~NetworkStateNotifier() {} |
74 | 73 |
75 // Update the current state and sends notification to observers. | 74 // Update the current state and sends notification to observers. |
76 // This should be invoked in UI thread. | 75 // This should be invoked in UI thread. |
77 void UpdateNetworkState(NetworkStateDetails::State new_state); | 76 void UpdateNetworkState(NetworkStateDetails::State new_state); |
78 | 77 |
79 // A factory to post a task in UI thread. | 78 // A factory to post a task in UI thread. |
80 ScopedRunnableMethodFactory<NetworkStateNotifier> task_factory_; | 79 ScopedRunnableMethodFactory<NetworkStateNotifier> task_factory_; |
81 | 80 |
82 // The current network state. | 81 // The current network state. |
83 NetworkStateDetails::State state_; | 82 NetworkStateDetails::State state_; |
84 | 83 |
85 // The start time of offline. | 84 // The start time of offline. |
86 base::Time offline_start_time_; | 85 base::Time offline_start_time_; |
87 | 86 |
88 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifier); | 87 DISALLOW_COPY_AND_ASSIGN(NetworkStateNotifier); |
89 }; | 88 }; |
90 | 89 |
91 } // namespace chromeos | 90 } // namespace chromeos |
92 | 91 |
93 #endif // CHROME_BROWSER_CHROMEOS_NETWORK_STATE_NOTIFIER_H_ | 92 #endif // CHROME_BROWSER_CHROMEOS_NETWORK_STATE_NOTIFIER_H_ |
OLD | NEW |