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

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

Issue 5219006: Refresh policies from DM server periodically (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 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) 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // Decode and swap in the new policy information. 98 // Decode and swap in the new policy information.
99 scoped_ptr<DictionaryValue> value(DecodePolicy(cached_policy.policy())); 99 scoped_ptr<DictionaryValue> value(DecodePolicy(cached_policy.policy()));
100 { 100 {
101 AutoLock lock(lock_); 101 AutoLock lock(lock_);
102 if (!fresh_policy_) 102 if (!fresh_policy_)
103 policy_.reset(value.release()); 103 policy_.reset(value.release());
104 last_policy_refresh_time_ = timestamp; 104 last_policy_refresh_time_ = timestamp;
105 } 105 }
106 } 106 }
107 107
108 void DeviceManagementPolicyCache::SetPolicy( 108 bool DeviceManagementPolicyCache::SetPolicy(
109 const em::DevicePolicyResponse& policy) { 109 const em::DevicePolicyResponse& policy) {
110 DictionaryValue* value = DeviceManagementPolicyCache::DecodePolicy(policy); 110 DictionaryValue* value = DeviceManagementPolicyCache::DecodePolicy(policy);
111 bool new_policy_differs = !(value->Equals(policy_.get()));
danno 2010/11/22 13:47:50 const bool
Jakob Kummerow (corp) 2010/11/22 16:56:08 Done.
111 base::Time now(base::Time::Now()); 112 base::Time now(base::Time::Now());
112 { 113 {
113 AutoLock lock(lock_); 114 AutoLock lock(lock_);
114 policy_.reset(value); 115 policy_.reset(value);
115 fresh_policy_ = true; 116 fresh_policy_ = true;
116 last_policy_refresh_time_ = now; 117 last_policy_refresh_time_ = now;
117 } 118 }
118 119
119 em::DevicePolicyResponse* policy_copy = new em::DevicePolicyResponse; 120 em::DevicePolicyResponse* policy_copy = new em::DevicePolicyResponse;
120 policy_copy->CopyFrom(policy); 121 policy_copy->CopyFrom(policy);
121 BrowserThread::PostTask( 122 BrowserThread::PostTask(
122 BrowserThread::FILE, 123 BrowserThread::FILE,
123 FROM_HERE, 124 FROM_HERE,
124 new PersistPolicyTask(backing_file_path_, policy_copy, 125 new PersistPolicyTask(backing_file_path_, policy_copy,
125 base::Time::NowFromSystemTime())); 126 base::Time::NowFromSystemTime()));
127 return new_policy_differs;
126 } 128 }
127 129
128 DictionaryValue* DeviceManagementPolicyCache::GetPolicy() { 130 DictionaryValue* DeviceManagementPolicyCache::GetPolicy() {
129 AutoLock lock(lock_); 131 AutoLock lock(lock_);
130 return static_cast<DictionaryValue*>(policy_->DeepCopy()); 132 return static_cast<DictionaryValue*>(policy_->DeepCopy());
131 } 133 }
132 134
133 // static 135 // static
134 Value* DeviceManagementPolicyCache::DecodeIntegerValue( 136 Value* DeviceManagementPolicyCache::DecodeIntegerValue(
135 google::protobuf::int64 value) { 137 google::protobuf::int64 value) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 DeviceManagementPolicyCache::DecodeValue(named_value->value()); 237 DeviceManagementPolicyCache::DecodeValue(named_value->value());
236 if (decoded_value) 238 if (decoded_value)
237 result->Set(named_value->name(), decoded_value); 239 result->Set(named_value->name(), decoded_value);
238 } 240 }
239 } 241 }
240 } 242 }
241 return result; 243 return result;
242 } 244 }
243 245
244 } // namespace policy 246 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698