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

Side by Side Diff: chrome/browser/chromeos/policy/user_policy_disk_cache.h

Issue 2681093005: Remove UserPolicyDiskCache; it is not used. (Closed)
Patch Set: Created 3 years, 10 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
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_CHROMEOS_POLICY_USER_POLICY_DISK_CACHE_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_POLICY_DISK_CACHE_H_
7
8 #include "base/files/file_path.h"
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12
13 namespace base {
14 class SequencedTaskRunner;
15 }
16
17 namespace enterprise_management {
18 class CachedCloudPolicyResponse;
19 }
20
21 namespace policy {
22
23 // Handles the on-disk cache file used by UserPolicyCache. This class handles
24 // the necessary thread switching and may outlive the associated UserPolicyCache
25 // instance.
26 class UserPolicyDiskCache
27 : public base::RefCountedThreadSafe<UserPolicyDiskCache> {
28 public:
29 // Indicates the status of a completed load operation.
30 enum LoadResult {
31 // Policy was loaded successfully.
32 LOAD_RESULT_SUCCESS,
33 // Cache file missing.
34 LOAD_RESULT_NOT_FOUND,
35 // Failed to read cache file.
36 LOAD_RESULT_READ_ERROR,
37 // Failed to parse cache file.
38 LOAD_RESULT_PARSE_ERROR,
39 };
40
41 // Delegate interface for observing loads operations.
42 class Delegate {
43 public:
44 virtual ~Delegate();
45 virtual void OnDiskCacheLoaded(
46 LoadResult result,
47 const enterprise_management::CachedCloudPolicyResponse& policy) = 0;
48 };
49
50 UserPolicyDiskCache(
51 const base::WeakPtr<Delegate>& delegate,
52 const base::FilePath& backing_file_path,
53 scoped_refptr<base::SequencedTaskRunner> background_task_runner);
54
55 // Starts reading the policy cache from disk. Passes the read policy
56 // information back to the hosting UserPolicyCache after a successful cache
57 // load through UserPolicyCache::OnDiskCacheLoaded().
58 void Load();
59
60 // Triggers a write operation to the disk cache on the FILE thread.
61 void Store(const enterprise_management::CachedCloudPolicyResponse& policy);
62
63 private:
64 friend class base::RefCountedThreadSafe<UserPolicyDiskCache>;
65 ~UserPolicyDiskCache();
66
67 // Tries to load the cache file on the FILE thread.
68 void LoadOnFileThread();
69
70 // Forwards the result to the UI thread.
71 void LoadDone(LoadResult result,
72 const enterprise_management::CachedCloudPolicyResponse& policy);
73
74 // Passes back the successfully read policy to the cache on the UI thread.
75 void ReportResultOnUIThread(
76 LoadResult result,
77 const enterprise_management::CachedCloudPolicyResponse& policy);
78
79 // Saves a policy blob on the FILE thread.
80 void StoreOnFileThread(
81 const enterprise_management::CachedCloudPolicyResponse& policy);
82
83 base::WeakPtr<Delegate> delegate_;
84 const base::FilePath backing_file_path_;
85 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_;
86 scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
87
88 DISALLOW_COPY_AND_ASSIGN(UserPolicyDiskCache);
89 };
90
91 } // namespace policy
92
93 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_POLICY_DISK_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698