Rename desktop_cursor_loader_updater_aurax11.
[chromium-blink-merge.git] / chrome / browser / performance_monitor / key_builder.h
blob1b4ac24cce68a18a0da864637083197f2fd8fae6
1 // Copyright (c) 2012 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 CHROME_BROWSER_PERFORMANCE_MONITOR_KEY_BUILDER_H_
6 #define CHROME_BROWSER_PERFORMANCE_MONITOR_KEY_BUILDER_H_
8 #include <map>
10 #include "chrome/browser/performance_monitor/event.h"
11 #include "chrome/browser/performance_monitor/metric.h"
13 namespace performance_monitor {
15 struct RecentKey {
16 RecentKey(const std::string& recent_time,
17 MetricType recent_type,
18 const std::string& recent_activity);
19 ~RecentKey();
21 const std::string time;
22 const MetricType type;
23 const std::string activity;
26 struct MaxValueKey {
27 MaxValueKey(MetricType max_value_type,
28 const std::string& max_value_activity)
29 : type(max_value_type),
30 activity(max_value_activity) {}
31 ~MaxValueKey() {}
33 const MetricType type;
34 const std::string activity;
37 struct MetricKey {
38 MetricKey(const std::string& metric_time,
39 MetricType metric_type,
40 const std::string& metric_activity);
41 ~MetricKey();
43 const std::string time;
44 const MetricType type;
45 const std::string activity;
48 // This class is responsible for building the keys which are used internally by
49 // PerformanceMonitor's database. These keys should only be referenced by the
50 // database, and should not be used externally.
51 class KeyBuilder {
52 public:
53 KeyBuilder();
54 ~KeyBuilder();
56 // Key Creation: Create the keys for different databases. The schemas are
57 // listed with the methods. A '-' in the schema represents kDelimeter.
59 // Key Schema: <Time>
60 std::string CreateActiveIntervalKey(const base::Time& time);
62 // Key Schema: <Metric>-<Time>-<Activity>
63 std::string CreateMetricKey(const base::Time& time,
64 const MetricType type,
65 const std::string& activity);
67 // Key Schema: <Time>-<Event Type>
68 std::string CreateEventKey(const base::Time& time, const EventType type);
70 // Key Schema: <Time>-<Metric>-<Activity>
71 std::string CreateRecentKey(const base::Time& time,
72 const MetricType type,
73 const std::string& activity);
75 // Key Schema: <Activity>-<Metric>
76 std::string CreateRecentMapKey(const MetricType type,
77 const std::string& activity);
79 std::string CreateMaxValueKey(const MetricType type,
80 const std::string& activity);
82 EventType EventKeyToEventType(const std::string& key);
83 RecentKey SplitRecentKey(const std::string& key);
84 MetricKey SplitMetricKey(const std::string& key);
86 private:
87 // Populate the maps from [Event, Metric]Type to key characters.
88 void PopulateKeyMaps();
90 std::map<EventType, int> event_type_to_event_key_char_;
91 std::map<int, EventType> event_key_char_to_event_type_;
92 std::map<MetricType, int> metric_type_to_metric_key_char_;
93 std::map<int, MetricType> metric_key_char_to_metric_type_;
96 } // namespace performance_monitor
98 #endif // CHROME_BROWSER_PERFORMANCE_MONITOR_KEY_BUILDER_H_