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