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

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

Issue 6310012: Allow policy refresh rate to be configured through policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test. Created 9 years, 11 months 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/device_management_policy_cache.h" 5 #include "chrome/browser/policy/device_management_policy_cache.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 FROM_HERE, 131 FROM_HERE,
132 new PersistPolicyTask(backing_file_path_, policy_copy, now, false)); 132 new PersistPolicyTask(backing_file_path_, policy_copy, now, false));
133 return new_policy_differs; 133 return new_policy_differs;
134 } 134 }
135 135
136 DictionaryValue* DeviceManagementPolicyCache::GetPolicy() { 136 DictionaryValue* DeviceManagementPolicyCache::GetPolicy() {
137 AutoLock lock(lock_); 137 AutoLock lock(lock_);
138 return policy_->DeepCopy(); 138 return policy_->DeepCopy();
139 } 139 }
140 140
141 void DeviceManagementPolicyCache::SetDeviceUnmanaged(bool is_device_unmanaged) { 141 void DeviceManagementPolicyCache::SetDeviceUnmanaged() {
142 if (is_device_unmanaged_ == is_device_unmanaged) 142 is_device_unmanaged_ = true;
143 return;
144
145 is_device_unmanaged_ = is_device_unmanaged;
146 base::Time now(base::Time::NowFromSystemTime()); 143 base::Time now(base::Time::NowFromSystemTime());
147 DictionaryValue* empty = new DictionaryValue();
148 { 144 {
149 AutoLock lock(lock_); 145 AutoLock lock(lock_);
150 policy_.reset(empty); 146 policy_.reset(new DictionaryValue);
151 last_policy_refresh_time_ = now; 147 last_policy_refresh_time_ = now;
152 } 148 }
153 BrowserThread::PostTask( 149 BrowserThread::PostTask(
154 BrowserThread::FILE, 150 BrowserThread::FILE,
155 FROM_HERE, 151 FROM_HERE,
156 new PersistPolicyTask(backing_file_path_, 152 new PersistPolicyTask(backing_file_path_, NULL, now, true));
157 (is_device_unmanaged ? NULL
158 : new em::DevicePolicyResponse()),
159 now,
160 is_device_unmanaged_));
161 } 153 }
162 154
163 // static 155 // static
164 Value* DeviceManagementPolicyCache::DecodeIntegerValue( 156 Value* DeviceManagementPolicyCache::DecodeIntegerValue(
165 google::protobuf::int64 value) { 157 google::protobuf::int64 value) {
166 if (value < std::numeric_limits<int>::min() || 158 if (value < std::numeric_limits<int>::min() ||
167 value > std::numeric_limits<int>::max()) { 159 value > std::numeric_limits<int>::max()) {
168 LOG(WARNING) << "Integer value " << value 160 LOG(WARNING) << "Integer value " << value
169 << " out of numeric limits, ignoring."; 161 << " out of numeric limits, ignoring.";
170 return NULL; 162 return NULL;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 DeviceManagementPolicyCache::DecodeValue(named_value->value()); 261 DeviceManagementPolicyCache::DecodeValue(named_value->value());
270 if (decoded_value) 262 if (decoded_value)
271 result->Set(named_value->name(), decoded_value); 263 result->Set(named_value->name(), decoded_value);
272 } 264 }
273 } 265 }
274 } 266 }
275 return result; 267 return result;
276 } 268 }
277 269
278 } // namespace policy 270 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_management_policy_cache.h ('k') | chrome/browser/policy/device_management_policy_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698