| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 15 matching lines...) Expand all Loading... |
| 26 // into the file specified by the c'tor parameter |backing_file_path|. | 26 // into the file specified by the c'tor parameter |backing_file_path|. |
| 27 class UserPolicyCache : public CloudPolicyCacheBase { | 27 class UserPolicyCache : public CloudPolicyCacheBase { |
| 28 public: | 28 public: |
| 29 explicit UserPolicyCache(const FilePath& backing_file_path); | 29 explicit UserPolicyCache(const FilePath& backing_file_path); |
| 30 virtual ~UserPolicyCache(); | 30 virtual ~UserPolicyCache(); |
| 31 | 31 |
| 32 // CloudPolicyCacheBase implementation: | 32 // CloudPolicyCacheBase implementation: |
| 33 virtual void Load() OVERRIDE; | 33 virtual void Load() OVERRIDE; |
| 34 virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE; | 34 virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE; |
| 35 virtual void SetUnmanaged() OVERRIDE; | 35 virtual void SetUnmanaged() OVERRIDE; |
| 36 virtual bool IsReady() OVERRIDE; |
| 36 | 37 |
| 37 private: | 38 private: |
| 38 class DiskCache; | 39 class DiskCache; |
| 39 | 40 |
| 40 // Invoked by DiskCache after the file cache has been read successfully. | 41 // Invoked by DiskCache after the file cache has been read successfully. |
| 41 void OnDiskCacheLoaded(const em::CachedCloudPolicyResponse& cached_response); | 42 void OnDiskCacheLoaded(const em::CachedCloudPolicyResponse& cached_response); |
| 42 | 43 |
| 43 // CloudPolicyCacheBase implementation: | 44 // CloudPolicyCacheBase implementation: |
| 44 virtual bool DecodePolicyData(const em::PolicyData& policy_data, | 45 virtual bool DecodePolicyData(const em::PolicyData& policy_data, |
| 45 PolicyMap* mandatory, | 46 PolicyMap* mandatory, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 61 Value* DecodeValue(const em::GenericValue& value) const; | 62 Value* DecodeValue(const em::GenericValue& value) const; |
| 62 | 63 |
| 63 // </Old-style policy support> | 64 // </Old-style policy support> |
| 64 | 65 |
| 65 // Manages the cache file. | 66 // Manages the cache file. |
| 66 scoped_refptr<DiskCache> disk_cache_; | 67 scoped_refptr<DiskCache> disk_cache_; |
| 67 | 68 |
| 68 // Used for constructing the weak ptr passed to |disk_cache_|. | 69 // Used for constructing the weak ptr passed to |disk_cache_|. |
| 69 base::WeakPtrFactory<UserPolicyCache> weak_ptr_factory_; | 70 base::WeakPtrFactory<UserPolicyCache> weak_ptr_factory_; |
| 70 | 71 |
| 72 // Starts as false, set to true when the first request for policies from |
| 73 // disk is returned. |
| 74 bool first_load_complete_; |
| 75 |
| 71 DISALLOW_COPY_AND_ASSIGN(UserPolicyCache); | 76 DISALLOW_COPY_AND_ASSIGN(UserPolicyCache); |
| 72 }; | 77 }; |
| 73 | 78 |
| 74 } // namespace policy | 79 } // namespace policy |
| 75 | 80 |
| 76 #endif // CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ | 81 #endif // CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ |
| OLD | NEW |