| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "storage/browser/blob/blob_storage_registry.h" | 5 #include "storage/browser/blob/blob_storage_registry.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 BlobStorageRegistry::~BlobStorageRegistry() { | 56 BlobStorageRegistry::~BlobStorageRegistry() { |
| 57 // Note: We don't bother calling the construction complete callbacks, as we | 57 // Note: We don't bother calling the construction complete callbacks, as we |
| 58 // are only being destructed at the end of the life of the browser process. | 58 // are only being destructed at the end of the life of the browser process. |
| 59 // So it shouldn't matter. | 59 // So it shouldn't matter. |
| 60 } | 60 } |
| 61 | 61 |
| 62 BlobStorageRegistry::Entry* BlobStorageRegistry::CreateEntry( | 62 BlobStorageRegistry::Entry* BlobStorageRegistry::CreateEntry( |
| 63 const std::string& uuid, | 63 const std::string& uuid, |
| 64 const std::string& content_type, | 64 const std::string& content_type, |
| 65 const std::string& content_disposition) { | 65 const std::string& content_disposition) { |
| 66 DCHECK(!ContainsKey(blob_map_, uuid)); | 66 DCHECK(!base::ContainsKey(blob_map_, uuid)); |
| 67 std::unique_ptr<Entry> entry(new Entry(1, BlobState::PENDING)); | 67 std::unique_ptr<Entry> entry(new Entry(1, BlobState::PENDING)); |
| 68 entry->content_type = content_type; | 68 entry->content_type = content_type; |
| 69 entry->content_disposition = content_disposition; | 69 entry->content_disposition = content_disposition; |
| 70 Entry* entry_ptr = entry.get(); | 70 Entry* entry_ptr = entry.get(); |
| 71 blob_map_.add(uuid, std::move(entry)); | 71 blob_map_.add(uuid, std::move(entry)); |
| 72 return entry_ptr; | 72 return entry_ptr; |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool BlobStorageRegistry::DeleteEntry(const std::string& uuid) { | 75 bool BlobStorageRegistry::DeleteEntry(const std::string& uuid) { |
| 76 return blob_map_.erase(uuid) == 1; | 76 return blob_map_.erase(uuid) == 1; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 URLMap::iterator found = url_to_uuid_.find(blob_url); | 108 URLMap::iterator found = url_to_uuid_.find(blob_url); |
| 109 if (found == url_to_uuid_.end()) | 109 if (found == url_to_uuid_.end()) |
| 110 return false; | 110 return false; |
| 111 if (uuid) | 111 if (uuid) |
| 112 uuid->assign(found->second); | 112 uuid->assign(found->second); |
| 113 url_to_uuid_.erase(found); | 113 url_to_uuid_.erase(found); |
| 114 return true; | 114 return true; |
| 115 } | 115 } |
| 116 | 116 |
| 117 bool BlobStorageRegistry::IsURLMapped(const GURL& blob_url) const { | 117 bool BlobStorageRegistry::IsURLMapped(const GURL& blob_url) const { |
| 118 return ContainsKey(url_to_uuid_, blob_url); | 118 return base::ContainsKey(url_to_uuid_, blob_url); |
| 119 } | 119 } |
| 120 | 120 |
| 121 BlobStorageRegistry::Entry* BlobStorageRegistry::GetEntryFromURL( | 121 BlobStorageRegistry::Entry* BlobStorageRegistry::GetEntryFromURL( |
| 122 const GURL& url, | 122 const GURL& url, |
| 123 std::string* uuid) { | 123 std::string* uuid) { |
| 124 URLMap::iterator found = | 124 URLMap::iterator found = |
| 125 url_to_uuid_.find(BlobUrlHasRef(url) ? ClearBlobUrlRef(url) : url); | 125 url_to_uuid_.find(BlobUrlHasRef(url) ? ClearBlobUrlRef(url) : url); |
| 126 if (found == url_to_uuid_.end()) | 126 if (found == url_to_uuid_.end()) |
| 127 return nullptr; | 127 return nullptr; |
| 128 Entry* entry = GetEntry(found->second); | 128 Entry* entry = GetEntry(found->second); |
| 129 if (entry && uuid) | 129 if (entry && uuid) |
| 130 uuid->assign(found->second); | 130 uuid->assign(found->second); |
| 131 return entry; | 131 return entry; |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace storage | 134 } // namespace storage |
| OLD | NEW |