| 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 <set> |
| 9 #include <string> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "base/cancelable_callback.h" |
| 8 #include "base/containers/scoped_ptr_hash_map.h" | 13 #include "base/containers/scoped_ptr_hash_map.h" |
| 9 #include "base/macros.h" | 14 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "chromeos/dbus/power_manager_client.h" |
| 11 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 #include "extensions/browser/event_router.h" |
| 20 #include "extensions/browser/extension_registry_observer.h" |
| 21 #include "extensions/browser/process_manager_observer.h" |
| 13 | 22 |
| 14 class Profile; | 23 class Profile; |
| 15 | 24 |
| 16 namespace base { | 25 namespace base { |
| 17 class DictionaryValue; | 26 class DictionaryValue; |
| 18 } | 27 } |
| 19 | 28 |
| 29 namespace content { |
| 30 class BrowserContext; |
| 31 } |
| 32 |
| 33 namespace extensions { |
| 34 class Extension; |
| 35 } |
| 36 |
| 20 namespace chromeos { | 37 namespace chromeos { |
| 21 | 38 |
| 22 // This class is responsible for managing the various wake-on-wifi related bits | 39 // This class is responsible for managing the various wake-on-wifi related bits |
| 23 // of functionality in chrome. It is responsible for communicating the user's | 40 // of functionality in chrome. It is responsible for communicating the user's |
| 24 // preferences to shill as well as listening for connections to the Google GCM | 41 // preferences to shill as well as listening for connections to the Google GCM |
| 25 // servers and sending that connection information down to shill. This class is | 42 // servers and sending that connection information down to shill. This class is |
| 26 // owned by ChromeBrowserMainPartsChromeos. This class is also NOT thread-safe | 43 // owned by ChromeBrowserMainPartsChromeos. This class is also NOT thread-safe |
| 27 // and should only be called on the UI thread. | 44 // and should only be called on the UI thread. |
| 28 class WakeOnWifiManager : public content::NotificationObserver { | 45 class WakeOnWifiManager : public content::NotificationObserver, |
| 46 public extensions::ExtensionRegistryObserver, |
| 47 public PowerManagerClient::Observer { |
| 29 public: | 48 public: |
| 30 enum WakeOnWifiFeature { | 49 enum WakeOnWifiFeature { |
| 31 WAKE_ON_NONE = 0x00, | 50 WAKE_ON_NONE = 0x00, |
| 32 WAKE_ON_PACKET = 0x01, | 51 WAKE_ON_PACKET = 0x01, |
| 33 WAKE_ON_SSID = 0x02, | 52 WAKE_ON_SSID = 0x02, |
| 34 WAKE_ON_PACKET_AND_SSID = 0x03, | 53 WAKE_ON_PACKET_AND_SSID = 0x03, |
| 35 NOT_SUPPORTED = 0x04, | 54 NOT_SUPPORTED = 0x04, |
| 36 INVALID = 0x08, | 55 INVALID = 0x08, |
| 37 }; | 56 }; |
| 38 | 57 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 51 | 70 |
| 52 // Callback for getting the Wi-Fi device properties. | 71 // Callback for getting the Wi-Fi device properties. |
| 53 void GetDevicePropertiesCallback(const std::string& device_path, | 72 void GetDevicePropertiesCallback(const std::string& device_path, |
| 54 const base::DictionaryValue& properties); | 73 const base::DictionaryValue& properties); |
| 55 | 74 |
| 56 // content::NotificationObserver override. | 75 // content::NotificationObserver override. |
| 57 void Observe(int type, | 76 void Observe(int type, |
| 58 const content::NotificationSource& source, | 77 const content::NotificationSource& source, |
| 59 const content::NotificationDetails& details) override; | 78 const content::NotificationDetails& details) override; |
| 60 | 79 |
| 80 // extensions::ExtensionRegistryObserver override. |
| 81 void OnExtensionLoaded(content::BrowserContext* context, |
| 82 const extensions::Extension* extension) override; |
| 83 |
| 84 // PowerManagerClient::Observer override. |
| 85 void SuspendImminent() override; |
| 86 void SuspendDone(const base::TimeDelta& duration) override; |
| 87 void DarkSuspendImminent() override; |
| 88 |
| 61 private: | 89 private: |
| 62 void OnProfileAdded(Profile* profile); | 90 void OnProfileAdded(Profile* profile); |
| 63 void OnProfileDestroyed(Profile* profile); | 91 void OnProfileDestroyed(Profile* profile); |
| 64 | 92 |
| 93 // Called when the system is about to perform a regular suspend or a dark |
| 94 // suspend. |
| 95 void OnSuspendImminent(bool dark_suspend); |
| 96 |
| 97 // Maybe report readiness to suspend to the PowerManagerClient. |
| 98 void MaybeReportSuspendReadiness(); |
| 99 |
| 100 // Called when an extension message has been dispatched. |
| 101 void OnExtensionMessageDispatched( |
| 102 extensions::EventRouter::DispatchDetails* details); |
| 103 |
| 104 // Called when a previously dispatched extension message is acked by |
| 105 // the extension renderer. |
| 106 void OnExtensionMessageAcked(int message_id); |
| 107 |
| 108 // Called when the ExtensionSystem for profile is ready to process requests. |
| 109 void OnExtensionSystemReady(Profile* profile); |
| 110 |
| 65 WakeOnWifiFeature current_feature_; | 111 WakeOnWifiFeature current_feature_; |
| 66 | 112 |
| 67 class WakeOnPacketConnectionObserver; | 113 class WakeOnPacketConnectionObserver; |
| 68 base::ScopedPtrHashMap<Profile*, WakeOnPacketConnectionObserver> | 114 base::ScopedPtrHashMap<Profile*, WakeOnPacketConnectionObserver> |
| 69 connection_observers_; | 115 connection_observers_; |
| 70 | 116 |
| 117 // Ids for extensions that have the GCM permission set. |
| 118 std::set<std::string> gcm_extensions_; |
| 119 |
| 120 bool suspend_is_pending_; |
| 121 std::set<int> unacked_extension_messages_; |
| 122 base::Closure power_manager_callback_; |
| 123 base::CancelableClosure suspend_readiness_callback_; |
| 124 |
| 71 content::NotificationRegistrar registrar_; | 125 content::NotificationRegistrar registrar_; |
| 72 | 126 |
| 73 base::WeakPtrFactory<WakeOnWifiManager> weak_ptr_factory_; | 127 base::WeakPtrFactory<WakeOnWifiManager> weak_ptr_factory_; |
| 74 | 128 |
| 75 DISALLOW_COPY_AND_ASSIGN(WakeOnWifiManager); | 129 DISALLOW_COPY_AND_ASSIGN(WakeOnWifiManager); |
| 76 }; | 130 }; |
| 77 | 131 |
| 78 } // namespace chromeos | 132 } // namespace chromeos |
| 79 | 133 |
| 80 #endif // CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_MANAGER_H_ | 134 #endif // CHROME_BROWSER_CHROMEOS_NET_WAKE_ON_WIFI_MANAGER_H_ |
| OLD | NEW |