| 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_USER_POLICY_CACHE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ |
| 6 #define CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ | 6 #define CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 // UserPolicyDiskCache::Delegate implementation: | 54 // UserPolicyDiskCache::Delegate implementation: |
| 55 virtual void OnDiskCacheLoaded( | 55 virtual void OnDiskCacheLoaded( |
| 56 UserPolicyDiskCache::LoadResult result, | 56 UserPolicyDiskCache::LoadResult result, |
| 57 const enterprise_management::CachedCloudPolicyResponse& | 57 const enterprise_management::CachedCloudPolicyResponse& |
| 58 cached_response) OVERRIDE; | 58 cached_response) OVERRIDE; |
| 59 | 59 |
| 60 // CloudPolicyCacheBase implementation: | 60 // CloudPolicyCacheBase implementation: |
| 61 virtual bool DecodePolicyData( | 61 virtual bool DecodePolicyData( |
| 62 const enterprise_management::PolicyData& policy_data, | 62 const enterprise_management::PolicyData& policy_data, |
| 63 PolicyMap* mandatory, | 63 PolicyMap* policies) OVERRIDE; |
| 64 PolicyMap* recommended) OVERRIDE; | |
| 65 | 64 |
| 66 // Checks if this cache is ready, and invokes SetReady() if so. | 65 // Checks if this cache is ready, and invokes SetReady() if so. |
| 67 void CheckIfReady(); | 66 void CheckIfReady(); |
| 68 | 67 |
| 69 // <Old-style policy support> | 68 // <Old-style policy support> |
| 70 // The following member functions are needed to support old-style policy and | 69 // The following member functions are needed to support old-style policy and |
| 71 // can be removed once all server-side components (CPanel, D3) have been | 70 // can be removed once all server-side components (CPanel, D3) have been |
| 72 // migrated to providing the new policy format. | 71 // migrated to providing the new policy format. |
| 73 | 72 // |
| 74 // If |mandatory| and |recommended| are both empty, and |policy_data| | 73 // If |policies| is empty and |policy_data| contains a field named |
| 75 // contains a field named "repeated GenericNamedValue named_value = 2;", | 74 // "repeated GenericNamedValue named_value = 2;", the policies in that field |
| 76 // this field is decoded into |mandatory|. | 75 // are added to |policies| as LEVEL_MANDATORY, SCOPE_USER policies. |
| 77 void MaybeDecodeOldstylePolicy(const std::string& policy_data, | 76 void MaybeDecodeOldstylePolicy(const std::string& policy_data, |
| 78 PolicyMap* mandatory, | 77 PolicyMap* policies); |
| 79 PolicyMap* recommended); | |
| 80 | 78 |
| 81 Value* DecodeIntegerValue(google::protobuf::int64 value) const; | 79 Value* DecodeIntegerValue(google::protobuf::int64 value) const; |
| 82 Value* DecodeValue(const enterprise_management::GenericValue& value) const; | 80 Value* DecodeValue(const enterprise_management::GenericValue& value) const; |
| 83 | 81 |
| 84 // </Old-style policy support> | 82 // </Old-style policy support> |
| 85 | 83 |
| 86 // Manages the cache file. | 84 // Manages the cache file. |
| 87 scoped_refptr<UserPolicyDiskCache> disk_cache_; | 85 scoped_refptr<UserPolicyDiskCache> disk_cache_; |
| 88 | 86 |
| 89 // Used for constructing the weak ptr passed to |disk_cache_|. | 87 // Used for constructing the weak ptr passed to |disk_cache_|. |
| 90 base::WeakPtrFactory<UserPolicyDiskCache::Delegate> weak_ptr_factory_; | 88 base::WeakPtrFactory<UserPolicyDiskCache::Delegate> weak_ptr_factory_; |
| 91 | 89 |
| 92 // True if the disk cache has been loaded. | 90 // True if the disk cache has been loaded. |
| 93 bool disk_cache_ready_; | 91 bool disk_cache_ready_; |
| 94 | 92 |
| 95 // True if at least one attempt was made to refresh the cache with a freshly | 93 // True if at least one attempt was made to refresh the cache with a freshly |
| 96 // fetched policy, or if there is no need to wait for that. | 94 // fetched policy, or if there is no need to wait for that. |
| 97 bool fetch_ready_; | 95 bool fetch_ready_; |
| 98 | 96 |
| 99 DISALLOW_COPY_AND_ASSIGN(UserPolicyCache); | 97 DISALLOW_COPY_AND_ASSIGN(UserPolicyCache); |
| 100 }; | 98 }; |
| 101 | 99 |
| 102 } // namespace policy | 100 } // namespace policy |
| 103 | 101 |
| 104 #endif // CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ | 102 #endif // CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ |
| OLD | NEW |