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

Side by Side Diff: chrome/browser/chromeos/settings/device_settings_service.cc

Issue 10832035: Switch from SignedSettings to DeviceSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: once more? Created 8 years, 4 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) 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/chromeos/settings/device_settings_service.h" 5 #include "chrome/browser/chromeos/settings/device_settings_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 scoped_refptr<OwnerKey> new_key(operation->owner_key()); 235 scoped_refptr<OwnerKey> new_key(operation->owner_key());
236 if (new_key.get()) { 236 if (new_key.get()) {
237 ownership_status = 237 ownership_status =
238 new_key->public_key() ? OWNERSHIP_TAKEN : OWNERSHIP_NONE; 238 new_key->public_key() ? OWNERSHIP_TAKEN : OWNERSHIP_NONE;
239 is_owner = (new_key->private_key() != NULL); 239 is_owner = (new_key->private_key() != NULL);
240 } else { 240 } else {
241 NOTREACHED() << "Failed to determine key status."; 241 NOTREACHED() << "Failed to determine key status.";
242 } 242 }
243 SetOwnershipStatus(ownership_status); 243 SetOwnershipStatus(ownership_status);
244 244
245 bool new_owner_key = false;
245 if (owner_key_.get() != new_key.get()) { 246 if (owner_key_.get() != new_key.get()) {
246 owner_key_ = new_key; 247 owner_key_ = new_key;
247 FOR_EACH_OBSERVER(Observer, observers_, OwnershipStatusChanged()); 248 new_owner_key = true;
248 content::NotificationService::current()->Notify(
249 chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED,
250 content::Source<DeviceSettingsService>(this),
251 content::NotificationService::NoDetails());
252 } 249 }
253 250
254 if (status == STORE_SUCCESS) { 251 if (status == STORE_SUCCESS) {
255 policy_data_ = operation->policy_data().Pass(); 252 policy_data_ = operation->policy_data().Pass();
256 device_settings_ = operation->device_settings().Pass(); 253 device_settings_ = operation->device_settings().Pass();
257 } else if (status != STORE_KEY_UNAVAILABLE) { 254 } else if (status != STORE_KEY_UNAVAILABLE) {
258 LOG(ERROR) << "Session manager operation failed: " << status; 255 LOG(ERROR) << "Session manager operation failed: " << status;
259 } 256 }
260 257
258 if (new_owner_key) {
259 FOR_EACH_OBSERVER(Observer, observers_, OwnershipStatusChanged());
260 content::NotificationService::current()->Notify(
261 chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED,
262 content::Source<DeviceSettingsService>(this),
263 content::NotificationService::NoDetails());
264 }
265
261 FOR_EACH_OBSERVER(Observer, observers_, DeviceSettingsUpdated()); 266 FOR_EACH_OBSERVER(Observer, observers_, DeviceSettingsUpdated());
262 267
263 std::vector<OwnershipStatusCallback> callbacks; 268 std::vector<OwnershipStatusCallback> callbacks;
264 callbacks.swap(pending_ownership_status_callbacks_); 269 callbacks.swap(pending_ownership_status_callbacks_);
265 for (std::vector<OwnershipStatusCallback>::iterator iter(callbacks.begin()); 270 for (std::vector<OwnershipStatusCallback>::iterator iter(callbacks.begin());
266 iter != callbacks.end(); ++iter) { 271 iter != callbacks.end(); ++iter) {
267 iter->Run(ownership_status, is_owner); 272 iter->Run(ownership_status, is_owner);
268 } 273 }
269 274
270 // The completion callback happens after the notification so clients can 275 // The completion callback happens after the notification so clients can
271 // filter self-triggered updates. 276 // filter self-triggered updates.
272 if (!callback.is_null()) 277 if (!callback.is_null())
273 callback.Run(); 278 callback.Run();
274 279
275 // Only remove the pending operation here, so new operations triggered by any 280 // Only remove the pending operation here, so new operations triggered by any
276 // of the callbacks above are queued up properly. 281 // of the callbacks above are queued up properly.
277 pending_operations_.pop_front(); 282 pending_operations_.pop_front();
278 delete operation; 283 delete operation;
279 284
280 StartNextOperation(); 285 StartNextOperation();
281 } 286 }
282 287
283 void DeviceSettingsService::SetOwnershipStatus(OwnershipStatus new_status) { 288 void DeviceSettingsService::SetOwnershipStatus(OwnershipStatus new_status) {
284 DCHECK(new_status == OWNERSHIP_TAKEN || new_status == OWNERSHIP_NONE); 289 DCHECK(new_status == OWNERSHIP_TAKEN || new_status == OWNERSHIP_NONE);
285 base::AutoLock lk(ownership_status_lock_); 290 base::AutoLock lk(ownership_status_lock_);
286 ownership_status_ = new_status; 291 ownership_status_ = new_status;
287 } 292 }
288 293
289 } // namespace chromeos 294 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698