Commit 952f3b51 authored by jkarlin's avatar jkarlin Committed by Commit bot

[CacheStorage] Use a map of scoped_ptrs instead of raw pointers

Review URL: https://codereview.chromium.org/1468163002

Cr-Commit-Position: refs/heads/master@{#361324}
parent ac2843f9
...@@ -126,13 +126,7 @@ scoped_ptr<CacheStorageManager> CacheStorageManager::Create( ...@@ -126,13 +126,7 @@ scoped_ptr<CacheStorageManager> CacheStorageManager::Create(
return manager.Pass(); return manager.Pass();
} }
CacheStorageManager::~CacheStorageManager() { CacheStorageManager::~CacheStorageManager() = default;
DCHECK_CURRENTLY_ON(BrowserThread::IO);
for (CacheStorageMap::iterator it = cache_storage_map_.begin();
it != cache_storage_map_.end(); ++it) {
delete it->second;
}
}
void CacheStorageManager::OpenCache( void CacheStorageManager::OpenCache(
const GURL& origin, const GURL& origin,
...@@ -294,7 +288,13 @@ void CacheStorageManager::DeleteOriginData( ...@@ -294,7 +288,13 @@ void CacheStorageManager::DeleteOriginData(
const storage::QuotaClient::DeletionCallback& callback) { const storage::QuotaClient::DeletionCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); 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_map_.erase(origin);
cache_storage->CloseAllCaches( cache_storage->CloseAllCaches(
base::Bind(&CacheStorageManager::DeleteOriginDidClose, origin, callback, base::Bind(&CacheStorageManager::DeleteOriginDidClose, origin, callback,
...@@ -361,11 +361,11 @@ CacheStorage* CacheStorageManager::FindOrCreateCacheStorage( ...@@ -361,11 +361,11 @@ CacheStorage* CacheStorageManager::FindOrCreateCacheStorage(
ConstructOriginPath(root_path_, origin), IsMemoryBacked(), ConstructOriginPath(root_path_, origin), IsMemoryBacked(),
cache_task_runner_.get(), request_context_getter_, quota_manager_proxy_, cache_task_runner_.get(), request_context_getter_, quota_manager_proxy_,
blob_context_, origin); blob_context_, origin);
// The map owns fetch_stores. cache_storage_map_.insert(
cache_storage_map_.insert(std::make_pair(origin, cache_storage)); std::make_pair(origin, make_scoped_ptr(cache_storage)));
return cache_storage; return cache_storage;
} }
return it->second; return it->second.get();
} }
// static // static
......
...@@ -91,7 +91,7 @@ class CONTENT_EXPORT CacheStorageManager { ...@@ -91,7 +91,7 @@ class CONTENT_EXPORT CacheStorageManager {
friend class CacheStorageMigrationTest; friend class CacheStorageMigrationTest;
friend class CacheStorageQuotaClient; friend class CacheStorageQuotaClient;
typedef std::map<GURL, CacheStorage*> CacheStorageMap; typedef std::map<GURL, scoped_ptr<CacheStorage>> CacheStorageMap;
CacheStorageManager( CacheStorageManager(
const base::FilePath& path, const base::FilePath& path,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment