| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_manager.h" | 5 #include "content/browser/cache_storage/cache_storage_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | |
| 9 #include <map> | 8 #include <map> |
| 10 #include <string> | 9 #include <string> |
| 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/id_map.h" | 15 #include "base/id_map.h" |
| 16 #include "base/sha1.h" | 16 #include "base/sha1.h" |
| 17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // static | 118 // static |
| 119 scoped_ptr<CacheStorageManager> CacheStorageManager::Create( | 119 scoped_ptr<CacheStorageManager> CacheStorageManager::Create( |
| 120 CacheStorageManager* old_manager) { | 120 CacheStorageManager* old_manager) { |
| 121 scoped_ptr<CacheStorageManager> manager(new CacheStorageManager( | 121 scoped_ptr<CacheStorageManager> manager(new CacheStorageManager( |
| 122 old_manager->root_path(), old_manager->cache_task_runner(), | 122 old_manager->root_path(), old_manager->cache_task_runner(), |
| 123 old_manager->quota_manager_proxy_.get())); | 123 old_manager->quota_manager_proxy_.get())); |
| 124 // These values may be NULL, in which case this will be called again later by | 124 // These values may be NULL, in which case this will be called again later by |
| 125 // the dispatcher host per usual. | 125 // the dispatcher host per usual. |
| 126 manager->SetBlobParametersForCache(old_manager->url_request_context_getter(), | 126 manager->SetBlobParametersForCache(old_manager->url_request_context_getter(), |
| 127 old_manager->blob_storage_context()); | 127 old_manager->blob_storage_context()); |
| 128 return manager.Pass(); | 128 return manager; |
| 129 } | 129 } |
| 130 | 130 |
| 131 CacheStorageManager::~CacheStorageManager() = default; | 131 CacheStorageManager::~CacheStorageManager() = default; |
| 132 | 132 |
| 133 void CacheStorageManager::OpenCache( | 133 void CacheStorageManager::OpenCache( |
| 134 const GURL& origin, | 134 const GURL& origin, |
| 135 const std::string& cache_name, | 135 const std::string& cache_name, |
| 136 const CacheStorage::CacheAndErrorCallback& callback) { | 136 const CacheStorage::CacheAndErrorCallback& callback) { |
| 137 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 137 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 138 | 138 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 cache_storage->EnumerateCaches(callback); | 171 cache_storage->EnumerateCaches(callback); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void CacheStorageManager::MatchCache( | 174 void CacheStorageManager::MatchCache( |
| 175 const GURL& origin, | 175 const GURL& origin, |
| 176 const std::string& cache_name, | 176 const std::string& cache_name, |
| 177 scoped_ptr<ServiceWorkerFetchRequest> request, | 177 scoped_ptr<ServiceWorkerFetchRequest> request, |
| 178 const CacheStorageCache::ResponseCallback& callback) { | 178 const CacheStorageCache::ResponseCallback& callback) { |
| 179 CacheStorage* cache_storage = FindOrCreateCacheStorage(origin); | 179 CacheStorage* cache_storage = FindOrCreateCacheStorage(origin); |
| 180 | 180 |
| 181 cache_storage->MatchCache(cache_name, request.Pass(), callback); | 181 cache_storage->MatchCache(cache_name, std::move(request), callback); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void CacheStorageManager::MatchAllCaches( | 184 void CacheStorageManager::MatchAllCaches( |
| 185 const GURL& origin, | 185 const GURL& origin, |
| 186 scoped_ptr<ServiceWorkerFetchRequest> request, | 186 scoped_ptr<ServiceWorkerFetchRequest> request, |
| 187 const CacheStorageCache::ResponseCallback& callback) { | 187 const CacheStorageCache::ResponseCallback& callback) { |
| 188 CacheStorage* cache_storage = FindOrCreateCacheStorage(origin); | 188 CacheStorage* cache_storage = FindOrCreateCacheStorage(origin); |
| 189 | 189 |
| 190 cache_storage->MatchAllCaches(request.Pass(), callback); | 190 cache_storage->MatchAllCaches(std::move(request), callback); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void CacheStorageManager::SetBlobParametersForCache( | 193 void CacheStorageManager::SetBlobParametersForCache( |
| 194 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, | 194 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, |
| 195 base::WeakPtr<storage::BlobStorageContext> blob_storage_context) { | 195 base::WeakPtr<storage::BlobStorageContext> blob_storage_context) { |
| 196 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 196 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 197 DCHECK(cache_storage_map_.empty()); | 197 DCHECK(cache_storage_map_.empty()); |
| 198 DCHECK(!request_context_getter_ || | 198 DCHECK(!request_context_getter_ || |
| 199 request_context_getter_.get() == request_context_getter.get()); | 199 request_context_getter_.get() == request_context_getter.get()); |
| 200 DCHECK(!blob_context_ || blob_context_.get() == blob_storage_context.get()); | 200 DCHECK(!blob_context_ || blob_context_.get() == blob_storage_context.get()); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 const base::FilePath& old_path, | 407 const base::FilePath& old_path, |
| 408 const base::FilePath& new_path) { | 408 const base::FilePath& new_path) { |
| 409 if (base::PathExists(old_path)) { | 409 if (base::PathExists(old_path)) { |
| 410 if (!base::PathExists(new_path)) | 410 if (!base::PathExists(new_path)) |
| 411 base::Move(old_path, new_path); | 411 base::Move(old_path, new_path); |
| 412 base::DeleteFile(old_path, /*recursive*/ true); | 412 base::DeleteFile(old_path, /*recursive*/ true); |
| 413 } | 413 } |
| 414 } | 414 } |
| 415 | 415 |
| 416 } // namespace content | 416 } // namespace content |
| OLD | NEW |