| 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" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 PercentOriginMap GetPercentOriginMap(); | 36 PercentOriginMap GetPercentOriginMap(); |
| 37 | 37 |
| 38 // Adds a callback for the completion of a round of updates to |origin_map_|. | 38 // Adds a callback for the completion of a round of updates to |origin_map_|. |
| 39 scoped_ptr<Subscription> AddPowerConsumptionUpdatedCallback( | 39 scoped_ptr<Subscription> AddPowerConsumptionUpdatedCallback( |
| 40 const base::Closure& callback); | 40 const base::Closure& callback); |
| 41 | 41 |
| 42 // Notifies observers to let them know that the origin power map has finished | 42 // Notifies observers to let them know that the origin power map has finished |
| 43 // updating for all origins this cycle. | 43 // updating for all origins this cycle. |
| 44 void OnAllOriginsUpdated(); | 44 void OnAllOriginsUpdated(); |
| 45 | 45 |
| 46 // Clears all URLs out of the map. |
| 47 void ClearOriginMap(); |
| 48 |
| 46 private: | 49 private: |
| 47 // OriginMap maps a URL to the amount of power consumed by the URL using the | 50 // OriginMap maps a URL to the amount of power consumed by the URL using the |
| 48 // same units as |total_consumed_|. | 51 // same units as |total_consumed_|. |
| 49 typedef std::map<GURL, double> OriginMap; | 52 typedef std::map<GURL, double> OriginMap; |
| 50 OriginMap origin_map_; | 53 OriginMap origin_map_; |
| 51 | 54 |
| 52 // Total amount of power consumed using units determined by | 55 // Total amount of power consumed using units determined by |
| 53 // the power heuristics available to the platform. | 56 // the power heuristics available to the platform. |
| 54 double total_consumed_; | 57 double total_consumed_; |
| 55 | 58 |
| 56 base::CallbackList<void(void)> callback_list_; | 59 base::CallbackList<void(void)> callback_list_; |
| 57 | 60 |
| 58 DISALLOW_COPY_AND_ASSIGN(OriginPowerMap); | 61 DISALLOW_COPY_AND_ASSIGN(OriginPowerMap); |
| 59 }; | 62 }; |
| 60 | 63 |
| 61 } // namespace power | 64 } // namespace power |
| 62 | 65 |
| 63 #endif // COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ | 66 #endif // COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ |
| OLD | NEW |