| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_ |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 } | 66 } |
| 67 bool is_managed() const { | 67 bool is_managed() const { |
| 68 return policy_.get() && | 68 return policy_.get() && |
| 69 policy_->state() == enterprise_management::PolicyData::ACTIVE; | 69 policy_->state() == enterprise_management::PolicyData::ACTIVE; |
| 70 } | 70 } |
| 71 Status status() const { return status_; } | 71 Status status() const { return status_; } |
| 72 CloudPolicyValidatorBase::Status validation_status() const { | 72 CloudPolicyValidatorBase::Status validation_status() const { |
| 73 return validation_status_; | 73 return validation_status_; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Store a new policy blob. Pending store operations will be canceled. The | 76 // Store a new policy blob. Pending load/store operations will be canceled. |
| 77 // store operation may proceed asynchronously and observers are notified once | 77 // The store operation may proceed asynchronously and observers are notified |
| 78 // the operation finishes. If successful, OnStoreLoaded() will be invoked on | 78 // once the operation finishes. If successful, OnStoreLoaded() will be invoked |
| 79 // the observers and the updated policy can be read through policy(). Errors | 79 // on the observers and the updated policy can be read through policy(). |
| 80 // generate OnStoreError() notifications. | 80 // Errors generate OnStoreError() notifications. |
| 81 virtual void Store( | 81 virtual void Store( |
| 82 const enterprise_management::PolicyFetchResponse& policy) = 0; | 82 const enterprise_management::PolicyFetchResponse& policy) = 0; |
| 83 | 83 |
| 84 // Load the current policy blob from persistent storage. This may trigger | 84 // Load the current policy blob from persistent storage. Pending load/store |
| 85 // asynchronous operations. Upon success, OnStoreLoaded() will be called on | 85 // operations will be canceled. This may trigger asynchronous operations. |
| 86 // the registered observers. Otherwise, OnStoreError() reports the reason for | 86 // Upon success, OnStoreLoaded() will be called on the registered observers. |
| 87 // failure. | 87 // Otherwise, OnStoreError() reports the reason for failure. |
| 88 virtual void Load() = 0; | 88 virtual void Load() = 0; |
| 89 | 89 |
| 90 // Deletes any existing policy blob and notifies observers via OnStoreLoaded() | 90 // Deletes any existing policy blob and notifies observers via OnStoreLoaded() |
| 91 // that the blob has changed. Virtual for mocks. | 91 // that the blob has changed. Virtual for mocks. |
| 92 virtual void Clear(); | 92 virtual void Clear(); |
| 93 | 93 |
| 94 // Registers an observer to be notified when policy changes. | 94 // Registers an observer to be notified when policy changes. |
| 95 void AddObserver(Observer* observer); | 95 void AddObserver(Observer* observer); |
| 96 | 96 |
| 97 // Removes the specified observer. | 97 // Removes the specified observer. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 bool is_initialized_; | 129 bool is_initialized_; |
| 130 | 130 |
| 131 ObserverList<Observer, true> observers_; | 131 ObserverList<Observer, true> observers_; |
| 132 | 132 |
| 133 DISALLOW_COPY_AND_ASSIGN(CloudPolicyStore); | 133 DISALLOW_COPY_AND_ASSIGN(CloudPolicyStore); |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 } // namespace policy | 136 } // namespace policy |
| 137 | 137 |
| 138 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_ | 138 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_STORE_H_ |
| OLD | NEW |