| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_POLICY_POLICY_STATISTICS_COLLECTOR_H_ | |
| 6 #define CHROME_BROWSER_POLICY_POLICY_STATISTICS_COLLECTOR_H_ | |
| 7 | |
| 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 | |
| 15 class PrefService; | |
| 16 class PrefRegistrySimple; | |
| 17 | |
| 18 namespace base { | |
| 19 class TaskRunner; | |
| 20 } | |
| 21 | |
| 22 namespace policy { | |
| 23 | |
| 24 class PolicyService; | |
| 25 | |
| 26 // Manages regular updates of policy usage UMA histograms. | |
| 27 class PolicyStatisticsCollector { | |
| 28 public: | |
| 29 // Policy usage statistics update rate, in milliseconds. | |
| 30 static const int kStatisticsUpdateRate; | |
| 31 | |
| 32 // Neither |policy_service| nor |prefs| can be NULL and must stay valid | |
| 33 // throughout the lifetime of PolicyStatisticsCollector. | |
| 34 PolicyStatisticsCollector(const GetChromePolicyDetailsCallback& get_details, | |
| 35 const Schema& chrome_schema, | |
| 36 PolicyService* policy_service, | |
| 37 PrefService* prefs, | |
| 38 const scoped_refptr<base::TaskRunner>& task_runner); | |
| 39 virtual ~PolicyStatisticsCollector(); | |
| 40 | |
| 41 // Completes initialization and starts periodical statistic updates. | |
| 42 void Initialize(); | |
| 43 | |
| 44 static void RegisterPrefs(PrefRegistrySimple* registry); | |
| 45 | |
| 46 protected: | |
| 47 // protected virtual for mocking. | |
| 48 virtual void RecordPolicyUse(int id); | |
| 49 | |
| 50 private: | |
| 51 void CollectStatistics(); | |
| 52 void ScheduleUpdate(base::TimeDelta delay); | |
| 53 | |
| 54 GetChromePolicyDetailsCallback get_details_; | |
| 55 Schema chrome_schema_; | |
| 56 PolicyService* policy_service_; | |
| 57 PrefService* prefs_; | |
| 58 | |
| 59 base::CancelableClosure update_callback_; | |
| 60 | |
| 61 const scoped_refptr<base::TaskRunner> task_runner_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(PolicyStatisticsCollector); | |
| 64 }; | |
| 65 | |
| 66 } // namespace policy | |
| 67 | |
| 68 #endif // CHROME_BROWSER_POLICY_POLICY_STATISTICS_COLLECTOR_H_ | |
| OLD | NEW |