Roll BoringSSL.
[chromium-blink-merge.git] / components / power / origin_power_map.h
blob0936be46d8af98264316927e9e404a7bba9da170
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_POWER_ORIGIN_POWER_MAP_H_
6 #define COMPONENTS_POWER_ORIGIN_POWER_MAP_H_
8 #include <map>
10 #include "components/keyed_service/core/keyed_service.h"
11 #include "url/gurl.h"
13 namespace power {
15 // Tracks app and website origins and how much power they are consuming while
16 // running.
17 class OriginPowerMap : public KeyedService {
18 public:
19 typedef std::map<GURL, int> PercentOriginMap;
21 OriginPowerMap();
22 virtual ~OriginPowerMap();
24 // Returns the integer percentage usage of the total power consumed by a
25 // given URL's origin.
26 int GetPowerForOrigin(const GURL& url);
28 // Adds a certain amount of power consumption to a given URL's origin.
29 // |power| is a platform-specific heuristic estimating power consumption.
30 void AddPowerForOrigin(const GURL& url, double power);
32 // Returns a map of all origins to the integer percentage usage of power
33 // consumed.
34 PercentOriginMap GetPercentOriginMap();
36 private:
37 // OriginMap maps a URL to the amount of power consumed by the URL using the
38 // same units as |total_consumed_|.
39 typedef std::map<GURL, double> OriginMap;
40 OriginMap origin_map_;
42 // Total amount of power consumed using units determined by
43 // the power heuristics available to the platform.
44 double total_consumed_;
46 DISALLOW_COPY_AND_ASSIGN(OriginPowerMap);
49 } // namespace power
51 #endif // COMPONENTS_POWER_ORIGIN_POWER_MAP_H_