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

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

Issue 6142009: Upating the app, ceee, chrome, ipc, media, and net directories to use the correct lock.h file. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Unified patch updating all references to the new base/synchronization/lock.h 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (timestamp > base::Time::NowFromSystemTime()) { 97 if (timestamp > base::Time::NowFromSystemTime()) {
98 LOG(WARNING) << "Rejected policy data from " << backing_file_path_.value() 98 LOG(WARNING) << "Rejected policy data from " << backing_file_path_.value()
99 << ", file is from the future."; 99 << ", file is from the future.";
100 return; 100 return;
101 } 101 }
102 is_device_unmanaged_ = cached_policy.unmanaged(); 102 is_device_unmanaged_ = cached_policy.unmanaged();
103 103
104 // Decode and swap in the new policy information. 104 // Decode and swap in the new policy information.
105 scoped_ptr<DictionaryValue> value(DecodePolicy(cached_policy.policy())); 105 scoped_ptr<DictionaryValue> value(DecodePolicy(cached_policy.policy()));
106 { 106 {
107 AutoLock lock(lock_); 107 base::AutoLock lock(lock_);
108 if (!fresh_policy_) 108 if (!fresh_policy_)
109 policy_.reset(value.release()); 109 policy_.reset(value.release());
110 last_policy_refresh_time_ = timestamp; 110 last_policy_refresh_time_ = timestamp;
111 } 111 }
112 } 112 }
113 113
114 bool DeviceManagementPolicyCache::SetPolicy( 114 bool DeviceManagementPolicyCache::SetPolicy(
115 const em::DevicePolicyResponse& policy) { 115 const em::DevicePolicyResponse& policy) {
116 is_device_unmanaged_ = false; 116 is_device_unmanaged_ = false;
117 DictionaryValue* value = DeviceManagementPolicyCache::DecodePolicy(policy); 117 DictionaryValue* value = DeviceManagementPolicyCache::DecodePolicy(policy);
118 const bool new_policy_differs = !(value->Equals(policy_.get())); 118 const bool new_policy_differs = !(value->Equals(policy_.get()));
119 base::Time now(base::Time::NowFromSystemTime()); 119 base::Time now(base::Time::NowFromSystemTime());
120 { 120 {
121 AutoLock lock(lock_); 121 base::AutoLock lock(lock_);
122 policy_.reset(value); 122 policy_.reset(value);
123 fresh_policy_ = true; 123 fresh_policy_ = true;
124 last_policy_refresh_time_ = now; 124 last_policy_refresh_time_ = now;
125 } 125 }
126 126
127 em::DevicePolicyResponse* policy_copy = new em::DevicePolicyResponse; 127 em::DevicePolicyResponse* policy_copy = new em::DevicePolicyResponse;
128 policy_copy->CopyFrom(policy); 128 policy_copy->CopyFrom(policy);
129 BrowserThread::PostTask( 129 BrowserThread::PostTask(
130 BrowserThread::FILE, 130 BrowserThread::FILE,
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 base::AutoLock lock(lock_);
138 return static_cast<DictionaryValue*>(policy_->DeepCopy()); 138 return static_cast<DictionaryValue*>(policy_->DeepCopy());
139 } 139 }
140 140
141 void DeviceManagementPolicyCache::SetDeviceUnmanaged(bool is_device_unmanaged) { 141 void DeviceManagementPolicyCache::SetDeviceUnmanaged(bool is_device_unmanaged) {
142 if (is_device_unmanaged_ == is_device_unmanaged) 142 if (is_device_unmanaged_ == is_device_unmanaged)
143 return; 143 return;
144 144
145 is_device_unmanaged_ = is_device_unmanaged; 145 is_device_unmanaged_ = is_device_unmanaged;
146 base::Time now(base::Time::NowFromSystemTime()); 146 base::Time now(base::Time::NowFromSystemTime());
147 DictionaryValue* empty = new DictionaryValue(); 147 DictionaryValue* empty = new DictionaryValue();
148 { 148 {
149 AutoLock lock(lock_); 149 base::AutoLock lock(lock_);
150 policy_.reset(empty); 150 policy_.reset(empty);
151 last_policy_refresh_time_ = now; 151 last_policy_refresh_time_ = now;
152 } 152 }
153 BrowserThread::PostTask( 153 BrowserThread::PostTask(
154 BrowserThread::FILE, 154 BrowserThread::FILE,
155 FROM_HERE, 155 FROM_HERE,
156 new PersistPolicyTask(backing_file_path_, 156 new PersistPolicyTask(backing_file_path_,
157 (is_device_unmanaged ? NULL 157 (is_device_unmanaged ? NULL
158 : new em::DevicePolicyResponse()), 158 : new em::DevicePolicyResponse()),
159 now, 159 now,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 DeviceManagementPolicyCache::DecodeValue(named_value->value()); 269 DeviceManagementPolicyCache::DecodeValue(named_value->value());
270 if (decoded_value) 270 if (decoded_value)
271 result->Set(named_value->name(), decoded_value); 271 result->Set(named_value->name(), decoded_value);
272 } 272 }
273 } 273 }
274 } 274 }
275 return result; 275 return result;
276 } 276 }
277 277
278 } // namespace policy 278 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_management_policy_cache.h ('k') | chrome/browser/printing/print_dialog_cloud.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698