Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1707)

Unified Diff: chrome/browser/policy/user_policy_cache.h

Issue 8499021: UserPolicyCache only becomes ready after policy has been fetched. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/user_policy_cache.h
diff --git a/chrome/browser/policy/user_policy_cache.h b/chrome/browser/policy/user_policy_cache.h
index a065e193a5a4b8d710f636f0f249b1998e4db503..a32a36a5da7c4e1e4baed2fb5e31ced53191a9f2 100644
--- a/chrome/browser/policy/user_policy_cache.h
+++ b/chrome/browser/policy/user_policy_cache.h
@@ -36,13 +36,18 @@ class PolicyMap;
class UserPolicyCache : public CloudPolicyCacheBase,
public UserPolicyDiskCache::Delegate {
public:
- explicit UserPolicyCache(const FilePath& backing_file_path);
+ // |backing_file_path| is the path to the cache file.
+ // |wait_for_policy_fetch| is true if the cache should be ready only after
+ // an attempt was made to fetch user policy.
+ UserPolicyCache(const FilePath& backing_file_path,
+ bool wait_for_policy_fetch);
virtual ~UserPolicyCache();
// CloudPolicyCacheBase implementation:
virtual void Load() OVERRIDE;
virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE;
virtual void SetUnmanaged() OVERRIDE;
+ virtual void SetFetchingDone() OVERRIDE;
private:
class DiskCache;
@@ -57,6 +62,9 @@ class UserPolicyCache : public CloudPolicyCacheBase,
PolicyMap* mandatory,
PolicyMap* recommended) OVERRIDE;
+ // Checks if this cache is ready, and invokes SetReady() if so.
+ void CheckIfReady();
+
// <Old-style policy support>
// The following member functions are needed to support old-style policy and
// can be removed once all server-side components (CPanel, D3) have been
@@ -80,6 +88,13 @@ class UserPolicyCache : public CloudPolicyCacheBase,
// Used for constructing the weak ptr passed to |disk_cache_|.
base::WeakPtrFactory<UserPolicyDiskCache::Delegate> weak_ptr_factory_;
+ // True if the disk cache has been loaded.
+ bool disk_cache_ready_;
+
+ // True if at least one attempt was made to refresh the cache with a freshly
+ // fetched policy, or if there is no need to wait for that.
+ bool fetch_ready_;
+
DISALLOW_COPY_AND_ASSIGN(UserPolicyCache);
};

Powered by Google App Engine
This is Rietveld 408576698