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/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "components/policy/policy_export.h" | 11 #include "components/policy/policy_export.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class HistogramBase; | 14 class HistogramBase; |
15 } | 15 } |
16 | 16 |
17 namespace policy { | 17 namespace policy { |
18 | 18 |
19 // UMA histogram enum for policy load status. Don't change existing constants, | 19 // UMA histogram enum for policy load status. Don't change existing constants, |
20 // append additional constants to the end if needed. | 20 // append additional constants to the end if needed. |
21 enum PolicyLoadStatus { | 21 enum PolicyLoadStatus { |
22 // Policy load attempt started. This gets logged for each policy load attempt | 22 // 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 | 23 // to get a baseline on the number of requests, and an arbitrary number of |
24 // the below status codes may get added in addition. | 24 // the below status codes may get added in addition. |
25 POLICY_LOAD_STATUS_STARTED, | 25 POLICY_LOAD_STATUS_STARTED = 0, |
26 // System failed to determine whether there's policy. | 26 // System failed to determine whether there's policy. |
27 POLICY_LOAD_STATUS_QUERY_FAILED, | 27 POLICY_LOAD_STATUS_QUERY_FAILED = 1, |
28 // No policy present. | 28 // No policy present. |
29 POLICY_LOAD_STATUS_NO_POLICY, | 29 POLICY_LOAD_STATUS_NO_POLICY = 2, |
30 // Data inaccessible, such as non-local policy file. | 30 // Data inaccessible, such as non-local policy file. |
31 POLICY_LOAD_STATUS_INACCCESSIBLE, | 31 POLICY_LOAD_STATUS_INACCCESSIBLE = 3, |
32 // Data missing, such as policy file not present. | 32 // Data missing, such as policy file not present. |
33 POLICY_LOAD_STATUS_MISSING, | 33 POLICY_LOAD_STATUS_MISSING = 4, |
34 // Trying with Wow64 redirection disabled. | 34 // Trying with Wow64 redirection disabled. |
35 POLICY_LOAD_STATUS_WOW64_REDIRECTION_DISABLED, | 35 POLICY_LOAD_STATUS_WOW64_REDIRECTION_DISABLED = 5, |
36 // Data read error, for example file reading errors. | 36 // Data read error, for example file reading errors. |
37 POLICY_LOAD_STATUS_READ_ERROR, | 37 POLICY_LOAD_STATUS_READ_ERROR = 6, |
38 // Data too large to process. | 38 // Data too large to process. |
39 POLICY_LOAD_STATUS_TOO_BIG, | 39 POLICY_LOAD_STATUS_TOO_BIG = 7, |
40 // Parse error. | 40 // Parse error. |
41 POLICY_LOAD_STATUS_PARSE_ERROR, | 41 POLICY_LOAD_STATUS_PARSE_ERROR = 8, |
42 | 42 |
43 // This must stay last. | 43 // This must stay last. |
44 POLICY_LOAD_STATUS_SIZE | 44 POLICY_LOAD_STATUS_SIZE |
45 }; | 45 }; |
46 | 46 |
47 // A helper for generating policy load status UMA statistics that'll collect | 47 // A helper for generating policy load status UMA statistics that'll collect |
48 // histogram samples for a policy load operation and records histogram samples | 48 // histogram samples for a policy load operation and records histogram samples |
49 // for the status codes that were seen on destruction. | 49 // for the status codes that were seen on destruction. |
50 class POLICY_EXPORT PolicyLoadStatusSample { | 50 class POLICY_EXPORT PolicyLoadStatusSample { |
51 public: | 51 public: |
52 PolicyLoadStatusSample(); | 52 PolicyLoadStatusSample(); |
53 ~PolicyLoadStatusSample(); | 53 ~PolicyLoadStatusSample(); |
54 | 54 |
55 // Adds a status code. | 55 // Adds a status code. |
56 void Add(PolicyLoadStatus status); | 56 void Add(PolicyLoadStatus status); |
57 | 57 |
58 private: | 58 private: |
59 std::bitset<POLICY_LOAD_STATUS_SIZE> status_bits_; | 59 std::bitset<POLICY_LOAD_STATUS_SIZE> status_bits_; |
60 base::HistogramBase* histogram_; | 60 base::HistogramBase* histogram_; |
61 | 61 |
62 DISALLOW_COPY_AND_ASSIGN(PolicyLoadStatusSample); | 62 DISALLOW_COPY_AND_ASSIGN(PolicyLoadStatusSample); |
63 }; | 63 }; |
64 | 64 |
65 } // namespace policy | 65 } // namespace policy |
66 | 66 |
67 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOAD_STATUS_H_ | 67 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOAD_STATUS_H_ |
OLD | NEW |