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

Unified Diff: content/browser/cache_storage/cache_storage_manager.cc

Issue 1468163002: [CacheStorage] Use a map of scoped_ptrs instead of raw pointers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/cache_storage/cache_storage_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/cache_storage/cache_storage_manager.cc
diff --git a/content/browser/cache_storage/cache_storage_manager.cc b/content/browser/cache_storage/cache_storage_manager.cc
index 939797d71e82fea692ae8edb64bec21e43d1af8c..84bb8e93d5f0b5d7f93ab5fee3bcca6f0f7a19ae 100644
--- a/content/browser/cache_storage/cache_storage_manager.cc
+++ b/content/browser/cache_storage/cache_storage_manager.cc
@@ -126,13 +126,7 @@ scoped_ptr<CacheStorageManager> CacheStorageManager::Create(
return manager.Pass();
}
-CacheStorageManager::~CacheStorageManager() {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- for (CacheStorageMap::iterator it = cache_storage_map_.begin();
- it != cache_storage_map_.end(); ++it) {
- delete it->second;
- }
-}
+CacheStorageManager::~CacheStorageManager() = default;
void CacheStorageManager::OpenCache(
const GURL& origin,
@@ -294,7 +288,13 @@ void CacheStorageManager::DeleteOriginData(
const storage::QuotaClient::DeletionCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- CacheStorage* cache_storage = FindOrCreateCacheStorage(origin);
+ CacheStorageMap::iterator it = cache_storage_map_.find(origin);
+ if (it == cache_storage_map_.end()) {
+ callback.Run(storage::kQuotaStatusOk);
+ return;
+ }
+
+ CacheStorage* cache_storage = it->second.release();
cache_storage_map_.erase(origin);
cache_storage->CloseAllCaches(
base::Bind(&CacheStorageManager::DeleteOriginDidClose, origin, callback,
@@ -361,11 +361,11 @@ CacheStorage* CacheStorageManager::FindOrCreateCacheStorage(
ConstructOriginPath(root_path_, origin), IsMemoryBacked(),
cache_task_runner_.get(), request_context_getter_, quota_manager_proxy_,
blob_context_, origin);
- // The map owns fetch_stores.
- cache_storage_map_.insert(std::make_pair(origin, cache_storage));
+ cache_storage_map_.insert(
+ std::make_pair(origin, make_scoped_ptr(cache_storage)));
return cache_storage;
}
- return it->second;
+ return it->second.get();
}
// static
« no previous file with comments | « content/browser/cache_storage/cache_storage_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698