Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(570)

Side by Side Diff: content/browser/cache_storage/cache_storage_manager.cc

Issue 1174943004: [CacheStorage] Use URLRequestContextGetter instead of URLRequestContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from PS4 Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 92 }
93 93
94 // static 94 // static
95 scoped_ptr<CacheStorageManager> CacheStorageManager::Create( 95 scoped_ptr<CacheStorageManager> CacheStorageManager::Create(
96 CacheStorageManager* old_manager) { 96 CacheStorageManager* old_manager) {
97 scoped_ptr<CacheStorageManager> manager(new CacheStorageManager( 97 scoped_ptr<CacheStorageManager> manager(new CacheStorageManager(
98 old_manager->root_path(), old_manager->cache_task_runner(), 98 old_manager->root_path(), old_manager->cache_task_runner(),
99 old_manager->quota_manager_proxy_.get())); 99 old_manager->quota_manager_proxy_.get()));
100 // These values may be NULL, in which case this will be called again later by 100 // These values may be NULL, in which case this will be called again later by
101 // the dispatcher host per usual. 101 // the dispatcher host per usual.
102 manager->SetBlobParametersForCache(old_manager->url_request_context(), 102 manager->SetBlobParametersForCache(old_manager->url_request_context_getter(),
103 old_manager->blob_storage_context()); 103 old_manager->blob_storage_context());
104 return manager.Pass(); 104 return manager.Pass();
105 } 105 }
106 106
107 CacheStorageManager::~CacheStorageManager() { 107 CacheStorageManager::~CacheStorageManager() {
108 DCHECK_CURRENTLY_ON(BrowserThread::IO); 108 DCHECK_CURRENTLY_ON(BrowserThread::IO);
109 for (CacheStorageMap::iterator it = cache_storage_map_.begin(); 109 for (CacheStorageMap::iterator it = cache_storage_map_.begin();
110 it != cache_storage_map_.end(); ++it) { 110 it != cache_storage_map_.end(); ++it) {
111 delete it->second; 111 delete it->second;
112 } 112 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 void CacheStorageManager::MatchAllCaches( 166 void CacheStorageManager::MatchAllCaches(
167 const GURL& origin, 167 const GURL& origin,
168 scoped_ptr<ServiceWorkerFetchRequest> request, 168 scoped_ptr<ServiceWorkerFetchRequest> request,
169 const CacheStorageCache::ResponseCallback& callback) { 169 const CacheStorageCache::ResponseCallback& callback) {
170 CacheStorage* cache_storage = FindOrCreateCacheStorage(origin); 170 CacheStorage* cache_storage = FindOrCreateCacheStorage(origin);
171 171
172 cache_storage->MatchAllCaches(request.Pass(), callback); 172 cache_storage->MatchAllCaches(request.Pass(), callback);
173 } 173 }
174 174
175 void CacheStorageManager::SetBlobParametersForCache( 175 void CacheStorageManager::SetBlobParametersForCache(
176 net::URLRequestContext* request_context, 176 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
177 base::WeakPtr<storage::BlobStorageContext> blob_storage_context) { 177 base::WeakPtr<storage::BlobStorageContext> blob_storage_context) {
178 DCHECK_CURRENTLY_ON(BrowserThread::IO); 178 DCHECK_CURRENTLY_ON(BrowserThread::IO);
179 DCHECK(cache_storage_map_.empty()); 179 DCHECK(cache_storage_map_.empty());
180 DCHECK(!request_context_ || request_context_ == request_context); 180 DCHECK(!request_context_getter_ ||
181 request_context_getter_.get() == request_context_getter.get());
181 DCHECK(!blob_context_ || blob_context_.get() == blob_storage_context.get()); 182 DCHECK(!blob_context_ || blob_context_.get() == blob_storage_context.get());
182 request_context_ = request_context; 183 request_context_getter_ = request_context_getter;
183 blob_context_ = blob_storage_context; 184 blob_context_ = blob_storage_context;
184 } 185 }
185 186
186 void CacheStorageManager::GetOriginUsage( 187 void CacheStorageManager::GetOriginUsage(
187 const GURL& origin_url, 188 const GURL& origin_url,
188 const storage::QuotaClient::GetUsageCallback& callback) { 189 const storage::QuotaClient::GetUsageCallback& callback) {
189 DCHECK_CURRENTLY_ON(BrowserThread::IO); 190 DCHECK_CURRENTLY_ON(BrowserThread::IO);
190 191
191 if (IsMemoryBacked()) { 192 if (IsMemoryBacked()) {
192 int64 sum = 0; 193 int64 sum = 0;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 base::Bind(&DeleteOriginDidDeleteDir, callback)); 286 base::Bind(&DeleteOriginDidDeleteDir, callback));
286 } 287 }
287 288
288 CacheStorageManager::CacheStorageManager( 289 CacheStorageManager::CacheStorageManager(
289 const base::FilePath& path, 290 const base::FilePath& path,
290 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, 291 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner,
291 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy) 292 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy)
292 : root_path_(path), 293 : root_path_(path),
293 cache_task_runner_(cache_task_runner), 294 cache_task_runner_(cache_task_runner),
294 quota_manager_proxy_(quota_manager_proxy), 295 quota_manager_proxy_(quota_manager_proxy),
295 request_context_(NULL),
296 weak_ptr_factory_(this) { 296 weak_ptr_factory_(this) {
297 if (quota_manager_proxy_.get()) { 297 if (quota_manager_proxy_.get()) {
298 quota_manager_proxy_->RegisterClient( 298 quota_manager_proxy_->RegisterClient(
299 new CacheStorageQuotaClient(weak_ptr_factory_.GetWeakPtr())); 299 new CacheStorageQuotaClient(weak_ptr_factory_.GetWeakPtr()));
300 } 300 }
301 } 301 }
302 302
303 CacheStorage* CacheStorageManager::FindOrCreateCacheStorage( 303 CacheStorage* CacheStorageManager::FindOrCreateCacheStorage(
304 const GURL& origin) { 304 const GURL& origin) {
305 DCHECK_CURRENTLY_ON(BrowserThread::IO); 305 DCHECK_CURRENTLY_ON(BrowserThread::IO);
306 DCHECK(request_context_); 306 DCHECK(request_context_getter_);
307 CacheStorageMap::const_iterator it = cache_storage_map_.find(origin); 307 CacheStorageMap::const_iterator it = cache_storage_map_.find(origin);
308 if (it == cache_storage_map_.end()) { 308 if (it == cache_storage_map_.end()) {
309 MigrateOrigin(origin); 309 MigrateOrigin(origin);
310 CacheStorage* cache_storage = new CacheStorage( 310 CacheStorage* cache_storage = new CacheStorage(
311 ConstructOriginPath(root_path_, origin), IsMemoryBacked(), 311 ConstructOriginPath(root_path_, origin), IsMemoryBacked(),
312 cache_task_runner_.get(), request_context_, quota_manager_proxy_, 312 cache_task_runner_.get(), request_context_getter_, quota_manager_proxy_,
313 blob_context_, origin); 313 blob_context_, origin);
314 // The map owns fetch_stores. 314 // The map owns fetch_stores.
315 cache_storage_map_.insert(std::make_pair(origin, cache_storage)); 315 cache_storage_map_.insert(std::make_pair(origin, cache_storage));
316 return cache_storage; 316 return cache_storage;
317 } 317 }
318 return it->second; 318 return it->second;
319 } 319 }
320 320
321 // static 321 // static
322 base::FilePath CacheStorageManager::ConstructLegacyOriginPath( 322 base::FilePath CacheStorageManager::ConstructLegacyOriginPath(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 const base::FilePath& old_path, 355 const base::FilePath& old_path,
356 const base::FilePath& new_path) { 356 const base::FilePath& new_path) {
357 if (base::PathExists(old_path)) { 357 if (base::PathExists(old_path)) {
358 if (!base::PathExists(new_path)) 358 if (!base::PathExists(new_path))
359 base::Move(old_path, new_path); 359 base::Move(old_path, new_path);
360 base::DeleteFile(old_path, /*recursive*/ true); 360 base::DeleteFile(old_path, /*recursive*/ true);
361 } 361 }
362 } 362 }
363 363
364 } // namespace content 364 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/cache_storage/cache_storage_manager.h ('k') | content/browser/cache_storage/cache_storage_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698