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

Side by Side Diff: chrome/browser/policy/policy_statistics_collector.cc

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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 | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/policy/policy_statistics_collector.h" 5 #include "chrome/browser/policy/policy_statistics_collector.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 Time last_update = Time::FromInternalValue( 42 Time last_update = Time::FromInternalValue(
43 prefs_->GetInt64(prefs::kLastPolicyStatisticsUpdate)); 43 prefs_->GetInt64(prefs::kLastPolicyStatisticsUpdate));
44 TimeDelta delay = std::max(Time::Now() - last_update, TimeDelta::FromDays(0)); 44 TimeDelta delay = std::max(Time::Now() - last_update, TimeDelta::FromDays(0));
45 if (delay >= update_rate) 45 if (delay >= update_rate)
46 CollectStatistics(); 46 CollectStatistics();
47 else 47 else
48 ScheduleUpdate(update_rate - delay); 48 ScheduleUpdate(update_rate - delay);
49 } 49 }
50 50
51 // static 51 // static
52 void PolicyStatisticsCollector::RegisterPrefs(PrefService* prefs) { 52 void PolicyStatisticsCollector::RegisterPrefs(PrefServiceSimple* prefs) {
53 prefs->RegisterInt64Pref(prefs::kLastPolicyStatisticsUpdate, 0, 53 prefs->RegisterInt64Pref(prefs::kLastPolicyStatisticsUpdate, 0);
54 PrefService::UNSYNCABLE_PREF);
55 } 54 }
56 55
57 void PolicyStatisticsCollector::RecordPolicyUse(int id) { 56 void PolicyStatisticsCollector::RecordPolicyUse(int id) {
58 if (max_policy_id_ == -1) { 57 if (max_policy_id_ == -1) {
59 const policy::PolicyDefinitionList* policy_list = 58 const policy::PolicyDefinitionList* policy_list =
60 policy::GetChromePolicyDefinitionList(); 59 policy::GetChromePolicyDefinitionList();
61 for (const policy::PolicyDefinitionList::Entry* policy = policy_list->begin; 60 for (const policy::PolicyDefinitionList::Entry* policy = policy_list->begin;
62 policy != policy_list->end; ++policy) { 61 policy != policy_list->end; ++policy) {
63 if (policy->id > max_policy_id_) 62 if (policy->id > max_policy_id_)
64 max_policy_id_ = policy->id; 63 max_policy_id_ = policy->id;
(...skipping 27 matching lines...) Expand all
92 } 91 }
93 92
94 void PolicyStatisticsCollector::ScheduleUpdate(base::TimeDelta delay) { 93 void PolicyStatisticsCollector::ScheduleUpdate(base::TimeDelta delay) {
95 update_callback_.Reset(base::Bind( 94 update_callback_.Reset(base::Bind(
96 &PolicyStatisticsCollector::CollectStatistics, 95 &PolicyStatisticsCollector::CollectStatistics,
97 base::Unretained(this))); 96 base::Unretained(this)));
98 task_runner_->PostDelayedTask(FROM_HERE, update_callback_.callback(), delay); 97 task_runner_->PostDelayedTask(FROM_HERE, update_callback_.callback(), delay);
99 } 98 }
100 99
101 } // namespace policy 100 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_statistics_collector.h ('k') | chrome/browser/policy/policy_statistics_collector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698