Chromium Code Reviews| Index: components/power/origin_power_map.h |
| diff --git a/components/power/origin_power_map.h b/components/power/origin_power_map.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cbf1b095f1d2699f3103d7be06e2d31e9306a181 |
| --- /dev/null |
| +++ b/components/power/origin_power_map.h |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ |
| +#define COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ |
| + |
| +#include <map> |
| + |
| +#include "components/keyed_service/core/keyed_service.h" |
| +#include "url/gurl.h" |
| + |
| +namespace power { |
| + |
| +// Tracks app and website origins and how much power they are consuming while |
| +// running. |
| +class OriginPowerMap : public KeyedService { |
| + public: |
| + typedef std::map<GURL, int> PercentOriginMap; |
| + |
| + OriginPowerMap(); |
| + virtual ~OriginPowerMap(); |
| + |
| + // Returns the integer percentage usage of the total power consumed by a |
| + // given URL's origin. |
| + int GetPowerForOrigin(const GURL& url); |
| + |
| + // Add a certain amount of power consumption to a given URL's origin. |
|
Daniel Erat
2014/08/12 15:58:52
nit: s/Add/Adds/
Daniel Nishi
2014/08/12 17:33:46
Done.
|
| + // |power| is a platform-specific heuristic estimating power consumption. |
| + void AddPowerForOrigin(const GURL& url, double power); |
| + |
| + // Return a map of all origins to the integer percentage usage of power |
|
Daniel Erat
2014/08/12 15:58:52
nit: s/Return/Returns/
Daniel Nishi
2014/08/12 17:33:46
Done.
|
| + // consumed. |
| + scoped_ptr<PercentOriginMap> GetPercentOriginMap(); |
|
Daniel Erat
2014/08/12 15:58:52
does this need to be scoped_ptr? i'm wondering if
Daniel Nishi
2014/08/12 17:33:46
I didn't do any formal profiling, but my unittests
|
| + |
| + private: |
| + typedef std::map<GURL, double> OriginMap; |
|
Daniel Erat
2014/08/12 15:58:52
nit: add a comment documenting what the doubles ar
Daniel Nishi
2014/08/12 17:33:46
Done.
|
| + OriginMap origin_map_; |
| + |
| + // The total amount of power consumed since the last wipe. |
|
Daniel Erat
2014/08/12 15:58:52
when do "wipes" happen? i don't see |total_consume
Daniel Nishi
2014/08/12 17:33:46
Since the data is not currently persisted, this wi
|
| + double total_consumed_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(OriginPowerMap); |
| +}; |
| + |
| +} // namespace power |
| + |
| +#endif // COMPONENTS_POWER_ORIGIN_POWER_MAP_H_ |