OLD | NEW |
| (Empty) |
1 // Copyright 2015 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_BROWSING_DATA_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOVER_H
_ | |
6 #define CHROME_BROWSER_BROWSING_DATA_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOVER_H
_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/sequenced_task_runner_helpers.h" | |
10 #include "base/time/time.h" | |
11 | |
12 namespace content { | |
13 class StoragePartition; | |
14 } | |
15 | |
16 namespace disk_cache { | |
17 class Backend; | |
18 } | |
19 | |
20 namespace net { | |
21 class URLRequestContextGetter; | |
22 } | |
23 | |
24 // Helper to remove http cache data from a StoragePartition. | |
25 class StoragePartitionHttpCacheDataRemover { | |
26 public: | |
27 static StoragePartitionHttpCacheDataRemover* CreateForRange( | |
28 content::StoragePartition* storage_partition, | |
29 base::Time delete_begin, | |
30 base::Time delete_end); | |
31 | |
32 // Calls |done_callback| upon completion and also destroys itself. | |
33 void Remove(const base::Closure& done_callback); | |
34 | |
35 private: | |
36 enum CacheState { | |
37 STATE_NONE, | |
38 STATE_CREATE_MAIN, | |
39 STATE_CREATE_MEDIA, | |
40 STATE_DELETE_MAIN, | |
41 STATE_DELETE_MEDIA, | |
42 STATE_DONE | |
43 }; | |
44 | |
45 StoragePartitionHttpCacheDataRemover( | |
46 base::Time delete_begin, | |
47 base::Time delete_end, | |
48 net::URLRequestContextGetter* main_context_getter, | |
49 net::URLRequestContextGetter* media_context_getter); | |
50 | |
51 // StoragePartitionHttpCacheDataRemover deletes itself (using DeleteHelper) | |
52 // and is not supposed to be deleted by other objects so make destructor | |
53 // private and DeleteHelper a friend. | |
54 friend class base::DeleteHelper<StoragePartitionHttpCacheDataRemover>; | |
55 | |
56 ~StoragePartitionHttpCacheDataRemover(); | |
57 | |
58 void ClearHttpCacheOnIOThread(); | |
59 void ClearedHttpCache(); | |
60 // Performs the actual work to delete the cache. | |
61 void DoClearCache(int rv); | |
62 | |
63 const base::Time delete_begin_; | |
64 const base::Time delete_end_; | |
65 | |
66 const scoped_refptr<net::URLRequestContextGetter> main_context_getter_; | |
67 const scoped_refptr<net::URLRequestContextGetter> media_context_getter_; | |
68 | |
69 base::Closure done_callback_; | |
70 | |
71 // IO. | |
72 int next_cache_state_; | |
73 disk_cache::Backend* cache_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(StoragePartitionHttpCacheDataRemover); | |
76 }; | |
77 | |
78 #endif // CHROME_BROWSER_BROWSING_DATA_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOVE
R_H_ | |
OLD | NEW |