Ignore title parameter for navigator.registerProtocolHandler
[chromium-blink-merge.git] / components / policy / core / common / policy_statistics_collector.h
blobf062ea3eb3a52064f78151f43de7fb21b7960f44
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 COMPONENTS_POLICY_CORE_COMMON_POLICY_STATISTICS_COLLECTOR_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_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"
12 #include "components/policy/core/common/policy_details.h"
13 #include "components/policy/core/common/schema.h"
14 #include "components/policy/policy_export.h"
16 class PrefService;
17 class PrefRegistrySimple;
19 namespace base {
20 class TaskRunner;
23 namespace policy {
25 class PolicyService;
27 // Manages regular updates of policy usage UMA histograms.
28 class POLICY_EXPORT PolicyStatisticsCollector {
29 public:
30 // Policy usage statistics update rate, in milliseconds.
31 static const int kStatisticsUpdateRate;
33 // Neither |policy_service| nor |prefs| can be NULL and must stay valid
34 // throughout the lifetime of PolicyStatisticsCollector.
35 PolicyStatisticsCollector(const GetChromePolicyDetailsCallback& get_details,
36 const Schema& chrome_schema,
37 PolicyService* policy_service,
38 PrefService* prefs,
39 const scoped_refptr<base::TaskRunner>& task_runner);
40 virtual ~PolicyStatisticsCollector();
42 // Completes initialization and starts periodical statistic updates.
43 void Initialize();
45 static void RegisterPrefs(PrefRegistrySimple* registry);
47 protected:
48 // protected virtual for mocking.
49 virtual void RecordPolicyUse(int id);
51 private:
52 void CollectStatistics();
53 void ScheduleUpdate(base::TimeDelta delay);
55 GetChromePolicyDetailsCallback get_details_;
56 Schema chrome_schema_;
57 PolicyService* policy_service_;
58 PrefService* prefs_;
60 base::CancelableClosure update_callback_;
62 const scoped_refptr<base::TaskRunner> task_runner_;
64 DISALLOW_COPY_AND_ASSIGN(PolicyStatisticsCollector);
67 } // namespace policy
69 #endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_STATISTICS_COLLECTOR_H_