| 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 CHROME_BROWSER_CHROMEOS_EXTENSIONS_POWER_POWER_API_MANAGER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_POWER_POWER_API_MANAGER_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/memory/singleton.h" | |
| 12 #include "content/public/browser/notification_observer.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 | |
| 15 namespace chromeos { | |
| 16 class PowerStateOverride; | |
| 17 } | |
| 18 | |
| 19 namespace extensions { | |
| 20 namespace power { | |
| 21 | |
| 22 class PowerApiManager : public content::NotificationObserver { | |
| 23 public: | |
| 24 static PowerApiManager* GetInstance(); | |
| 25 | |
| 26 // Add an extension lock for an extension. Calling this for an | |
| 27 // extension id already with a lock will do nothing. | |
| 28 void AddExtensionLock(const std::string& extension_id); | |
| 29 | |
| 30 // Remove an extension lock for an extension. Calling this for an | |
| 31 // extension id without a lock will do nothing. | |
| 32 void RemoveExtensionLock(const std::string& extension_id); | |
| 33 | |
| 34 // Overridden from content::NotificationObserver. | |
| 35 virtual void Observe(int type, | |
| 36 const content::NotificationSource& source, | |
| 37 const content::NotificationDetails& details) OVERRIDE; | |
| 38 | |
| 39 private: | |
| 40 friend struct DefaultSingletonTraits<PowerApiManager>; | |
| 41 | |
| 42 // Singleton class - use GetInstance instead. | |
| 43 PowerApiManager(); | |
| 44 virtual ~PowerApiManager(); | |
| 45 | |
| 46 // Check the state of the set of extension IDs with a lock. | |
| 47 // If we have any extensions with a lock, make sure that power management | |
| 48 // is overriden. If no extensions have a lock, ensure that our power | |
| 49 // management override is released. | |
| 50 void UpdatePowerSettings(); | |
| 51 | |
| 52 content::NotificationRegistrar registrar_; | |
| 53 | |
| 54 scoped_refptr<chromeos::PowerStateOverride> power_state_override_; | |
| 55 | |
| 56 // Set of extension IDs that have a keep awake lock. | |
| 57 std::set<std::string> extension_ids_set_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(PowerApiManager); | |
| 60 }; | |
| 61 | |
| 62 } // namespace power | |
| 63 } // namespace extensions | |
| 64 | |
| 65 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_POWER_POWER_API_MANAGER_H_ | |
| OLD | NEW |