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 "components/keyed_service/core/keyed_service.h" |
| 11 #include "url/gurl.h" |
| 12 |
| 13 // Tracks app and website origins and how much power they are consuming while |
| 14 // running. |
| 15 class OriginPowerMap : public KeyedService { |
| 16 public: |
| 17 typedef std::map<GURL, int> PercentOriginMap; |
| 18 |
| 19 OriginPowerMap(); |
| 20 virtual ~OriginPowerMap(); |
| 21 |
| 22 // Returns the integer percentage usage of the total power consumed by a |
| 23 // given URL's origin. |
| 24 int GetPowerForOrigin(const GURL& url); |
| 25 |
| 26 // Add a certain amount of power consumption to a given URL's origin. |
| 27 // |power| is a platform-specific heuristic estimating power consumption. |
| 28 void AddPowerForOrigin(const GURL& url, double power); |
| 29 |
| 30 // Return a map of all origins to the integer percentage usage of power |
| 31 // consumed. |
| 32 scoped_ptr<PercentOriginMap> GetPercentOriginMap(); |
| 33 |
| 34 private: |
| 35 typedef std::map<GURL, double> OriginMap; |
| 36 OriginMap origin_map_; |
| 37 |
| 38 // The total amount of power consumed since the last wipe. |
| 39 double total_consumed_; |
| 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(OriginPowerMap); |
| 42 }; |
| 43 |
| 44 #endif // CHROME_BROWSER_POWER_ORIGIN_POWER_MAP_H_ |
OLD | NEW |