| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #include "content/browser/cache_storage/cache_storage_context_impl.h" | 5 #include "content/browser/cache_storage/cache_storage_context_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
| 10 #include "content/browser/cache_storage/cache_storage_manager.h" | 10 #include "content/browser/cache_storage/cache_storage_manager.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 net::URLRequestContextGetter* request_context_getter, | 74 net::URLRequestContextGetter* request_context_getter, |
| 75 ChromeBlobStorageContext* blob_storage_context) { | 75 ChromeBlobStorageContext* blob_storage_context) { |
| 76 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 76 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 77 | 77 |
| 78 if (cache_manager_ && request_context_getter && blob_storage_context) { | 78 if (cache_manager_ && request_context_getter && blob_storage_context) { |
| 79 cache_manager_->SetBlobParametersForCache( | 79 cache_manager_->SetBlobParametersForCache( |
| 80 request_context_getter, blob_storage_context->context()->AsWeakPtr()); | 80 request_context_getter, blob_storage_context->context()->AsWeakPtr()); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 void CacheStorageContextImpl::GetAllOriginsInfo( |
| 85 const CacheStorageContext::GetUsageInfoCallback& callback) { |
| 86 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 87 |
| 88 if (!cache_manager_) { |
| 89 BrowserThread::PostTask( |
| 90 BrowserThread::IO, FROM_HERE, |
| 91 base::Bind(callback, std::vector<CacheStorageUsageInfo>())); |
| 92 return; |
| 93 } |
| 94 |
| 95 cache_manager_->GetAllOriginsUsage(callback); |
| 96 } |
| 97 |
| 98 void CacheStorageContextImpl::DeleteForOrigin(const GURL& origin) { |
| 99 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 100 if (cache_manager_) |
| 101 cache_manager_->DeleteOriginData(origin); |
| 102 } |
| 103 |
| 84 void CacheStorageContextImpl::CreateCacheStorageManager( | 104 void CacheStorageContextImpl::CreateCacheStorageManager( |
| 85 const base::FilePath& user_data_directory, | 105 const base::FilePath& user_data_directory, |
| 86 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, | 106 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, |
| 87 storage::QuotaManagerProxy* quota_manager_proxy, | 107 storage::QuotaManagerProxy* quota_manager_proxy, |
| 88 storage::SpecialStoragePolicy* special_storage_policy) { | 108 storage::SpecialStoragePolicy* special_storage_policy) { |
| 89 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 109 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 90 | 110 |
| 91 DCHECK(!cache_manager_); | 111 DCHECK(!cache_manager_); |
| 92 cache_manager_ = | 112 cache_manager_ = |
| 93 CacheStorageManager::Create(user_data_directory, cache_task_runner.get(), | 113 CacheStorageManager::Create(user_data_directory, cache_task_runner.get(), |
| 94 make_scoped_refptr(quota_manager_proxy)); | 114 make_scoped_refptr(quota_manager_proxy)); |
| 95 } | 115 } |
| 96 | 116 |
| 97 void CacheStorageContextImpl::ShutdownOnIO() { | 117 void CacheStorageContextImpl::ShutdownOnIO() { |
| 98 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 118 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 99 | 119 |
| 100 cache_manager_.reset(); | 120 cache_manager_.reset(); |
| 101 } | 121 } |
| 102 | 122 |
| 103 } // namespace content | 123 } // namespace content |
| OLD | NEW |