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.
5 #ifndef COMPONENTS_BROWSING_DATA_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOVER_H_
6 #define COMPONENTS_BROWSING_DATA_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOVER_H_
8 #include "base/callback.h"
9 #include "base/sequenced_task_runner_helpers.h"
10 #include "base/time/time.h"
13 class StoragePartition
;
16 namespace disk_cache
{
21 class URLRequestContextGetter
;
24 namespace browsing_data
{
26 // Helper to remove http cache data from a StoragePartition.
27 class StoragePartitionHttpCacheDataRemover
{
29 static StoragePartitionHttpCacheDataRemover
* CreateForRange(
30 content::StoragePartition
* storage_partition
,
31 base::Time delete_begin
,
32 base::Time delete_end
);
34 // Calls |done_callback| upon completion and also destroys itself.
35 void Remove(const base::Closure
& done_callback
);
47 StoragePartitionHttpCacheDataRemover(
48 base::Time delete_begin
,
49 base::Time delete_end
,
50 net::URLRequestContextGetter
* main_context_getter
,
51 net::URLRequestContextGetter
* media_context_getter
);
53 // StoragePartitionHttpCacheDataRemover deletes itself (using DeleteHelper)
54 // and is not supposed to be deleted by other objects so make destructor
55 // private and DeleteHelper a friend.
56 friend class base::DeleteHelper
<StoragePartitionHttpCacheDataRemover
>;
58 ~StoragePartitionHttpCacheDataRemover();
60 void ClearHttpCacheOnIOThread();
61 void ClearedHttpCache();
62 // Performs the actual work to delete the cache.
63 void DoClearCache(int rv
);
65 const base::Time delete_begin_
;
66 const base::Time delete_end_
;
68 const scoped_refptr
<net::URLRequestContextGetter
> main_context_getter_
;
69 const scoped_refptr
<net::URLRequestContextGetter
> media_context_getter_
;
71 base::Closure done_callback_
;
74 int next_cache_state_
;
75 disk_cache::Backend
* cache_
;
77 DISALLOW_COPY_AND_ASSIGN(StoragePartitionHttpCacheDataRemover
);
80 } // namespace browsing_data
82 #endif // COMPONENTS_BROWSING_DATA_STORAGE_PARTITION_HTTP_CACHE_DATA_REMOVER_H_