| Index: content/browser/browsing_data/storage_partition_http_cache_data_remover_impl.cc
|
| diff --git a/components/browsing_data/content/storage_partition_http_cache_data_remover.cc b/content/browser/browsing_data/storage_partition_http_cache_data_remover_impl.cc
|
| similarity index 72%
|
| rename from components/browsing_data/content/storage_partition_http_cache_data_remover.cc
|
| rename to content/browser/browsing_data/storage_partition_http_cache_data_remover_impl.cc
|
| index 5eeff79f1ecb2ceb9dbaae2872f6d8fde8efa9e9..456e91b4a30cd6fac41e6dc71f294f3daf3f571b 100644
|
| --- a/components/browsing_data/content/storage_partition_http_cache_data_remover.cc
|
| +++ b/content/browser/browsing_data/storage_partition_http_cache_data_remover_impl.cc
|
| @@ -2,12 +2,13 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "components/browsing_data/content/storage_partition_http_cache_data_remover.h"
|
| +#include "content/browser/browsing_data/storage_partition_http_cache_data_remover_impl.h"
|
|
|
| #include "base/location.h"
|
| +#include "base/sequenced_task_runner_helpers.h"
|
| #include "base/single_thread_task_runner.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| -#include "components/browsing_data/content/conditional_cache_deletion_helper.h"
|
| +#include "content/browser/browsing_data/conditional_cache_deletion_helper.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "content/public/browser/storage_partition.h"
|
| #include "net/base/sdch_manager.h"
|
| @@ -18,27 +19,9 @@
|
| #include "net/http/http_cache.h"
|
| #include "net/url_request/url_request_context.h"
|
| #include "net/url_request/url_request_context_getter.h"
|
| +#include "url/gurl.h"
|
|
|
| -using content::BrowserThread;
|
| -
|
| -namespace browsing_data {
|
| -
|
| -StoragePartitionHttpCacheDataRemover::StoragePartitionHttpCacheDataRemover(
|
| - base::Callback<bool(const GURL&)> url_predicate,
|
| - base::Time delete_begin,
|
| - base::Time delete_end,
|
| - net::URLRequestContextGetter* main_context_getter,
|
| - net::URLRequestContextGetter* media_context_getter)
|
| - : url_predicate_(url_predicate),
|
| - delete_begin_(delete_begin),
|
| - delete_end_(delete_end),
|
| - main_context_getter_(main_context_getter),
|
| - media_context_getter_(media_context_getter),
|
| - next_cache_state_(CacheState::NONE),
|
| - cache_(nullptr) {}
|
| -
|
| -StoragePartitionHttpCacheDataRemover::~StoragePartitionHttpCacheDataRemover() {
|
| -}
|
| +namespace content {
|
|
|
| // static.
|
| StoragePartitionHttpCacheDataRemover*
|
| @@ -46,10 +29,9 @@ StoragePartitionHttpCacheDataRemover::CreateForRange(
|
| content::StoragePartition* storage_partition,
|
| base::Time delete_begin,
|
| base::Time delete_end) {
|
| - return new StoragePartitionHttpCacheDataRemover(
|
| + return new StoragePartitionHttpCacheDataRemoverImpl(
|
| base::Callback<bool(const GURL&)>(), // Null callback.
|
| - delete_begin, delete_end,
|
| - storage_partition->GetURLRequestContext(),
|
| + delete_begin, delete_end, storage_partition->GetURLRequestContext(),
|
| storage_partition->GetMediaURLRequestContext());
|
| }
|
|
|
| @@ -60,13 +42,31 @@ StoragePartitionHttpCacheDataRemover::CreateForURLsAndRange(
|
| const base::Callback<bool(const GURL&)>& url_predicate,
|
| base::Time delete_begin,
|
| base::Time delete_end) {
|
| - return new StoragePartitionHttpCacheDataRemover(
|
| + return new StoragePartitionHttpCacheDataRemoverImpl(
|
| url_predicate, delete_begin, delete_end,
|
| storage_partition->GetURLRequestContext(),
|
| storage_partition->GetMediaURLRequestContext());
|
| }
|
|
|
| -void StoragePartitionHttpCacheDataRemover::Remove(
|
| +StoragePartitionHttpCacheDataRemoverImpl::
|
| + StoragePartitionHttpCacheDataRemoverImpl(
|
| + base::Callback<bool(const GURL&)> url_predicate,
|
| + base::Time delete_begin,
|
| + base::Time delete_end,
|
| + net::URLRequestContextGetter* main_context_getter,
|
| + net::URLRequestContextGetter* media_context_getter)
|
| + : url_predicate_(url_predicate),
|
| + delete_begin_(delete_begin),
|
| + delete_end_(delete_end),
|
| + main_context_getter_(main_context_getter),
|
| + media_context_getter_(media_context_getter),
|
| + next_cache_state_(CacheState::NONE),
|
| + cache_(nullptr) {}
|
| +
|
| +StoragePartitionHttpCacheDataRemoverImpl::
|
| + ~StoragePartitionHttpCacheDataRemoverImpl() {}
|
| +
|
| +void StoragePartitionHttpCacheDataRemoverImpl::Remove(
|
| const base::Closure& done_callback) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| DCHECK(!done_callback.is_null());
|
| @@ -75,11 +75,11 @@ void StoragePartitionHttpCacheDataRemover::Remove(
|
| BrowserThread::PostTask(
|
| BrowserThread::IO, FROM_HERE,
|
| base::Bind(
|
| - &StoragePartitionHttpCacheDataRemover::ClearHttpCacheOnIOThread,
|
| + &StoragePartitionHttpCacheDataRemoverImpl::ClearHttpCacheOnIOThread,
|
| base::Unretained(this)));
|
| }
|
|
|
| -void StoragePartitionHttpCacheDataRemover::ClearHttpCacheOnIOThread() {
|
| +void StoragePartitionHttpCacheDataRemoverImpl::ClearHttpCacheOnIOThread() {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| next_cache_state_ = CacheState::NONE;
|
| DCHECK_EQ(CacheState::NONE, next_cache_state_);
|
| @@ -90,7 +90,7 @@ void StoragePartitionHttpCacheDataRemover::ClearHttpCacheOnIOThread() {
|
| DoClearCache(net::OK);
|
| }
|
|
|
| -void StoragePartitionHttpCacheDataRemover::ClearedHttpCache() {
|
| +void StoragePartitionHttpCacheDataRemoverImpl::ClearedHttpCache() {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| done_callback_.Run();
|
| base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
|
| @@ -99,7 +99,7 @@ void StoragePartitionHttpCacheDataRemover::ClearedHttpCache() {
|
| // The expected state sequence is CacheState::NONE --> CacheState::CREATE_MAIN
|
| // --> CacheState::PROCESS_MAIN --> CacheState::CREATE_MEDIA -->
|
| // CacheState::PROCESS_MEDIA --> CacheState::DONE, and any errors are ignored.
|
| -void StoragePartitionHttpCacheDataRemover::DoClearCache(int rv) {
|
| +void StoragePartitionHttpCacheDataRemoverImpl::DoClearCache(int rv) {
|
| DCHECK_NE(CacheState::NONE, next_cache_state_);
|
|
|
| while (rv != net::ERR_IO_PENDING && next_cache_state_ != CacheState::NONE) {
|
| @@ -135,7 +135,7 @@ void StoragePartitionHttpCacheDataRemover::DoClearCache(int rv) {
|
|
|
| rv = http_cache->GetBackend(
|
| &cache_,
|
| - base::Bind(&StoragePartitionHttpCacheDataRemover::DoClearCache,
|
| + base::Bind(&StoragePartitionHttpCacheDataRemoverImpl::DoClearCache,
|
| base::Unretained(this)));
|
| break;
|
| }
|
| @@ -148,24 +148,23 @@ void StoragePartitionHttpCacheDataRemover::DoClearCache(int rv) {
|
| // |cache_| can be null if it cannot be initialized.
|
| if (cache_) {
|
| if (!url_predicate_.is_null()) {
|
| - rv = (new ConditionalCacheDeletionHelper(
|
| - cache_,
|
| - ConditionalCacheDeletionHelper::CreateURLAndTimeCondition(
|
| - url_predicate_,
|
| - delete_begin_,
|
| - delete_end_)))->DeleteAndDestroySelfWhenFinished(
|
| - base::Bind(
|
| - &StoragePartitionHttpCacheDataRemover::DoClearCache,
|
| - base::Unretained(this)));
|
| + rv =
|
| + (new ConditionalCacheDeletionHelper(
|
| + cache_,
|
| + ConditionalCacheDeletionHelper::CreateURLAndTimeCondition(
|
| + url_predicate_, delete_begin_, delete_end_)))
|
| + ->DeleteAndDestroySelfWhenFinished(base::Bind(
|
| + &StoragePartitionHttpCacheDataRemoverImpl::DoClearCache,
|
| + base::Unretained(this)));
|
| } else if (delete_begin_.is_null() && delete_end_.is_max()) {
|
| rv = cache_->DoomAllEntries(base::Bind(
|
| - &StoragePartitionHttpCacheDataRemover::DoClearCache,
|
| + &StoragePartitionHttpCacheDataRemoverImpl::DoClearCache,
|
| base::Unretained(this)));
|
| } else {
|
| rv = cache_->DoomEntriesBetween(
|
| delete_begin_, delete_end_,
|
| base::Bind(
|
| - &StoragePartitionHttpCacheDataRemover::DoClearCache,
|
| + &StoragePartitionHttpCacheDataRemoverImpl::DoClearCache,
|
| base::Unretained(this)));
|
| }
|
| cache_ = NULL;
|
| @@ -179,8 +178,9 @@ void StoragePartitionHttpCacheDataRemover::DoClearCache(int rv) {
|
| // Notify the UI thread that we are done.
|
| BrowserThread::PostTask(
|
| BrowserThread::UI, FROM_HERE,
|
| - base::Bind(&StoragePartitionHttpCacheDataRemover::ClearedHttpCache,
|
| - base::Unretained(this)));
|
| + base::Bind(
|
| + &StoragePartitionHttpCacheDataRemoverImpl::ClearedHttpCache,
|
| + base::Unretained(this)));
|
| return;
|
| }
|
| case CacheState::NONE: {
|
| @@ -191,4 +191,4 @@ void StoragePartitionHttpCacheDataRemover::DoClearCache(int rv) {
|
| }
|
| }
|
|
|
| -} // namespace browsing_data
|
| +} // namespace content
|
|
|