Chromium Code Reviews| Index: chrome/browser/policy/cros_user_policy_cache.h |
| diff --git a/chrome/browser/policy/cros_user_policy_cache.h b/chrome/browser/policy/cros_user_policy_cache.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5c87a83eef418a8e6a41713fcd1d9fbba21c3437 |
| --- /dev/null |
| +++ b/chrome/browser/policy/cros_user_policy_cache.h |
| @@ -0,0 +1,114 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_POLICY_CROS_USER_POLICY_CACHE_H_ |
| +#define CHROME_BROWSER_POLICY_CROS_USER_POLICY_CACHE_H_ |
| +#pragma once |
| + |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/compiler_specific.h" |
| +#include "base/file_path.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "chrome/browser/policy/cloud_policy_cache_base.h" |
| +#include "chrome/browser/policy/user_policy_disk_cache.h" |
| +#include "chrome/browser/policy/user_policy_token_cache.h" |
| + |
| +namespace chromeos { |
| +class LoginLibrary; |
| +} |
| + |
| +namespace policy { |
| + |
| +class CloudPolicyDataStore; |
| +class CrosUserPolicyIdentityStrategy; |
|
gfeher
2011/07/21 23:37:15
Obsolete, please remove.
Mattias Nissler (ping if slow)
2011/07/22 11:29:48
Done.
|
| + |
| +// User policy cache that talks to the ChromeOS login library in order to store |
| +// and fetch policy data. |
| +class CrosUserPolicyCache : public CloudPolicyCacheBase, |
| + public UserPolicyTokenCache::Delegate, |
| + public UserPolicyDiskCache::Delegate { |
| + public: |
| + CrosUserPolicyCache(chromeos::LoginLibrary* login_library, |
| + CloudPolicyDataStore* data_store, |
| + const FilePath& legacy_token_cache_file, |
| + const FilePath& legacy_policy_cache_file); |
| + virtual ~CrosUserPolicyCache(); |
| + |
| + // CloudPolicyCacheBase implementation. |
| + virtual void Load() OVERRIDE; |
| + virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE; |
| + virtual void SetUnmanaged() OVERRIDE; |
| + virtual bool IsReady() OVERRIDE; |
| + |
| + protected: |
| + virtual bool DecodePolicyData(const em::PolicyData& policy_data, |
| + PolicyMap* mandatory, |
| + PolicyMap* recommended) OVERRIDE; |
| + |
| + private: |
| + class PolicyKey; |
| + class StorePolicyOperation; |
| + class RetrievePolicyOperation; |
| + |
| + // UserPolicyTokenLoader::Delegate: |
| + virtual void OnTokenLoaded(const std::string& token, |
| + const std::string& device_id) OVERRIDE; |
| + |
| + // UserPolicyDiskCache::Delegate: |
| + virtual void OnDiskCacheLoaded( |
| + const em::CachedCloudPolicyResponse& policy) OVERRIDE; |
| + |
| + // Used as a callback for the policy store operation. |
| + void OnPolicyStored(bool result); |
| + |
| + // Callback for the initial policy load. Installs the policy and passes the |
| + // loaded token and device ID to the identity strategy. |
|
gfeher
2011/07/21 23:37:15
Nit: identity strategy -> data store
Mattias Nissler (ping if slow)
2011/07/22 11:29:48
Done.
|
| + void OnPolicyLoadDone(bool result, const em::PolicyFetchResponse& policy); |
| + |
| + // Callback for the policy retrieval operation run to reload the policy after |
| + // new policy has been successfully stored. Installs the new policy in the |
| + // cache and publishes it if successful. |
| + void OnPolicyReloadDone(bool result, const em::PolicyFetchResponse& policy); |
| + |
| + // Starts a new retrieval operation. |
| + void StartRetrieve(bool reload_key); |
| + |
| + void CancelStore(); |
| + void CancelRetrieve(); |
| + |
| + // Removes the legacy cache dir. |
| + static void RemoveLegacyCacheDir(const FilePath& dir); |
| + |
| + scoped_refptr<PolicyKey> key_; |
| + chromeos::LoginLibrary* login_library_; |
| + CloudPolicyDataStore* data_store_; |
| + |
| + // Whether we have loaded the policy cache. |
| + bool policy_cache_loaded_; |
| + |
| + // Storage and retrieval operations that are currently in flight. |
| + StorePolicyOperation* store_operation_; |
| + RetrievePolicyOperation* retrieve_operation_; |
| + |
| + // TODO(mnissler): Remove all the legacy policy support members below after |
| + // the number of M14 clients drops back to zero. |
| + FilePath legacy_cache_dir_; |
| + |
| + base::WeakPtrFactory<UserPolicyTokenCache::Delegate> |
| + legacy_token_cache_delegate_factory_; |
| + scoped_refptr<UserPolicyTokenLoader> legacy_token_loader_; |
| + |
| + base::WeakPtrFactory<UserPolicyDiskCache::Delegate> |
| + legacy_policy_cache_delegate_factory_; |
| + scoped_refptr<UserPolicyDiskCache> legacy_policy_cache_; |
| + |
|
gfeher
2011/07/21 23:37:15
Nit: extra newline.
Mattias Nissler (ping if slow)
2011/07/22 11:29:48
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(CrosUserPolicyCache); |
| +}; |
| + |
| +} // namespace policy |
| + |
| +#endif // CHROME_BROWSER_POLICY_CROS_USER_POLICY_CACHE_H_ |