| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_CONNECTION_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_CONNECTION_OBSERVER_H_ |
| 7 |
| 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/macros.h" |
| 10 #include "chrome/browser/chromeos/net/wake_on_wifi_manager.h" |
| 11 #include "components/gcm_driver/gcm_connection_observer.h" |
| 12 #include "content/public/browser/notification_observer.h" |
| 13 #include "net/base/ip_endpoint.h" |
| 14 |
| 15 class Profile; |
| 16 |
| 17 namespace chromeos { |
| 18 |
| 19 class ConnectionObserverTest; |
| 20 class NetworkDeviceHandler; |
| 21 |
| 22 // Simple class that listens for a connection to the GCM server and passes the |
| 23 // connection information down to shill. Each instance of this class is |
| 24 // associated with a profile. |
| 25 class WakeOnWifiConnectionObserver : public gcm::GCMConnectionObserver { |
| 26 public: |
| 27 ~WakeOnWifiConnectionObserver() override; |
| 28 |
| 29 // Handles the case when the wifi properties have been received along with |
| 30 // attempting to begin listening for wake on wifi packets on the given IP |
| 31 // endpoint. The listening will only begin if wake on packet is enabled on the |
| 32 // device. |
| 33 void HandleWifiDevicePropertiesReady(); |
| 34 |
| 35 // gcm::GCMConnectionObserver overrides: |
| 36 void OnConnected(const net::IPEndPoint& ip_endpoint) override; |
| 37 void OnDisconnected() override; |
| 38 |
| 39 void set_feature(WakeOnWifiManager::WakeOnWifiFeature feature) { |
| 40 feature_ = feature; |
| 41 } |
| 42 |
| 43 private: |
| 44 FRIEND_TEST_ALL_PREFIXES(WakeOnWifiObserverTest, TestWakeOnWifiPacketAdd); |
| 45 FRIEND_TEST_ALL_PREFIXES(WakeOnWifiObserverTest, |
| 46 TestWakeOnWifiPacketRemove); |
| 47 FRIEND_TEST_ALL_PREFIXES(WakeOnWifiObserverTest, TestWakeOnWifiNoneAdd); |
| 48 FRIEND_TEST_ALL_PREFIXES(WakeOnWifiObserverTest, TestWakeOnWifiNoneRemove); |
| 49 friend class WakeOnWifiManager; |
| 50 |
| 51 WakeOnWifiConnectionObserver(Profile* profile, |
| 52 bool wifi_properties_received, |
| 53 WakeOnWifiManager::WakeOnWifiFeature feature, |
| 54 NetworkDeviceHandler* network_device_handler); |
| 55 |
| 56 void AddWakeOnPacketConnection(); |
| 57 void RemoveWakeOnPacketConnection(); |
| 58 |
| 59 Profile* profile_; |
| 60 net::IPEndPoint ip_endpoint_; |
| 61 bool wifi_properties_received_; |
| 62 WakeOnWifiManager::WakeOnWifiFeature feature_; |
| 63 NetworkDeviceHandler* network_device_handler_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(WakeOnWifiConnectionObserver); |
| 66 }; |
| 67 |
| 68 } // namespace chromeos |
| 69 |
| 70 #endif // CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_CONNECTION_OBSERVER_H_ |
| OLD | NEW |