OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 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. | |
4 | |
5 // This class exists to interpret the response from the metrics server. | |
6 | |
7 #ifndef CHROME_BROWSER_METRICS_METRICS_RESPONSE_H_ | |
8 #define CHROME_BROWSER_METRICS_METRICS_RESPONSE_H_ | |
9 | |
10 #include <string> | |
11 | |
12 #include "base/basictypes.h" | |
13 | |
14 class MetricsResponse { | |
15 public: | |
16 // Parses metrics response XML into the information we care about | |
17 // (how often to send metrics info, which info to send). | |
18 explicit MetricsResponse(const std::string& response_xml); | |
19 | |
20 // True if the XML passed to the constructor was valid and parseable. | |
21 bool valid() { return valid_; } | |
22 | |
23 // Each flag (except NONE) defined here represents one type of metrics | |
24 // event that the server is interested in. | |
25 enum CollectorType { | |
26 COLLECTOR_NONE = 0x0, | |
27 COLLECTOR_PROFILE = 0x1, | |
28 COLLECTOR_WINDOW = 0x2, | |
29 COLLECTOR_DOCUMENT = 0x4, | |
30 COLLECTOR_UI = 0x8 | |
31 }; | |
32 | |
33 // This is the collection of CollectorTypes that are desired by the | |
34 // server, ORed together into one value. | |
35 int collectors() { return collectors_; } | |
36 | |
37 // Returns true if the given CollectorType is desired by the server. | |
38 bool collector_active(CollectorType type) { return !!(collectors_ & type); } | |
39 | |
40 // Returns the maximum number of event that the server wants in each | |
41 // metrics log sent. (If 0, no value was provided.) | |
42 int events() { return events_; } | |
43 | |
44 // Returns the size of the time interval that the server wants us to include | |
45 // in each log (in seconds). (If 0, no value was provided.) | |
46 int interval() { return interval_; } | |
47 | |
48 private: | |
49 bool valid_; | |
50 int collectors_; | |
51 int events_; | |
52 int interval_; | |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(MetricsResponse); | |
55 }; | |
56 | |
57 #endif // CHROME_BROWSER_METRICS_METRICS_RESPONSE_H_ | |
OLD | NEW |