| 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 |
| 11 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 #include "chrome/browser/policy/cloud_policy_cache_base.h" | 15 #include "chrome/browser/policy/cloud_policy_cache_base.h" |
| 15 #include "chrome/browser/policy/user_policy_disk_cache.h" | 16 #include "chrome/browser/policy/user_policy_disk_cache.h" |
| 16 | 17 |
| 17 class FilePath; | 18 class FilePath; |
| 18 | 19 |
| 19 namespace enterprise_management { | 20 namespace enterprise_management { |
| 20 | 21 |
| 21 class CachedCloudPolicyResponse; | 22 class CachedCloudPolicyResponse; |
| 22 // <Old-style policy support> (see comment below) | 23 // <Old-style policy support> (see comment below) |
| 23 class GenericValue; | 24 class GenericValue; |
| 24 // </Old-style policy support> | 25 // </Old-style policy support> |
| 25 | 26 |
| 26 } // namespace enterprise_management | 27 } // namespace enterprise_management |
| 27 | 28 |
| 28 namespace policy { | 29 namespace policy { |
| 29 | 30 |
| 30 class PolicyMap; | 31 class PolicyMap; |
| 31 | 32 |
| 32 // CloudPolicyCacheBase implementation that persists policy information | 33 // CloudPolicyCacheBase implementation that persists policy information |
| 33 // into the file specified by the c'tor parameter |backing_file_path|. | 34 // into the file specified by the c'tor parameter |backing_file_path|. |
| 34 class UserPolicyCache : public CloudPolicyCacheBase, | 35 class UserPolicyCache : public CloudPolicyCacheBase, |
| 35 public UserPolicyDiskCache::Delegate { | 36 public UserPolicyDiskCache::Delegate { |
| 36 public: | 37 public: |
| 37 // |backing_file_path| is the path to the cache file. | 38 // |backing_file_path| is the path to the cache file. |
| 38 // |wait_for_policy_fetch| is true if the cache should be ready only after | 39 // |wait_for_policy_fetch| is true if the cache should be ready only after |
| 39 // an attempt was made to fetch user policy. | 40 // an attempt was made to fetch user policy. |
| 41 // If |callback| is not null, it will be invoked once the cache is ready. |
| 40 UserPolicyCache(const FilePath& backing_file_path, | 42 UserPolicyCache(const FilePath& backing_file_path, |
| 41 bool wait_for_policy_fetch); | 43 bool wait_for_policy_fetch, |
| 44 const base::Closure& callback); |
| 42 virtual ~UserPolicyCache(); | 45 virtual ~UserPolicyCache(); |
| 43 | 46 |
| 44 // CloudPolicyCacheBase implementation: | 47 // CloudPolicyCacheBase implementation: |
| 45 virtual void Load() OVERRIDE; | 48 virtual void Load() OVERRIDE; |
| 46 virtual void SetPolicy( | 49 virtual void SetPolicy( |
| 47 const enterprise_management::PolicyFetchResponse& policy) OVERRIDE; | 50 const enterprise_management::PolicyFetchResponse& policy) OVERRIDE; |
| 48 virtual void SetUnmanaged() OVERRIDE; | 51 virtual void SetUnmanaged() OVERRIDE; |
| 49 virtual void SetFetchingDone() OVERRIDE; | 52 virtual void SetFetchingDone() OVERRIDE; |
| 50 | 53 |
| 51 private: | 54 private: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // Used for constructing the weak ptr passed to |disk_cache_|. | 90 // Used for constructing the weak ptr passed to |disk_cache_|. |
| 88 base::WeakPtrFactory<UserPolicyDiskCache::Delegate> weak_ptr_factory_; | 91 base::WeakPtrFactory<UserPolicyDiskCache::Delegate> weak_ptr_factory_; |
| 89 | 92 |
| 90 // True if the disk cache has been loaded. | 93 // True if the disk cache has been loaded. |
| 91 bool disk_cache_ready_; | 94 bool disk_cache_ready_; |
| 92 | 95 |
| 93 // True if at least one attempt was made to refresh the cache with a freshly | 96 // True if at least one attempt was made to refresh the cache with a freshly |
| 94 // fetched policy, or if there is no need to wait for that. | 97 // fetched policy, or if there is no need to wait for that. |
| 95 bool fetch_ready_; | 98 bool fetch_ready_; |
| 96 | 99 |
| 100 // Callback to invoke when the cache becomes ready. |
| 101 base::Closure ready_callback_; |
| 102 |
| 97 DISALLOW_COPY_AND_ASSIGN(UserPolicyCache); | 103 DISALLOW_COPY_AND_ASSIGN(UserPolicyCache); |
| 98 }; | 104 }; |
| 99 | 105 |
| 100 } // namespace policy | 106 } // namespace policy |
| 101 | 107 |
| 102 #endif // CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ | 108 #endif // CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_ |
| OLD | NEW |