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

Side by Side Diff: chrome/browser/policy/user_policy_cache.h

Issue 11946017: Remove old cloud policy code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits. Created 7 years, 11 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_
6 #define CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_
7
8 #include <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/values.h"
13 #include "chrome/browser/policy/cloud_policy_cache_base.h"
14 #include "chrome/browser/policy/user_policy_disk_cache.h"
15
16 class FilePath;
17
18 namespace enterprise_management {
19
20 class CachedCloudPolicyResponse;
21 // <Old-style policy support> (see comment below)
22 class GenericValue;
23 // </Old-style policy support>
24
25 } // namespace enterprise_management
26
27 namespace policy {
28
29 class PolicyMap;
30
31 // CloudPolicyCacheBase implementation that persists policy information
32 // into the file specified by the c'tor parameter |backing_file_path|.
33 class UserPolicyCache : public CloudPolicyCacheBase,
34 public UserPolicyDiskCache::Delegate {
35 public:
36 // |backing_file_path| is the path to the cache file.
37 // |wait_for_policy_fetch| is true if the cache should be ready only after
38 // an attempt was made to fetch user policy.
39 UserPolicyCache(const FilePath& backing_file_path,
40 bool wait_for_policy_fetch);
41 virtual ~UserPolicyCache();
42
43 // CloudPolicyCacheBase implementation:
44 virtual void Load() OVERRIDE;
45 virtual bool SetPolicy(
46 const enterprise_management::PolicyFetchResponse& policy) OVERRIDE;
47 virtual void SetUnmanaged() OVERRIDE;
48 virtual void SetFetchingDone() OVERRIDE;
49
50 private:
51 class DiskCache;
52
53 // UserPolicyDiskCache::Delegate implementation:
54 virtual void OnDiskCacheLoaded(
55 UserPolicyDiskCache::LoadResult result,
56 const enterprise_management::CachedCloudPolicyResponse&
57 cached_response) OVERRIDE;
58
59 // CloudPolicyCacheBase implementation:
60 virtual bool DecodePolicyData(
61 const enterprise_management::PolicyData& policy_data,
62 PolicyMap* policies) OVERRIDE;
63
64 // Checks if this cache is ready, and invokes SetReady() if so.
65 void CheckIfReady();
66
67 // <Old-style policy support>
68 // The following member functions are needed to support old-style policy and
69 // can be removed once all server-side components (CPanel, D3) have been
70 // migrated to providing the new policy format.
71 //
72 // If |policies| is empty and |policy_data| contains a field named
73 // "repeated GenericNamedValue named_value = 2;", the policies in that field
74 // are added to |policies| as LEVEL_MANDATORY, SCOPE_USER policies.
75 void MaybeDecodeOldstylePolicy(const std::string& policy_data,
76 PolicyMap* policies);
77
78 Value* DecodeIntegerValue(google::protobuf::int64 value) const;
79 Value* DecodeValue(const enterprise_management::GenericValue& value) const;
80
81 // </Old-style policy support>
82
83 // Manages the cache file.
84 scoped_refptr<UserPolicyDiskCache> disk_cache_;
85
86 // Used for constructing the weak ptr passed to |disk_cache_|.
87 base::WeakPtrFactory<UserPolicyDiskCache::Delegate> weak_ptr_factory_;
88
89 // True if the disk cache has been loaded.
90 bool disk_cache_ready_;
91
92 // True if at least one attempt was made to refresh the cache with a freshly
93 // fetched policy, or if there is no need to wait for that.
94 bool fetch_ready_;
95
96 DISALLOW_COPY_AND_ASSIGN(UserPolicyCache);
97 };
98
99 } // namespace policy
100
101 #endif // CHROME_BROWSER_POLICY_USER_POLICY_CACHE_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/user_cloud_policy_store_chromeos.cc ('k') | chrome/browser/policy/user_policy_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698