OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_POWER_ORIGIN_POWER_MAP_H_ | |
6 #define CHROME_BROWSER_POWER_ORIGIN_POWER_MAP_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #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.
| |
11 #include "components/keyed_service/core/keyed_service.h" | |
12 #include "url/gurl.h" | |
13 | |
14 class PrefService; | |
15 | |
16 namespace base { | |
17 class DictionaryValue; | |
18 } | |
19 | |
20 namespace user_prefs { | |
21 class PrefRegistrySyncable; | |
22 } | |
23 | |
24 // Tracks app and website origins and how much power they are consuming while | |
25 // running. | |
26 class OriginPowerMap : public KeyedService { | |
27 public: | |
28 explicit OriginPowerMap(PrefService* prefs); | |
29 virtual ~OriginPowerMap(); | |
30 | |
31 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.
| |
32 | |
33 // Returns the integer percentage usage of the total power consumed by a | |
34 // given origin. | |
35 int GetPowerForOrigin(const GURL& origin); | |
36 | |
37 // Add a certain amount of power consumption to a given origin. | |
38 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
| |
39 | |
40 // Return a map of all origins to the integer percentage usage of power | |
41 // consumed. | |
42 scoped_ptr<ScaledOriginMap> GetScaledOriginMap(); | |
sky
2014/08/06 23:59:23
nit: const
Daniel Nishi
2014/08/07 21:15:08
Done.
| |
43 void SavePrefs(); | |
44 | |
45 // Register per-profile preferences for the power consumed by origin. | |
46 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | |
47 | |
48 private: | |
49 typedef std::map<GURL, double> OriginMap; | |
50 OriginMap origin_map_; | |
51 | |
52 // The total amount of power consumed since the last wipe. | |
53 double total_consumed_; | |
54 | |
55 PrefService* prefs_; | |
56 }; | |
sky
2014/08/06 23:59:23
DISALLOW_...
Daniel Nishi
2014/08/07 21:15:08
Done.
| |
57 | |
58 #endif // CHROME_BROWSER_POWER_ORIGIN_POWER_MAP_H_ | |
OLD | NEW |