| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ | 5 #ifndef COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ |
| 6 #define COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ | 6 #define COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/callback_list.h" | 10 #include "base/callback_list.h" |
| 11 #include "components/keyed_service/core/keyed_service.h" | 11 #include "components/keyed_service/core/keyed_service.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 namespace power { | 14 namespace power { |
| 15 | 15 |
| 16 // Tracks app and website origins and how much power they are consuming while | 16 // Tracks app and website origins and how much power they are consuming while |
| 17 // running. | 17 // running. |
| 18 class OriginPowerMap : public KeyedService { | 18 class OriginPowerMap : public KeyedService { |
| 19 public: | 19 public: |
| 20 typedef std::map<GURL, int> PercentOriginMap; | 20 typedef std::map<GURL, int> PercentOriginMap; |
| 21 typedef base::CallbackList<void(void)>::Subscription Subscription; | 21 typedef base::CallbackList<void(void)>::Subscription Subscription; |
| 22 | 22 |
| 23 OriginPowerMap(); | 23 OriginPowerMap(); |
| 24 virtual ~OriginPowerMap(); | 24 ~OriginPowerMap() override; |
| 25 | 25 |
| 26 // Returns the integer percentage usage of the total power consumed by a | 26 // Returns the integer percentage usage of the total power consumed by a |
| 27 // given URL's origin. | 27 // given URL's origin. |
| 28 int GetPowerForOrigin(const GURL& url); | 28 int GetPowerForOrigin(const GURL& url); |
| 29 | 29 |
| 30 // Adds a certain amount of power consumption to a given URL's origin. | 30 // Adds a certain amount of power consumption to a given URL's origin. |
| 31 // |power| is a platform-specific heuristic estimating power consumption. | 31 // |power| is a platform-specific heuristic estimating power consumption. |
| 32 void AddPowerForOrigin(const GURL& url, double power); | 32 void AddPowerForOrigin(const GURL& url, double power); |
| 33 | 33 |
| 34 // Returns a map of all origins to the integer percentage usage of power | 34 // Returns a map of all origins to the integer percentage usage of power |
| (...skipping 22 matching lines...) Expand all Loading... |
| 57 double total_consumed_; | 57 double total_consumed_; |
| 58 | 58 |
| 59 base::CallbackList<void(void)> callback_list_; | 59 base::CallbackList<void(void)> callback_list_; |
| 60 | 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(OriginPowerMap); | 61 DISALLOW_COPY_AND_ASSIGN(OriginPowerMap); |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 } // namespace power | 64 } // namespace power |
| 65 | 65 |
| 66 #endif // COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ | 66 #endif // COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ |
| OLD | NEW |