| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_NET_WAKE_ON_WIFI_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/containers/scoped_ptr_hash_map.h" | 8 #include "base/containers/scoped_ptr_hash_map.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
| 11 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
| 12 | 12 |
| 13 class Profile; | 13 class Profile; |
| 14 | 14 |
| 15 namespace chromeos { | 15 namespace chromeos { |
| 16 | 16 |
| 17 // This class is responsible for managing the various wake-on-wifi related bits | 17 // This class is responsible for managing the various wake-on-wifi related bits |
| 18 // of functionality in chrome. It is responsible for communicating the user's | 18 // of functionality in chrome. It is responsible for communicating the user's |
| 19 // preferences to shill as well as listening for connections to the Google GCM | 19 // preferences to shill as well as listening for connections to the Google GCM |
| 20 // servers and sending that connection information down to shill. This class is | 20 // servers and sending that connection information down to shill. This class is |
| 21 // owned by ChromeBrowserMainPartsChromeos. This class is also NOT thread-safe | 21 // owned by ChromeBrowserMainPartsChromeos. This class is also NOT thread-safe |
| 22 // and should only be called on the UI thread. | 22 // and should only be called on the UI thread. |
| 23 class WakeOnWifiManager : public content::NotificationObserver { | 23 class WakeOnWifiManager : public content::NotificationObserver { |
| 24 public: | 24 public: |
| 25 enum WakeOnWifiFeature { | 25 enum WakeOnWifiFeature { |
| 26 WAKE_ON_NONE = 0, | 26 WAKE_ON_NONE = 0, |
| 27 WAKE_ON_PACKET = 1, | 27 WAKE_ON_PACKET = 1, |
| 28 WAKE_ON_SSID = 2, | 28 WAKE_ON_SSID = 2, |
| 29 WAKE_ON_PACKET_AND_SSID = 3, | 29 WAKE_ON_PACKET_AND_SSID = 3, |
| 30 INVALID = 4, |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 static WakeOnWifiManager* Get(); | 33 static WakeOnWifiManager* Get(); |
| 33 | 34 |
| 34 WakeOnWifiManager(); | 35 WakeOnWifiManager(); |
| 35 ~WakeOnWifiManager() override; | 36 ~WakeOnWifiManager() override; |
| 36 | 37 |
| 37 // Should be called whenever the primary user changes their preference for the | 38 // Should be called whenever the primary user changes their preference for the |
| 38 // wake-on-wifi features that should be enabled. | 39 // wake-on-wifi features that should be enabled. |
| 39 void OnPreferenceChanged(WakeOnWifiFeature feature); | 40 void OnPreferenceChanged(WakeOnWifiFeature feature); |
| 40 | 41 |
| 41 // content::NotificationObserver override. | 42 // content::NotificationObserver override. |
| 42 void Observe(int type, | 43 void Observe(int type, |
| 43 const content::NotificationSource& source, | 44 const content::NotificationSource& source, |
| 44 const content::NotificationDetails& details) override; | 45 const content::NotificationDetails& details) override; |
| 45 | 46 |
| 46 private: | 47 private: |
| 47 void OnProfileAdded(Profile* profile); | 48 void OnProfileAdded(Profile* profile); |
| 48 void OnProfileDestroyed(Profile* profile); | 49 void OnProfileDestroyed(Profile* profile); |
| 49 | 50 |
| 51 WakeOnWifiFeature current_feature_; |
| 52 |
| 50 class WakeOnPacketConnectionObserver; | 53 class WakeOnPacketConnectionObserver; |
| 51 base::ScopedPtrHashMap<Profile*, WakeOnPacketConnectionObserver> | 54 base::ScopedPtrHashMap<Profile*, WakeOnPacketConnectionObserver> |
| 52 connection_observers_; | 55 connection_observers_; |
| 53 | 56 |
| 54 content::NotificationRegistrar registrar_; | 57 content::NotificationRegistrar registrar_; |
| 55 | 58 |
| 56 DISALLOW_COPY_AND_ASSIGN(WakeOnWifiManager); | 59 DISALLOW_COPY_AND_ASSIGN(WakeOnWifiManager); |
| 57 }; | 60 }; |
| 58 | 61 |
| 59 } // namespace chromeos | 62 } // namespace chromeos |
| 60 | 63 |
| 61 #endif // CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_MANAGER_H_ | 64 #endif // CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_MANAGER_H_ |
| OLD | NEW |