Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/callback.h" | |
|
emaxx
2017/05/05 10:44:25
nit: Not necessary anymore.
ljusten (tachyonic)
2017/05/05 12:58:36
Done.
| |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "components/policy/policy_export.h" | 12 #include "components/policy/policy_export.h" |
| 12 | 13 |
| 13 namespace base { | |
| 14 class HistogramBase; | |
| 15 } | |
| 16 | |
| 17 namespace policy { | 14 namespace policy { |
| 18 | 15 |
| 19 // UMA histogram enum for policy load status. Don't change existing constants, | 16 // UMA histogram enum for policy load status. Don't change existing constants, |
| 20 // append additional constants to the end if needed. | 17 // append additional constants to the end if needed. |
| 21 enum PolicyLoadStatus { | 18 enum PolicyLoadStatus { |
| 22 // Policy load attempt started. This gets logged for each policy load attempt | 19 // 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 | 20 // to get a baseline on the number of requests, and an arbitrary number of |
| 24 // the below status codes may get added in addition. | 21 // the below status codes may get added in addition. |
| 25 POLICY_LOAD_STATUS_STARTED = 0, | 22 POLICY_LOAD_STATUS_STARTED = 0, |
| 26 // System failed to determine whether there's policy. | 23 // System failed to determine whether there's policy. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 37 POLICY_LOAD_STATUS_READ_ERROR = 6, | 34 POLICY_LOAD_STATUS_READ_ERROR = 6, |
| 38 // Data too large to process. | 35 // Data too large to process. |
| 39 POLICY_LOAD_STATUS_TOO_BIG = 7, | 36 POLICY_LOAD_STATUS_TOO_BIG = 7, |
| 40 // Parse error. | 37 // Parse error. |
| 41 POLICY_LOAD_STATUS_PARSE_ERROR = 8, | 38 POLICY_LOAD_STATUS_PARSE_ERROR = 8, |
| 42 | 39 |
| 43 // This must stay last. | 40 // This must stay last. |
| 44 POLICY_LOAD_STATUS_SIZE | 41 POLICY_LOAD_STATUS_SIZE |
| 45 }; | 42 }; |
| 46 | 43 |
| 47 // A helper for generating policy load status UMA statistics that'll collect | 44 // A helper for collecting statuses for a policy load operation. |
| 48 // histogram samples for a policy load operation and records histogram samples | 45 class POLICY_EXPORT PolicyLoadStatusSampler { |
| 49 // for the status codes that were seen on destruction. | |
| 50 class POLICY_EXPORT PolicyLoadStatusSample { | |
| 51 public: | 46 public: |
| 52 PolicyLoadStatusSample(); | 47 using StatusSet = std::bitset<POLICY_LOAD_STATUS_SIZE>; |
| 53 ~PolicyLoadStatusSample(); | 48 |
| 49 PolicyLoadStatusSampler(); | |
| 50 virtual ~PolicyLoadStatusSampler(); | |
| 54 | 51 |
| 55 // Adds a status code. | 52 // Adds a status code. |
| 56 void Add(PolicyLoadStatus status); | 53 void Add(PolicyLoadStatus status); |
| 57 | 54 |
| 55 // Returns a set with all statuses. | |
| 56 const StatusSet& GetStatusSet() const { return status_bits_; } | |
| 57 | |
| 58 private: | 58 private: |
| 59 std::bitset<POLICY_LOAD_STATUS_SIZE> status_bits_; | 59 StatusSet status_bits_; |
| 60 base::HistogramBase* histogram_; | 60 DISALLOW_COPY_AND_ASSIGN(PolicyLoadStatusSampler); |
| 61 }; | |
| 61 | 62 |
| 62 DISALLOW_COPY_AND_ASSIGN(PolicyLoadStatusSample); | 63 // A helper for generating policy load status UMA statistics. On destruction, |
| 64 // records histogram samples for the collected status codes. | |
| 65 class POLICY_EXPORT PolicyLoadStatusAutoSubmitter | |
|
emaxx
2017/05/05 10:44:25
nit: Not insisting, but as you're already changing
ljusten (tachyonic)
2017/05/05 12:58:36
Done, but I dropped the 'Auto' - it's cleaner.
| |
| 66 : public PolicyLoadStatusSampler { | |
| 67 public: | |
| 68 PolicyLoadStatusAutoSubmitter(); | |
| 69 ~PolicyLoadStatusAutoSubmitter() override; | |
| 70 | |
| 71 private: | |
| 72 DISALLOW_COPY_AND_ASSIGN(PolicyLoadStatusAutoSubmitter); | |
| 63 }; | 73 }; |
| 64 | 74 |
| 65 } // namespace policy | 75 } // namespace policy |
| 66 | 76 |
| 67 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOAD_STATUS_H_ | 77 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOAD_STATUS_H_ |
| OLD | NEW |