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

Side by Side Diff: chrome/browser/policy/cloud_policy_cache_base.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_CLOUD_POLICY_CACHE_BASE_H_ 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_BASE_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_BASE_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_BASE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/observer_list.h" 9 #include "base/observer_list.h"
10 #include "base/threading/non_thread_safe.h" 10 #include "base/threading/non_thread_safe.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 notifier_ = notifier; 46 notifier_ = notifier;
47 } 47 }
48 48
49 // Loads persisted policy information. 49 // Loads persisted policy information.
50 virtual void Load() = 0; 50 virtual void Load() = 0;
51 51
52 // Resets the policy information. 52 // Resets the policy information.
53 virtual void SetPolicy(const em::PolicyFetchResponse& policy) = 0; 53 virtual void SetPolicy(const em::PolicyFetchResponse& policy) = 0;
54 54
55 virtual void SetUnmanaged() = 0; 55 virtual void SetUnmanaged() = 0;
56
57 // Invoked whenever an attempt to fetch policy has been completed. The fetch
58 // may or may not have suceeded. This can be triggered by failed attempts to
59 // fetch oauth tokens, register with dmserver or fetch policy.
60 virtual void SetFetchingDone() = 0;
61
56 bool is_unmanaged() const { 62 bool is_unmanaged() const {
57 return is_unmanaged_; 63 return is_unmanaged_;
58 } 64 }
59 65
60 // Returns the time at which the policy was last fetched. 66 // Returns the time at which the policy was last fetched.
61 base::Time last_policy_refresh_time() const { 67 base::Time last_policy_refresh_time() const {
62 return last_policy_refresh_time_; 68 return last_policy_refresh_time_;
63 } 69 }
64 70
65 // Get the version of the encryption key currently used for decoding policy. 71 // Get the version of the encryption key currently used for decoding policy.
66 // Returns true if the version is available, in which case |version| is filled 72 // Returns true if the version is available, in which case |version| is filled
67 // in. 73 // in.
68 bool GetPublicKeyVersion(int* version); 74 bool GetPublicKeyVersion(int* version);
69 75
70 void AddObserver(Observer* observer); 76 void AddObserver(Observer* observer);
71 void RemoveObserver(Observer* observer); 77 void RemoveObserver(Observer* observer);
72 78
73 // Accessor for the underlying PolicyMaps. 79 // Accessor for the underlying PolicyMaps.
74 const PolicyMap* policy(PolicyLevel level); 80 const PolicyMap* policy(PolicyLevel level);
75 81
76 // Resets the cache, clearing the policy currently stored in memory and the 82 // Resets the cache, clearing the policy currently stored in memory and the
77 // last refresh time. 83 // last refresh time.
78 void Reset(); 84 void Reset();
79 85
80 // true if the cache contains data that is ready to be served as policies. 86 // true if the cache contains data that is ready to be served as policies.
81 // This should mean that this method turns true as soon as a round-trip to 87 // This usually means that the local policy storage has been loaded.
82 // the local policy storage is complete. The creation of the Profile is 88 // Note that Profile creation will block until the cache is ready.
83 // blocked on this method, so we shouldn't wait for successful network 89 // On enrolled devices and for users of the enrolled domain, the cache only
84 // round trips. 90 // becomes ready after a user policy fetch is completed.
85 bool IsReady(); 91 bool IsReady();
86 92
87 protected: 93 protected:
88 // Wraps public key version and validity. 94 // Wraps public key version and validity.
89 struct PublicKeyVersion { 95 struct PublicKeyVersion {
90 int version; 96 int version;
91 bool valid; 97 bool valid;
92 }; 98 };
93 99
94 // Decodes the given |policy| using |DecodePolicyResponse()|, applies the 100 // Decodes the given |policy| using |DecodePolicyResponse()|, applies the
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 164
159 // Cache observers that are registered with this cache. 165 // Cache observers that are registered with this cache.
160 ObserverList<Observer, true> observer_list_; 166 ObserverList<Observer, true> observer_list_;
161 167
162 DISALLOW_COPY_AND_ASSIGN(CloudPolicyCacheBase); 168 DISALLOW_COPY_AND_ASSIGN(CloudPolicyCacheBase);
163 }; 169 };
164 170
165 } // namespace policy 171 } // namespace policy
166 172
167 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_BASE_H_ 173 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698