| 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/sequenced_task_runner.h" | 9 #include "base/sequenced_task_runner.h" |
| 10 #include "base/task_scheduler/post_task.h" | 10 #include "base/task_scheduler/post_task.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // posted task can register the quota client. | 43 // posted task can register the quota client. |
| 44 // TODO: Fix the tests to let the quota manager initialize normally. | 44 // TODO: Fix the tests to let the quota manager initialize normally. |
| 45 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 45 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 46 CreateCacheStorageManager(user_data_directory, cache_task_runner, | 46 CreateCacheStorageManager(user_data_directory, cache_task_runner, |
| 47 std::move(quota_manager_proxy)); | 47 std::move(quota_manager_proxy)); |
| 48 return; | 48 return; |
| 49 } | 49 } |
| 50 | 50 |
| 51 BrowserThread::PostTask( | 51 BrowserThread::PostTask( |
| 52 BrowserThread::IO, FROM_HERE, | 52 BrowserThread::IO, FROM_HERE, |
| 53 base::Bind(&CacheStorageContextImpl::CreateCacheStorageManager, this, | 53 base::BindOnce(&CacheStorageContextImpl::CreateCacheStorageManager, this, |
| 54 user_data_directory, cache_task_runner, | 54 user_data_directory, cache_task_runner, |
| 55 std::move(quota_manager_proxy))); | 55 std::move(quota_manager_proxy))); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void CacheStorageContextImpl::Shutdown() { | 58 void CacheStorageContextImpl::Shutdown() { |
| 59 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 59 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 60 | 60 |
| 61 BrowserThread::PostTask( | 61 BrowserThread::PostTask( |
| 62 BrowserThread::IO, FROM_HERE, | 62 BrowserThread::IO, FROM_HERE, |
| 63 base::Bind(&CacheStorageContextImpl::ShutdownOnIO, this)); | 63 base::BindOnce(&CacheStorageContextImpl::ShutdownOnIO, this)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 CacheStorageManager* CacheStorageContextImpl::cache_manager() const { | 66 CacheStorageManager* CacheStorageContextImpl::cache_manager() const { |
| 67 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 67 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 68 return cache_manager_.get(); | 68 return cache_manager_.get(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void CacheStorageContextImpl::SetBlobParametersForCache( | 71 void CacheStorageContextImpl::SetBlobParametersForCache( |
| 72 net::URLRequestContextGetter* request_context_getter, | 72 net::URLRequestContextGetter* request_context_getter, |
| 73 ChromeBlobStorageContext* blob_storage_context) { | 73 ChromeBlobStorageContext* blob_storage_context) { |
| 74 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 74 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 75 | 75 |
| 76 if (cache_manager_ && request_context_getter && blob_storage_context) { | 76 if (cache_manager_ && request_context_getter && blob_storage_context) { |
| 77 cache_manager_->SetBlobParametersForCache( | 77 cache_manager_->SetBlobParametersForCache( |
| 78 request_context_getter, blob_storage_context->context()->AsWeakPtr()); | 78 request_context_getter, blob_storage_context->context()->AsWeakPtr()); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 void CacheStorageContextImpl::GetAllOriginsInfo( | 82 void CacheStorageContextImpl::GetAllOriginsInfo( |
| 83 const CacheStorageContext::GetUsageInfoCallback& callback) { | 83 const CacheStorageContext::GetUsageInfoCallback& callback) { |
| 84 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 84 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 85 | 85 |
| 86 if (!cache_manager_) { | 86 if (!cache_manager_) { |
| 87 BrowserThread::PostTask( | 87 BrowserThread::PostTask( |
| 88 BrowserThread::IO, FROM_HERE, | 88 BrowserThread::IO, FROM_HERE, |
| 89 base::Bind(callback, std::vector<CacheStorageUsageInfo>())); | 89 base::BindOnce(callback, std::vector<CacheStorageUsageInfo>())); |
| 90 return; | 90 return; |
| 91 } | 91 } |
| 92 | 92 |
| 93 cache_manager_->GetAllOriginsUsage(callback); | 93 cache_manager_->GetAllOriginsUsage(callback); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void CacheStorageContextImpl::DeleteForOrigin(const GURL& origin) { | 96 void CacheStorageContextImpl::DeleteForOrigin(const GURL& origin) { |
| 97 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 97 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 98 if (cache_manager_) | 98 if (cache_manager_) |
| 99 cache_manager_->DeleteOriginData(origin); | 99 cache_manager_->DeleteOriginData(origin); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 110 user_data_directory, cache_task_runner, std::move(quota_manager_proxy)); | 110 user_data_directory, cache_task_runner, std::move(quota_manager_proxy)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void CacheStorageContextImpl::ShutdownOnIO() { | 113 void CacheStorageContextImpl::ShutdownOnIO() { |
| 114 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 114 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 115 | 115 |
| 116 cache_manager_.reset(); | 116 cache_manager_.reset(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace content | 119 } // namespace content |
| OLD | NEW |