1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_POLICY_POLICY_STATISTICS_COLLECTOR_H_
6 #define CHROME_BROWSER_POLICY_POLICY_STATISTICS_COLLECTOR_H_
8 #include "base/basictypes.h"
9 #include "base/cancelable_callback.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/time/time.h"
14 class PrefRegistrySimple;
24 // Manages regular updates of policy usage UMA histograms.
25 class PolicyStatisticsCollector {
27 // Policy usage statistics update rate, in milliseconds.
28 static const int kStatisticsUpdateRate;
30 // Neither |policy_service| nor |prefs| can be NULL and must stay valid
31 // throughout the lifetime of PolicyStatisticsCollector.
32 PolicyStatisticsCollector(PolicyService* policy_service,
34 const scoped_refptr<base::TaskRunner>& task_runner);
35 virtual ~PolicyStatisticsCollector();
37 // Completes initialization and starts periodical statistic updates.
40 static void RegisterPrefs(PrefRegistrySimple* registry);
43 // protected virtual for mocking.
44 virtual void RecordPolicyUse(int id);
47 void CollectStatistics();
48 void ScheduleUpdate(base::TimeDelta delay);
50 PolicyService* policy_service_;
53 base::CancelableClosure update_callback_;
55 const scoped_refptr<base::TaskRunner> task_runner_;
57 DISALLOW_COPY_AND_ASSIGN(PolicyStatisticsCollector);
62 #endif // CHROME_BROWSER_POLICY_POLICY_STATISTICS_COLLECTOR_H_