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