Chromium Code Reviews| Index: chrome/browser/policy/user_policy_cache.cc |
| diff --git a/chrome/browser/policy/user_policy_cache.cc b/chrome/browser/policy/user_policy_cache.cc |
| index 3cf8da57bd513dadeb544b791e82ab5f9ad30d0d..ed9ad27415bceee19196a15581b5258e70df1814 100644 |
| --- a/chrome/browser/policy/user_policy_cache.cc |
| +++ b/chrome/browser/policy/user_policy_cache.cc |
| @@ -28,8 +28,11 @@ namespace policy { |
| void DecodePolicy(const em::CloudPolicySettings& policy, |
| PolicyMap* mandatory, PolicyMap* recommended); |
| -UserPolicyCache::UserPolicyCache(const FilePath& backing_file_path) |
| - : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| +UserPolicyCache::UserPolicyCache(const FilePath& backing_file_path, |
| + bool wait_for_policy_fetch) |
| + : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), |
| + disk_cache_ready_(false), |
| + fetch_ready_(!wait_for_policy_fetch) { |
| disk_cache_ = new UserPolicyDiskCache(weak_ptr_factory_.GetWeakPtr(), |
| backing_file_path); |
| } |
| @@ -72,6 +75,13 @@ void UserPolicyCache::SetUnmanaged() { |
| disk_cache_->Store(cached_policy); |
| } |
| +void UserPolicyCache::SetFetchingDone() { |
| + if (!fetch_ready_) |
| + VLOG(1) << "SetFetchingDone, cache is now fetch_ready_"; |
|
Mattias Nissler (ping if slow)
2011/11/11 11:41:23
all VLOGs should probably be DVLOGs per that recen
Joao da Silva
2011/11/11 12:55:14
Done.
|
| + fetch_ready_ = true; |
| + CheckIfReady(); |
| +} |
| + |
| void UserPolicyCache::OnDiskCacheLoaded( |
| UserPolicyDiskCache::LoadResult result, |
| const em::CachedCloudPolicyResponse& cached_response) { |
| @@ -89,7 +99,8 @@ void UserPolicyCache::OnDiskCacheLoaded( |
| } |
| // Ready to feed policy up the chain! |
| - SetReady(); |
| + disk_cache_ready_ = true; |
| + CheckIfReady(); |
| } |
| bool UserPolicyCache::DecodePolicyData(const em::PolicyData& policy_data, |
| @@ -107,6 +118,11 @@ bool UserPolicyCache::DecodePolicyData(const em::PolicyData& policy_data, |
| return true; |
| } |
| +void UserPolicyCache::CheckIfReady() { |
| + if (!IsReady() && disk_cache_ready_ && fetch_ready_) |
| + SetReady(); |
| +} |
| + |
| // Everything below is only needed for supporting old-style GenericNamedValue |
| // based policy data and can be removed once this support is no longer needed. |