diff options
author | dhnishi <dhnishi@chromium.org> | 2014-09-03 11:40:49 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-03 18:53:29 +0000 |
commit | 828da409d7ffa5a837187eedf77af3f867f5ee31 (patch) | |
tree | b44e4d60d14ac8162aa59aec9f10ebbbb4587438 /components/power | |
parent | 71992c77b8cdb27ea11920536ac3dd19ff5fedf8 (diff) | |
download | chromium_src-828da409d7ffa5a837187eedf77af3f867f5ee31.zip chromium_src-828da409d7ffa5a837187eedf77af3f867f5ee31.tar.gz chromium_src-828da409d7ffa5a837187eedf77af3f867f5ee31.tar.bz2 |
Update the Website Settings page when the origin power map for the
profile is updated.
BUG=409093
Review URL: https://codereview.chromium.org/519883002
Cr-Commit-Position: refs/heads/master@{#293177}
Diffstat (limited to 'components/power')
-rw-r--r-- | components/power/origin_power_map.cc | 10 | ||||
-rw-r--r-- | components/power/origin_power_map.h | 12 |
2 files changed, 22 insertions, 0 deletions
diff --git a/components/power/origin_power_map.cc b/components/power/origin_power_map.cc index dfb0f17..4ce32e2 100644 --- a/components/power/origin_power_map.cc +++ b/components/power/origin_power_map.cc @@ -49,4 +49,14 @@ OriginPowerMap::PercentOriginMap OriginPowerMap::GetPercentOriginMap() { return percent_map; } +scoped_ptr<OriginPowerMap::Subscription> +OriginPowerMap::AddPowerConsumptionUpdatedCallback( + const base::Closure& callback) { + return callback_list_.Add(callback); +} + +void OriginPowerMap::OnAllOriginsUpdated() { + callback_list_.Notify(); +} + } // namespace power diff --git a/components/power/origin_power_map.h b/components/power/origin_power_map.h index 0936be4..36caa02 100644 --- a/components/power/origin_power_map.h +++ b/components/power/origin_power_map.h @@ -7,6 +7,7 @@ #include <map> +#include "base/callback_list.h" #include "components/keyed_service/core/keyed_service.h" #include "url/gurl.h" @@ -17,6 +18,7 @@ namespace power { class OriginPowerMap : public KeyedService { public: typedef std::map<GURL, int> PercentOriginMap; + typedef base::CallbackList<void(void)>::Subscription Subscription; OriginPowerMap(); virtual ~OriginPowerMap(); @@ -33,6 +35,14 @@ class OriginPowerMap : public KeyedService { // consumed. PercentOriginMap GetPercentOriginMap(); + // Adds a callback for the completion of a round of updates to |origin_map_|. + scoped_ptr<Subscription> AddPowerConsumptionUpdatedCallback( + const base::Closure& callback); + + // Notifies observers to let them know that the origin power map has finished + // updating for all origins this cycle. + void OnAllOriginsUpdated(); + private: // OriginMap maps a URL to the amount of power consumed by the URL using the // same units as |total_consumed_|. @@ -43,6 +53,8 @@ class OriginPowerMap : public KeyedService { // the power heuristics available to the platform. double total_consumed_; + base::CallbackList<void(void)> callback_list_; + DISALLOW_COPY_AND_ASSIGN(OriginPowerMap); }; |