| 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/service_worker/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/fileapi/chrome_blob_storage_context.h" | 11 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
| 11 #include "content/browser/service_worker/service_worker_cache_storage_manager.h" | |
| 12 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "net/url_request/url_request_context_getter.h" | 14 #include "net/url_request/url_request_context_getter.h" |
| 15 #include "storage/browser/blob/blob_storage_context.h" | 15 #include "storage/browser/blob/blob_storage_context.h" |
| 16 #include "storage/browser/quota/quota_manager_proxy.h" | 16 #include "storage/browser/quota/quota_manager_proxy.h" |
| 17 #include "storage/browser/quota/special_storage_policy.h" | 17 #include "storage/browser/quota/special_storage_policy.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 CacheStorageContextImpl::CacheStorageContextImpl( | 21 CacheStorageContextImpl::CacheStorageContextImpl( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 | 59 |
| 60 void CacheStorageContextImpl::Shutdown() { | 60 void CacheStorageContextImpl::Shutdown() { |
| 61 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 61 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 62 | 62 |
| 63 BrowserThread::PostTask( | 63 BrowserThread::PostTask( |
| 64 BrowserThread::IO, FROM_HERE, | 64 BrowserThread::IO, FROM_HERE, |
| 65 base::Bind(&CacheStorageContextImpl::ShutdownOnIO, this)); | 65 base::Bind(&CacheStorageContextImpl::ShutdownOnIO, this)); |
| 66 } | 66 } |
| 67 | 67 |
| 68 ServiceWorkerCacheStorageManager* CacheStorageContextImpl::cache_manager() | 68 CacheStorageManager* CacheStorageContextImpl::cache_manager() const { |
| 69 const { | |
| 70 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 69 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 71 return cache_manager_.get(); | 70 return cache_manager_.get(); |
| 72 } | 71 } |
| 73 | 72 |
| 74 void CacheStorageContextImpl::SetBlobParametersForCache( | 73 void CacheStorageContextImpl::SetBlobParametersForCache( |
| 75 net::URLRequestContextGetter* request_context, | 74 net::URLRequestContextGetter* request_context, |
| 76 ChromeBlobStorageContext* blob_storage_context) { | 75 ChromeBlobStorageContext* blob_storage_context) { |
| 77 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 76 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 78 | 77 |
| 79 if (cache_manager_ && request_context && blob_storage_context) { | 78 if (cache_manager_ && request_context && blob_storage_context) { |
| 80 cache_manager_->SetBlobParametersForCache( | 79 cache_manager_->SetBlobParametersForCache( |
| 81 request_context->GetURLRequestContext(), | 80 request_context->GetURLRequestContext(), |
| 82 blob_storage_context->context()->AsWeakPtr()); | 81 blob_storage_context->context()->AsWeakPtr()); |
| 83 } | 82 } |
| 84 } | 83 } |
| 85 | 84 |
| 86 void CacheStorageContextImpl::CreateCacheStorageManager( | 85 void CacheStorageContextImpl::CreateCacheStorageManager( |
| 87 const base::FilePath& user_data_directory, | 86 const base::FilePath& user_data_directory, |
| 88 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, | 87 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, |
| 89 storage::QuotaManagerProxy* quota_manager_proxy, | 88 storage::QuotaManagerProxy* quota_manager_proxy, |
| 90 storage::SpecialStoragePolicy* special_storage_policy) { | 89 storage::SpecialStoragePolicy* special_storage_policy) { |
| 91 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 90 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 92 | 91 |
| 93 DCHECK(!cache_manager_); | 92 DCHECK(!cache_manager_); |
| 94 cache_manager_ = ServiceWorkerCacheStorageManager::Create( | 93 cache_manager_ = |
| 95 user_data_directory, cache_task_runner.get(), | 94 CacheStorageManager::Create(user_data_directory, cache_task_runner.get(), |
| 96 make_scoped_refptr(quota_manager_proxy)); | 95 make_scoped_refptr(quota_manager_proxy)); |
| 97 } | 96 } |
| 98 | 97 |
| 99 void CacheStorageContextImpl::ShutdownOnIO() { | 98 void CacheStorageContextImpl::ShutdownOnIO() { |
| 100 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 99 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 101 | 100 |
| 102 cache_manager_.reset(); | 101 cache_manager_.reset(); |
| 103 } | 102 } |
| 104 | 103 |
| 105 } // namespace content | 104 } // namespace content |
| OLD | NEW |