Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_POLICY_POLICY_STATISTICS_COLLECTOR_H_ | 5 #ifndef CHROME_BROWSER_POLICY_POLICY_STATISTICS_COLLECTOR_H_ |
| 6 #define CHROME_BROWSER_POLICY_POLICY_STATISTICS_COLLECTOR_H_ | 6 #define CHROME_BROWSER_POLICY_POLICY_STATISTICS_COLLECTOR_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/cancelable_callback.h" | 9 #include "base/cancelable_callback.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 | 12 |
| 13 class PrefService; | 13 class PrefService; |
| 14 class PrefServiceSimple; | |
| 15 class PrefServiceSyncable; | |
|
Mattias Nissler (ping if slow)
2012/12/20 13:41:52
needed?
Jói
2012/12/20 16:30:31
Removed.
| |
| 14 | 16 |
| 15 namespace base { | 17 namespace base { |
| 16 class TaskRunner; | 18 class TaskRunner; |
| 17 } | 19 } |
| 18 | 20 |
| 19 namespace policy { | 21 namespace policy { |
| 20 | 22 |
| 21 class PolicyService; | 23 class PolicyService; |
| 22 | 24 |
| 23 // Manages regular updates of policy usage UMA histograms. | 25 // Manages regular updates of policy usage UMA histograms. |
| 24 class PolicyStatisticsCollector { | 26 class PolicyStatisticsCollector { |
| 25 public: | 27 public: |
| 26 // Policy usage statistics update rate, in milliseconds. | 28 // Policy usage statistics update rate, in milliseconds. |
| 27 static const int kStatisticsUpdateRate; | 29 static const int kStatisticsUpdateRate; |
| 28 | 30 |
| 29 // Neither |policy_service| nor |prefs| can be NULL and must stay valid | 31 // Neither |policy_service| nor |prefs| can be NULL and must stay valid |
| 30 // throughout the lifetime of PolicyStatisticsCollector. | 32 // throughout the lifetime of PolicyStatisticsCollector. |
| 31 PolicyStatisticsCollector(PolicyService* policy_service, | 33 PolicyStatisticsCollector(PolicyService* policy_service, |
| 32 PrefService* prefs, | 34 PrefService* prefs, |
| 33 const scoped_refptr<base::TaskRunner>& task_runner); | 35 const scoped_refptr<base::TaskRunner>& task_runner); |
| 34 virtual ~PolicyStatisticsCollector(); | 36 virtual ~PolicyStatisticsCollector(); |
| 35 | 37 |
| 36 // Completes initialization and starts periodical statistic updates. | 38 // Completes initialization and starts periodical statistic updates. |
| 37 void Initialize(); | 39 void Initialize(); |
| 38 | 40 |
| 39 static void RegisterPrefs(PrefService* prefs); | 41 static void RegisterPrefs(PrefServiceSimple* prefs); |
| 40 | 42 |
| 41 protected: | 43 protected: |
| 42 // protected virtual for mocking. | 44 // protected virtual for mocking. |
| 43 virtual void RecordPolicyUse(int id); | 45 virtual void RecordPolicyUse(int id); |
| 44 | 46 |
| 45 private: | 47 private: |
| 46 void CollectStatistics(); | 48 void CollectStatistics(); |
| 47 void ScheduleUpdate(base::TimeDelta delay); | 49 void ScheduleUpdate(base::TimeDelta delay); |
| 48 | 50 |
| 49 int max_policy_id_; | 51 int max_policy_id_; |
| 50 | 52 |
| 51 PolicyService* policy_service_; | 53 PolicyService* policy_service_; |
| 52 PrefService* prefs_; | 54 PrefService* prefs_; |
| 53 | 55 |
| 54 base::CancelableClosure update_callback_; | 56 base::CancelableClosure update_callback_; |
| 55 | 57 |
| 56 const scoped_refptr<base::TaskRunner> task_runner_; | 58 const scoped_refptr<base::TaskRunner> task_runner_; |
| 57 | 59 |
| 58 DISALLOW_COPY_AND_ASSIGN(PolicyStatisticsCollector); | 60 DISALLOW_COPY_AND_ASSIGN(PolicyStatisticsCollector); |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 } // namespace policy | 63 } // namespace policy |
| 62 | 64 |
| 63 #endif // CHROME_BROWSER_POLICY_POLICY_STATISTICS_COLLECTOR_H_ | 65 #endif // CHROME_BROWSER_POLICY_POLICY_STATISTICS_COLLECTOR_H_ |
| OLD | NEW |