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