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

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

Issue 2860973002: Allow PolicyLoadStatusSample to override reporting method (Closed)
Patch Set: Change lambda bind to a more classical bind. 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
« no previous file with comments | « no previous file | components/policy/core/common/policy_load_status.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/callback.h"
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 15 matching lines...) Expand all
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 generating policy load status UMA statistics that'll collect
48 // histogram samples for a policy load operation and records histogram samples 45 // histogram samples for a policy load operation and records histogram samples
49 // for the status codes that were seen on destruction. 46 // for the status codes that were seen on destruction.
50 class POLICY_EXPORT PolicyLoadStatusSample { 47 class POLICY_EXPORT PolicyLoadStatusSample {
51 public: 48 public:
52 PolicyLoadStatusSample(); 49 using ReportCallback = base::Callback<void(PolicyLoadStatus status)>;
50
51 // If |report_callback| is set, status is sent to this callback. Otherwise,
emaxx 2017/05/04 13:00:34 To me this looks like stretching a single class fo
ljusten (tachyonic) 2017/05/05 08:16:27 Thanks, I like that better.
52 // status is sent to a base::LinearHistogram with name |kHistogramName|. Set
53 // the callback in situations where base::LinearHistogram cannot be used, e.g.
54 // when called from Chromium OS code.
55 PolicyLoadStatusSample(
56 const ReportCallback& report_callback = ReportCallback());
53 ~PolicyLoadStatusSample(); 57 ~PolicyLoadStatusSample();
54 58
55 // Adds a status code. 59 // Adds a status code.
56 void Add(PolicyLoadStatus status); 60 void Add(PolicyLoadStatus status);
57 61
58 private: 62 private:
59 std::bitset<POLICY_LOAD_STATUS_SIZE> status_bits_; 63 std::bitset<POLICY_LOAD_STATUS_SIZE> status_bits_;
60 base::HistogramBase* histogram_; 64 ReportCallback report_callback_;
61 65
62 DISALLOW_COPY_AND_ASSIGN(PolicyLoadStatusSample); 66 DISALLOW_COPY_AND_ASSIGN(PolicyLoadStatusSample);
63 }; 67 };
64 68
65 } // namespace policy 69 } // namespace policy
66 70
67 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOAD_STATUS_H_ 71 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOAD_STATUS_H_
OLDNEW
« no previous file with comments | « no previous file | components/policy/core/common/policy_load_status.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698