Commit aecef39c authored by avi's avatar avi Committed by Commit bot

Remove base::ScopedPtrHashMap from storage/.

BUG=579229

Review-Url: https://codereview.chromium.org/2604913002
Cr-Commit-Position: refs/heads/master@{#440872}
parent 3171a243
......@@ -11,7 +11,7 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "base/memory/ptr_util.h"
#include "storage/browser/blob/blob_entry.h"
#include "url/gurl.h"
......@@ -49,11 +49,11 @@ BlobEntry* BlobStorageRegistry::CreateEntry(
const std::string& uuid,
const std::string& content_type,
const std::string& content_disposition) {
DCHECK(!ContainsKey(blob_map_, uuid));
std::unique_ptr<BlobEntry> entry(
new BlobEntry(content_type, content_disposition));
DCHECK(blob_map_.find(uuid) == blob_map_.end());
std::unique_ptr<BlobEntry> entry =
base::MakeUnique<BlobEntry>(content_type, content_disposition);
BlobEntry* entry_ptr = entry.get();
blob_map_.add(uuid, std::move(entry));
blob_map_[uuid] = std::move(entry);
return entry_ptr;
}
......@@ -66,10 +66,10 @@ bool BlobStorageRegistry::HasEntry(const std::string& uuid) const {
}
BlobEntry* BlobStorageRegistry::GetEntry(const std::string& uuid) {
BlobMap::iterator found = blob_map_.find(uuid);
auto found = blob_map_.find(uuid);
if (found == blob_map_.end())
return nullptr;
return found->second;
return found->second.get();
}
const BlobEntry* BlobStorageRegistry::GetEntry(const std::string& uuid) const {
......@@ -88,7 +88,7 @@ bool BlobStorageRegistry::CreateUrlMapping(const GURL& blob_url,
bool BlobStorageRegistry::DeleteURLMapping(const GURL& blob_url,
std::string* uuid) {
DCHECK(!BlobUrlHasRef(blob_url));
URLMap::iterator found = url_to_uuid_.find(blob_url);
auto found = url_to_uuid_.find(blob_url);
if (found == url_to_uuid_.end())
return false;
if (uuid)
......@@ -98,12 +98,12 @@ bool BlobStorageRegistry::DeleteURLMapping(const GURL& blob_url,
}
bool BlobStorageRegistry::IsURLMapped(const GURL& blob_url) const {
return base::ContainsKey(url_to_uuid_, blob_url);
return url_to_uuid_.find(blob_url) != url_to_uuid_.end();
}
BlobEntry* BlobStorageRegistry::GetEntryFromURL(const GURL& url,
std::string* uuid) {
URLMap::iterator found =
auto found =
url_to_uuid_.find(BlobUrlHasRef(url) ? ClearBlobUrlRef(url) : url);
if (found == url_to_uuid_.end())
return nullptr;
......
......@@ -10,10 +10,10 @@
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "base/callback_forward.h"
#include "base/containers/scoped_ptr_hash_map.h"
#include "base/macros.h"
#include "storage/browser/storage_browser_export.h"
#include "storage/common/blob_storage/blob_storage_constants.h"
......@@ -70,12 +70,9 @@ class STORAGE_EXPORT BlobStorageRegistry {
private:
friend class ViewBlobInternalsJob;
using BlobMap =
base::ScopedPtrHashMap<std::string, std::unique_ptr<BlobEntry>>;
using URLMap = std::map<GURL, std::string>;
BlobMap blob_map_;
URLMap url_to_uuid_;
std::unordered_map<std::string, std::unique_ptr<BlobEntry>> blob_map_;
std::map<GURL, std::string> url_to_uuid_;
DISALLOW_COPY_AND_ASSIGN(BlobStorageRegistry);
};
......
......@@ -153,8 +153,7 @@ int ViewBlobInternalsJob::GetData(
}
void ViewBlobInternalsJob::GenerateHTML(std::string* out) const {
for (BlobStorageRegistry::BlobMap::const_iterator iter =
blob_storage_context_->registry().blob_map_.begin();
for (auto iter = blob_storage_context_->registry().blob_map_.begin();
iter != blob_storage_context_->registry().blob_map_.end(); ++iter) {
AddHTMLBoldText(iter->first, out);
GenerateHTMLForBlobData(*iter->second, iter->second->content_type(),
......@@ -163,8 +162,7 @@ void ViewBlobInternalsJob::GenerateHTML(std::string* out) const {
}
if (!blob_storage_context_->registry().url_to_uuid_.empty()) {
AddHorizontalRule(out);
for (BlobStorageRegistry::URLMap::const_iterator iter =
blob_storage_context_->registry().url_to_uuid_.begin();
for (auto iter = blob_storage_context_->registry().url_to_uuid_.begin();
iter != blob_storage_context_->registry().url_to_uuid_.end(); ++iter) {
AddHTMLBoldText(iter->first.spec(), out);
StartHTMLList(out);
......
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