OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ASH_SYSTEM_NETWORK_TRAY_NETWORK_STATE_OBSERVER_H_ | |
6 #define ASH_SYSTEM_NETWORK_TRAY_NETWORK_STATE_OBSERVER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/timer/timer.h" | |
10 #include "chromeos/network/network_state_handler_observer.h" | |
11 | |
12 namespace ash { | |
13 | |
14 class TrayNetworkStateObserver : public chromeos::NetworkStateHandlerObserver { | |
15 public: | |
16 class Delegate { | |
17 public: | |
18 // Called when any interesting network changes occur. The frequency of this | |
19 // event is limited to kUpdateFrequencyMs. | |
20 virtual void NetworkStateChanged() = 0; | |
21 | |
22 protected: | |
23 virtual ~Delegate() {} | |
24 }; | |
25 | |
26 explicit TrayNetworkStateObserver(Delegate* delegate); | |
27 | |
28 ~TrayNetworkStateObserver() override; | |
29 | |
30 // NetworkStateHandlerObserver overrides. | |
31 void NetworkListChanged() override; | |
32 void DeviceListChanged() override; | |
33 void DefaultNetworkChanged(const chromeos::NetworkState* network) override; | |
34 void NetworkConnectionStateChanged( | |
35 const chromeos::NetworkState* network) override; | |
36 void NetworkPropertiesUpdated(const chromeos::NetworkState* network) override; | |
37 | |
38 private: | |
39 void SignalUpdate(); | |
40 void SendNetworkStateChanged(); | |
41 | |
42 // Unowned Delegate pointer (must outlive this instance). | |
43 Delegate* delegate_; | |
44 | |
45 // Set to true when we should purge stale icons in the cache. | |
46 bool purge_icons_; | |
47 | |
48 // Frequency at which to push NetworkStateChanged updates. This avoids | |
49 // unnecessarily frequent UI updates (which can be expensive). We set this | |
50 // to 0 for tests to eliminate timing variance. | |
51 int update_frequency_; | |
52 | |
53 // Timer used to limit the frequency of NetworkStateChanged updates. | |
54 base::OneShotTimer timer_; | |
55 | |
56 DISALLOW_COPY_AND_ASSIGN(TrayNetworkStateObserver); | |
57 }; | |
58 | |
59 } // namespace ash | |
60 | |
61 #endif // ASH_SYSTEM_NETWORK_TRAY_NETWORK_STATE_OBSERVER_H_ | |
OLD | NEW |