Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_COMPONENT_CLOUD_POLICY_STORE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_COMPONENT_CLOUD_POLICY_STORE_H_ |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_COMPONENT_CLOUD_POLICY_STORE_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_COMPONENT_CLOUD_POLICY_STORE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | |
| 10 #include <string> | 9 #include <string> |
| 11 | 10 |
| 12 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 13 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 14 #include "chrome/browser/policy/cloud/resource_cache.h" | |
| 15 #include "chrome/browser/policy/policy_bundle.h" | 15 #include "chrome/browser/policy/policy_bundle.h" |
| 16 #include "components/policy/core/common/policy_namespace.h" | 16 #include "components/policy/core/common/policy_namespace.h" |
| 17 | 17 |
| 18 namespace enterprise_management { | 18 namespace enterprise_management { |
| 19 class ExternalPolicyData; | 19 class ExternalPolicyData; |
| 20 class PolicyData; | 20 class PolicyData; |
| 21 class PolicyFetchResponse; | 21 class PolicyFetchResponse; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace policy { | 24 namespace policy { |
| 25 | 25 |
| 26 class ResourceCache; | |
| 27 | |
| 28 // Validates protobufs for external policy data, validates the data itself, and | 26 // Validates protobufs for external policy data, validates the data itself, and |
| 29 // caches both locally. | 27 // caches both locally. |
| 30 class ComponentCloudPolicyStore : public base::NonThreadSafe { | 28 class ComponentCloudPolicyStore : public base::NonThreadSafe { |
| 31 public: | 29 public: |
| 32 class Delegate { | 30 class Delegate { |
| 33 public: | 31 public: |
| 34 virtual ~Delegate(); | 32 virtual ~Delegate(); |
| 35 | 33 |
| 36 // Invoked whenever the policies served by policy() have changed, except | 34 // Invoked whenever the policies served by policy() have changed, except |
| 37 // for the initial Load(). | 35 // for the initial Load(). |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 // Returns false if |data| failed validation, otherwise returns true and the | 82 // Returns false if |data| failed validation, otherwise returns true and the |
| 85 // data was stored in the cache. | 83 // data was stored in the cache. |
| 86 bool Store(const PolicyNamespace& ns, | 84 bool Store(const PolicyNamespace& ns, |
| 87 const std::string& serialized_policy_proto, | 85 const std::string& serialized_policy_proto, |
| 88 const std::string& secure_hash, | 86 const std::string& secure_hash, |
| 89 const std::string& data); | 87 const std::string& data); |
| 90 | 88 |
| 91 // Deletes the storage of namespace |ns| and stops serving its policies. | 89 // Deletes the storage of namespace |ns| and stops serving its policies. |
| 92 void Delete(const PolicyNamespace& ns); | 90 void Delete(const PolicyNamespace& ns); |
| 93 | 91 |
| 94 // Deletes the storage of all components of |domain| that are not in | 92 // Deletes the storage of all components of |domain| that pass then given |
|
bartfab (slow)
2013/11/05 15:53:04
It is kind of weird that those which pass the test
Joao da Silva
2013/11/07 13:15:00
It has been renamed to SubkeyFilter.
| |
| 95 // |components_to_keep|, and stops serving their policies. | 93 // |test|, and stops serving their policies. |
| 96 void Purge(PolicyDomain domain, | 94 void Purge(PolicyDomain domain, |
| 97 const std::set<std::string>& components_to_keep); | 95 const ResourceCache::KeyTest& test); |
| 98 | 96 |
| 99 // Validates |proto| and returns the corresponding policy namespace in |ns|, | 97 // Validates |proto| and returns the corresponding policy namespace in |ns|, |
| 100 // and the parsed ExternalPolicyData in |payload|. | 98 // and the parsed ExternalPolicyData in |payload|. |
| 101 // If |proto| validates successfully then its |payload| can be trusted, and | 99 // If |proto| validates successfully then its |payload| can be trusted, and |
| 102 // the data referenced there can be downloaded. A |proto| must be validated | 100 // the data referenced there can be downloaded. A |proto| must be validated |
| 103 // before attempting to download the data, and before storing both. | 101 // before attempting to download the data, and before storing both. |
| 104 bool ValidatePolicy( | 102 bool ValidatePolicy( |
| 105 scoped_ptr<enterprise_management::PolicyFetchResponse> proto, | 103 scoped_ptr<enterprise_management::PolicyFetchResponse> proto, |
| 106 PolicyNamespace* ns, | 104 PolicyNamespace* ns, |
| 107 enterprise_management::ExternalPolicyData* payload); | 105 enterprise_management::ExternalPolicyData* payload); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 134 | 132 |
| 135 PolicyBundle policy_bundle_; | 133 PolicyBundle policy_bundle_; |
| 136 std::map<PolicyNamespace, std::string> cached_hashes_; | 134 std::map<PolicyNamespace, std::string> cached_hashes_; |
| 137 | 135 |
| 138 DISALLOW_COPY_AND_ASSIGN(ComponentCloudPolicyStore); | 136 DISALLOW_COPY_AND_ASSIGN(ComponentCloudPolicyStore); |
| 139 }; | 137 }; |
| 140 | 138 |
| 141 } // namespace policy | 139 } // namespace policy |
| 142 | 140 |
| 143 #endif // CHROME_BROWSER_POLICY_CLOUD_COMPONENT_CLOUD_POLICY_STORE_H_ | 141 #endif // CHROME_BROWSER_POLICY_CLOUD_COMPONENT_CLOUD_POLICY_STORE_H_ |
| OLD | NEW |