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 COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ | |
6 #define COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "components/keyed_service/core/keyed_service.h" | |
11 #include "url/gurl.h" | |
12 | |
13 namespace power { | |
14 | |
15 // Tracks app and website origins and how much power they are consuming while | |
16 // running. | |
17 class OriginPowerMap : public KeyedService { | |
18 public: | |
19 typedef std::map<GURL, int> PercentOriginMap; | |
20 | |
21 OriginPowerMap(); | |
22 virtual ~OriginPowerMap(); | |
23 | |
24 // Returns the integer percentage usage of the total power consumed by a | |
25 // given URL's origin. | |
26 int GetPowerForOrigin(const GURL& url); | |
27 | |
28 // Add a certain amount of power consumption to a given URL's origin. | |
Daniel Erat
2014/08/12 15:58:52
nit: s/Add/Adds/
Daniel Nishi
2014/08/12 17:33:46
Done.
| |
29 // |power| is a platform-specific heuristic estimating power consumption. | |
30 void AddPowerForOrigin(const GURL& url, double power); | |
31 | |
32 // Return a map of all origins to the integer percentage usage of power | |
Daniel Erat
2014/08/12 15:58:52
nit: s/Return/Returns/
Daniel Nishi
2014/08/12 17:33:46
Done.
| |
33 // consumed. | |
34 scoped_ptr<PercentOriginMap> GetPercentOriginMap(); | |
Daniel Erat
2014/08/12 15:58:52
does this need to be scoped_ptr? i'm wondering if
Daniel Nishi
2014/08/12 17:33:46
I didn't do any formal profiling, but my unittests
| |
35 | |
36 private: | |
37 typedef std::map<GURL, double> OriginMap; | |
Daniel Erat
2014/08/12 15:58:52
nit: add a comment documenting what the doubles ar
Daniel Nishi
2014/08/12 17:33:46
Done.
| |
38 OriginMap origin_map_; | |
39 | |
40 // The total amount of power consumed since the last wipe. | |
Daniel Erat
2014/08/12 15:58:52
when do "wipes" happen? i don't see |total_consume
Daniel Nishi
2014/08/12 17:33:46
Since the data is not currently persisted, this wi
| |
41 double total_consumed_; | |
42 | |
43 DISALLOW_COPY_AND_ASSIGN(OriginPowerMap); | |
44 }; | |
45 | |
46 } // namespace power | |
47 | |
48 #endif // COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ | |
OLD | NEW |