Index: chrome/browser/power/origin_power_map.h |
diff --git a/chrome/browser/power/origin_power_map.h b/chrome/browser/power/origin_power_map.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b6448fd7f4e162b7f91447a44b08df77b5f82f42 |
--- /dev/null |
+++ b/chrome/browser/power/origin_power_map.h |
@@ -0,0 +1,58 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_POWER_ORIGIN_POWER_MAP_H_ |
+#define CHROME_BROWSER_POWER_ORIGIN_POWER_MAP_H_ |
+ |
+#include <map> |
+ |
+#include "base/memory/ref_counted.h" |
sky
2014/08/06 23:59:23
Do you really need the ref_counted include?
Daniel Nishi
2014/08/07 21:15:08
Unnecessary include removed.
|
+#include "components/keyed_service/core/keyed_service.h" |
+#include "url/gurl.h" |
+ |
+class PrefService; |
+ |
+namespace base { |
+class DictionaryValue; |
+} |
+ |
+namespace user_prefs { |
+class PrefRegistrySyncable; |
+} |
+ |
+// Tracks app and website origins and how much power they are consuming while |
+// running. |
+class OriginPowerMap : public KeyedService { |
+ public: |
+ explicit OriginPowerMap(PrefService* prefs); |
+ virtual ~OriginPowerMap(); |
+ |
+ typedef std::map<GURL, int> ScaledOriginMap; |
sky
2014/08/06 23:59:23
typedefs should be first in a section (see style g
sky
2014/08/06 23:59:23
Why is this named Scaled? Percent would be more me
Daniel Nishi
2014/08/07 21:15:08
I was thinking that since it was scaled to 100 as
Daniel Nishi
2014/08/07 21:15:08
Typedefs moved up.
|
+ |
+ // Returns the integer percentage usage of the total power consumed by a |
+ // given origin. |
+ int GetPowerForOrigin(const GURL& origin); |
+ |
+ // Add a certain amount of power consumption to a given origin. |
+ void AddPowerForOrigin(const GURL& origin, double power); |
sky
2014/08/06 23:59:23
Document what |power| means here. It's worth a des
Daniel Nishi
2014/08/07 21:15:08
Since the definition of |power| is platform specif
|
+ |
+ // Return a map of all origins to the integer percentage usage of power |
+ // consumed. |
+ scoped_ptr<ScaledOriginMap> GetScaledOriginMap(); |
sky
2014/08/06 23:59:23
nit: const
Daniel Nishi
2014/08/07 21:15:08
Done.
|
+ void SavePrefs(); |
+ |
+ // Register per-profile preferences for the power consumed by origin. |
+ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
+ |
+ private: |
+ typedef std::map<GURL, double> OriginMap; |
+ OriginMap origin_map_; |
+ |
+ // The total amount of power consumed since the last wipe. |
+ double total_consumed_; |
+ |
+ PrefService* prefs_; |
+}; |
sky
2014/08/06 23:59:23
DISALLOW_...
Daniel Nishi
2014/08/07 21:15:08
Done.
|
+ |
+#endif // CHROME_BROWSER_POWER_ORIGIN_POWER_MAP_H_ |