Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: components/policy/core/common/policy_load_status.h

Issue 2860973002: Allow PolicyLoadStatusSample to override reporting method (Closed)
Patch Set: Cleanups and class rename. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_LOAD_STATUS_H_ 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_LOAD_STATUS_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_LOAD_STATUS_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_POLICY_LOAD_STATUS_H_
7 7
8 #include <bitset> 8 #include <bitset>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "components/policy/policy_export.h" 11 #include "components/policy/policy_export.h"
12 12
13 namespace base {
14 class HistogramBase;
15 }
16
17 namespace policy { 13 namespace policy {
18 14
19 // UMA histogram enum for policy load status. Don't change existing constants, 15 // UMA histogram enum for policy load status. Don't change existing constants,
20 // append additional constants to the end if needed. 16 // append additional constants to the end if needed.
21 enum PolicyLoadStatus { 17 enum PolicyLoadStatus {
22 // Policy load attempt started. This gets logged for each policy load attempt 18 // Policy load attempt started. This gets logged for each policy load attempt
23 // to get a baseline on the number of requests, and an arbitrary number of 19 // to get a baseline on the number of requests, and an arbitrary number of
24 // the below status codes may get added in addition. 20 // the below status codes may get added in addition.
25 POLICY_LOAD_STATUS_STARTED = 0, 21 POLICY_LOAD_STATUS_STARTED = 0,
26 // System failed to determine whether there's policy. 22 // System failed to determine whether there's policy.
(...skipping 10 matching lines...) Expand all
37 POLICY_LOAD_STATUS_READ_ERROR = 6, 33 POLICY_LOAD_STATUS_READ_ERROR = 6,
38 // Data too large to process. 34 // Data too large to process.
39 POLICY_LOAD_STATUS_TOO_BIG = 7, 35 POLICY_LOAD_STATUS_TOO_BIG = 7,
40 // Parse error. 36 // Parse error.
41 POLICY_LOAD_STATUS_PARSE_ERROR = 8, 37 POLICY_LOAD_STATUS_PARSE_ERROR = 8,
42 38
43 // This must stay last. 39 // This must stay last.
44 POLICY_LOAD_STATUS_SIZE 40 POLICY_LOAD_STATUS_SIZE
45 }; 41 };
46 42
47 // A helper for generating policy load status UMA statistics that'll collect 43 // A helper for collecting statuses for a policy load operation.
48 // histogram samples for a policy load operation and records histogram samples 44 class POLICY_EXPORT PolicyLoadStatusSampler {
49 // for the status codes that were seen on destruction.
50 class POLICY_EXPORT PolicyLoadStatusSample {
51 public: 45 public:
52 PolicyLoadStatusSample(); 46 using StatusSet = std::bitset<POLICY_LOAD_STATUS_SIZE>;
53 ~PolicyLoadStatusSample(); 47
48 PolicyLoadStatusSampler();
49 virtual ~PolicyLoadStatusSampler();
54 50
55 // Adds a status code. 51 // Adds a status code.
56 void Add(PolicyLoadStatus status); 52 void Add(PolicyLoadStatus status);
57 53
54 // Returns a set with all statuses.
55 const StatusSet& GetStatusSet() const { return status_bits_; }
56
58 private: 57 private:
59 std::bitset<POLICY_LOAD_STATUS_SIZE> status_bits_; 58 StatusSet status_bits_;
60 base::HistogramBase* histogram_; 59 DISALLOW_COPY_AND_ASSIGN(PolicyLoadStatusSampler);
60 };
61 61
62 DISALLOW_COPY_AND_ASSIGN(PolicyLoadStatusSample); 62 // A helper for generating policy load status UMA statistics. On destruction,
63 // records histogram samples for the collected status codes.
64 class POLICY_EXPORT PolicyLoadStatusUmaReporter
65 : public PolicyLoadStatusSampler {
66 public:
67 PolicyLoadStatusUmaReporter();
68 ~PolicyLoadStatusUmaReporter() override;
69
70 private:
71 DISALLOW_COPY_AND_ASSIGN(PolicyLoadStatusUmaReporter);
63 }; 72 };
64 73
65 } // namespace policy 74 } // namespace policy
66 75
67 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOAD_STATUS_H_ 76 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOAD_STATUS_H_
OLDNEW
« no previous file with comments | « components/policy/core/common/config_dir_policy_loader.cc ('k') | components/policy/core/common/policy_load_status.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698