Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: components/power/origin_power_map.h

Issue 519883002: Update the Website Settings page when the power consumption is updated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a bug where the Origin Map may not exist in tests. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/website_settings_handler.cc ('k') | components/power/origin_power_map.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/power/origin_power_map.h
diff --git a/components/power/origin_power_map.h b/components/power/origin_power_map.h
index 0936be46d8af98264316927e9e404a7bba9da170..36caa02f0ada89238b9bc3ae7270391f9cc13dc7 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);
};
« no previous file with comments | « chrome/browser/ui/webui/options/website_settings_handler.cc ('k') | components/power/origin_power_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698