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.
5 #ifndef ASH_SYSTEM_CHROMEOS_NETWORK_TRAY_NETWORK_STATE_OBSERVER_H
6 #define ASH_SYSTEM_CHROMEOS_NETWORK_TRAY_NETWORK_STATE_OBSERVER_H
10 #include "base/compiler_specific.h"
11 #include "base/timer/timer.h"
12 #include "chromeos/network/network_state_handler_observer.h"
16 class TrayNetworkStateObserver
: public chromeos::NetworkStateHandlerObserver
{
20 // Called when any interesting network changes occur. The frequency of this
21 // event is limited to kUpdateFrequencyMs.
22 virtual void NetworkStateChanged() = 0;
25 virtual ~Delegate() {}
28 explicit TrayNetworkStateObserver(Delegate
* delegate
);
30 ~TrayNetworkStateObserver() override
;
32 // NetworkStateHandlerObserver overrides.
33 void NetworkListChanged() override
;
34 void DeviceListChanged() override
;
35 void DefaultNetworkChanged(const chromeos::NetworkState
* network
) override
;
36 void NetworkConnectionStateChanged(
37 const chromeos::NetworkState
* network
) override
;
38 void NetworkPropertiesUpdated(const chromeos::NetworkState
* network
) override
;
42 void SendNetworkStateChanged();
44 // Unowned Delegate pointer (must outlive this instance).
47 // Set to true when we should purge stale icons in the cache.
50 // Frequency at which to push NetworkStateChanged updates. This avoids
51 // unnecessarily frequent UI updates (which can be expensive). We set this
52 // to 0 for tests to eliminate timing variance.
53 int update_frequency_
;
55 // Timer used to limit the frequency of NetworkStateChanged updates.
56 base::OneShotTimer
<TrayNetworkStateObserver
> timer_
;
58 DISALLOW_COPY_AND_ASSIGN(TrayNetworkStateObserver
);
63 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_TRAY_NETWORK_STATE_OBSERVER_H