OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_BROWSING_DATA_CONTENT_CONDITIONAL_CACHE_COUNTING_HELPER_H_ | 5 #ifndef COMPONENTS_BROWSING_DATA_CONTENT_CONDITIONAL_CACHE_COUNTING_HELPER_H_ |
6 #define COMPONENTS_BROWSING_DATA_CONTENT_CONDITIONAL_CACHE_COUNTING_HELPER_H_ | 6 #define COMPONENTS_BROWSING_DATA_CONTENT_CONDITIONAL_CACHE_COUNTING_HELPER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/sequenced_task_runner_helpers.h" | 11 #include "base/sequenced_task_runner_helpers.h" |
12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
13 #include "net/disk_cache/disk_cache.h" | 13 #include "net/disk_cache/disk_cache.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 class StoragePartition; | 16 class StoragePartition; |
17 } | 17 } |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 class URLRequestContextGetter; | 20 class URLRequestContextGetter; |
21 } | 21 } |
22 | 22 |
23 namespace browsing_data { | 23 namespace browsing_data { |
24 | 24 |
25 // Helper to count the size of the http cache data from a StoragePartition. | 25 // Helper to count the size of the http cache data from a StoragePartition. |
26 class ConditionalCacheCountingHelper { | 26 class ConditionalCacheCountingHelper { |
27 public: | 27 public: |
28 // Returns the number bytes in the selected range and if this value is an | 28 // Returns if this value is an upper estimate and the number bytes in the |
29 // upper estimate. | 29 // selected range. |
30 typedef base::Callback<void(int64_t, bool)> CacheCountCallback; | 30 typedef base::Callback<void(bool, int64_t)> CacheCountCallback; |
31 | 31 |
32 static ConditionalCacheCountingHelper* CreateForRange( | 32 static ConditionalCacheCountingHelper* CreateForRange( |
33 content::StoragePartition* storage_partition, | 33 content::StoragePartition* storage_partition, |
34 base::Time begin_time, | 34 base::Time begin_time, |
35 base::Time end_time); | 35 base::Time end_time); |
36 | 36 |
37 // Count the cache entries according to the specified time range. Destroys | 37 // Count the cache entries according to the specified time range. Destroys |
38 // this instance of ConditionalCacheCountingHelper when finished. | 38 // this instance of ConditionalCacheCountingHelper when finished. |
39 // Must be called on the UI thread! | 39 // Must be called on the UI thread! |
40 // | 40 // |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 std::unique_ptr<disk_cache::Backend::Iterator> iterator_; | 89 std::unique_ptr<disk_cache::Backend::Iterator> iterator_; |
90 | 90 |
91 base::WeakPtrFactory<ConditionalCacheCountingHelper> weak_ptr_factory_; | 91 base::WeakPtrFactory<ConditionalCacheCountingHelper> weak_ptr_factory_; |
92 | 92 |
93 DISALLOW_COPY_AND_ASSIGN(ConditionalCacheCountingHelper); | 93 DISALLOW_COPY_AND_ASSIGN(ConditionalCacheCountingHelper); |
94 }; | 94 }; |
95 | 95 |
96 } // namespace browsing_data | 96 } // namespace browsing_data |
97 | 97 |
98 #endif // COMPONENTS_BROWSING_DATA_CONTENT_CONDITIONAL_CACHE_COUNTING_HELPER_H_ | 98 #endif // COMPONENTS_BROWSING_DATA_CONTENT_CONDITIONAL_CACHE_COUNTING_HELPER_H_ |
OLD | NEW |