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

Side by Side Diff: chrome/browser/policy/cloud/cloud_policy_store.cc

Issue 19462006: Implement fetching, caching and retrieval of external policy data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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/policy/cloud/cloud_policy_store.h" 5 #include "chrome/browser/policy/cloud/cloud_policy_store.h"
6 6
7 #include "base/logging.h"
8 #include "chrome/browser/policy/cloud/cloud_external_data_manager.h"
9
7 namespace policy { 10 namespace policy {
8 11
9 CloudPolicyStore::Observer::~Observer() {} 12 CloudPolicyStore::Observer::~Observer() {}
10 13
11 CloudPolicyStore::CloudPolicyStore() 14 CloudPolicyStore::CloudPolicyStore()
12 : status_(STATUS_OK), 15 : status_(STATUS_OK),
13 validation_status_(CloudPolicyValidatorBase::VALIDATION_OK), 16 validation_status_(CloudPolicyValidatorBase::VALIDATION_OK),
14 is_initialized_(false) {} 17 is_initialized_(false) {}
15 18
16 CloudPolicyStore::~CloudPolicyStore() {} 19 CloudPolicyStore::~CloudPolicyStore() {}
17 20
18 void CloudPolicyStore::AddObserver(CloudPolicyStore::Observer* observer) { 21 void CloudPolicyStore::AddObserver(CloudPolicyStore::Observer* observer) {
19 observers_.AddObserver(observer); 22 observers_.AddObserver(observer);
20 } 23 }
21 24
22 void CloudPolicyStore::RemoveObserver(CloudPolicyStore::Observer* observer) { 25 void CloudPolicyStore::RemoveObserver(CloudPolicyStore::Observer* observer) {
23 observers_.RemoveObserver(observer); 26 observers_.RemoveObserver(observer);
24 } 27 }
25 28
26 void CloudPolicyStore::NotifyStoreLoaded() { 29 void CloudPolicyStore::NotifyStoreLoaded() {
27 is_initialized_ = true; 30 is_initialized_ = true;
31 // The |external_data_manager_| must be notified first so that when other
32 // observers are informed about the changed policies and try to fetch external
33 // data referenced by these, the |external_data_manager_| has the required
34 // metadata already.
35 if (external_data_manager_)
36 external_data_manager_->OnPolicyStoreLoaded();
28 FOR_EACH_OBSERVER(Observer, observers_, OnStoreLoaded(this)); 37 FOR_EACH_OBSERVER(Observer, observers_, OnStoreLoaded(this));
29 } 38 }
30 39
31 void CloudPolicyStore::NotifyStoreError() { 40 void CloudPolicyStore::NotifyStoreError() {
32 is_initialized_ = true; 41 is_initialized_ = true;
33 FOR_EACH_OBSERVER(Observer, observers_, OnStoreError(this)); 42 FOR_EACH_OBSERVER(Observer, observers_, OnStoreError(this));
34 } 43 }
35 44
36 } // namespace 45 void CloudPolicyStore::SetExternalDataManager(
46 base::WeakPtr<CloudExternalDataManager> external_data_manager) {
47 DCHECK(!external_data_manager_);
48 external_data_manager_ = external_data_manager;
49 if (is_initialized_)
50 external_data_manager_->OnPolicyStoreLoaded();
51 }
52
53 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698