| 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 #ifndef STORAGE_BROWSER_BLOB_BLOB_STORAGE_REGISTRY_H_ | 5 #ifndef STORAGE_BROWSER_BLOB_BLOB_STORAGE_REGISTRY_H_ |
| 6 #define STORAGE_BROWSER_BLOB_BLOB_STORAGE_REGISTRY_H_ | 6 #define STORAGE_BROWSER_BLOB_BLOB_STORAGE_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // the blob is already in use, we return null. | 68 // the blob is already in use, we return null. |
| 69 Entry* CreateEntry(const std::string& uuid); | 69 Entry* CreateEntry(const std::string& uuid); |
| 70 | 70 |
| 71 // Removes the blob entry with the given uuid. This does not unmap any | 71 // Removes the blob entry with the given uuid. This does not unmap any |
| 72 // URLs that are pointing to this uuid. Returns if the entry existed. | 72 // URLs that are pointing to this uuid. Returns if the entry existed. |
| 73 bool DeleteEntry(const std::string& uuid); | 73 bool DeleteEntry(const std::string& uuid); |
| 74 | 74 |
| 75 // Gets the blob entry for the given uuid. Returns nullptr if the entry | 75 // Gets the blob entry for the given uuid. Returns nullptr if the entry |
| 76 // does not exist. | 76 // does not exist. |
| 77 Entry* GetEntry(const std::string& uuid); | 77 Entry* GetEntry(const std::string& uuid); |
| 78 const Entry* GetEntry(const std::string& uuid) const; |
| 78 | 79 |
| 79 // Creates a url mapping from blob uuid to the given url. Returns false if | 80 // Creates a url mapping from blob uuid to the given url. Returns false if |
| 80 // the uuid isn't mapped to an entry or if there already is a map for the URL. | 81 // the uuid isn't mapped to an entry or if there already is a map for the URL. |
| 81 bool CreateUrlMapping(const GURL& url, const std::string& uuid); | 82 bool CreateUrlMapping(const GURL& url, const std::string& uuid); |
| 82 | 83 |
| 83 // Removes the given URL mapping. Optionally populates a uuid string of the | 84 // Removes the given URL mapping. Optionally populates a uuid string of the |
| 84 // removed entry uuid. Returns false if the url isn't mapped. | 85 // removed entry uuid. Returns false if the url isn't mapped. |
| 85 bool DeleteURLMapping(const GURL& url, std::string* uuid); | 86 bool DeleteURLMapping(const GURL& url, std::string* uuid); |
| 86 | 87 |
| 87 // Returns if the url is mapped to a blob uuid. | 88 // Returns if the url is mapped to a blob uuid. |
| 88 bool IsURLMapped(const GURL& blob_url) const; | 89 bool IsURLMapped(const GURL& blob_url) const; |
| 89 | 90 |
| 90 // Returns the entry from the given url, and optionally populates the uuid for | 91 // Returns the entry from the given url, and optionally populates the uuid for |
| 91 // that entry. Returns a nullptr if the mapping or entry doesn't exist. | 92 // that entry. Returns a nullptr if the mapping or entry doesn't exist. |
| 92 Entry* GetEntryFromURL(const GURL& url, std::string* uuid); | 93 Entry* GetEntryFromURL(const GURL& url, std::string* uuid); |
| 93 | 94 |
| 94 size_t blob_count() const { return blob_map_.size(); } | 95 size_t blob_count() const { return blob_map_.size(); } |
| 95 size_t url_count() const { return url_to_uuid_.size(); } | 96 size_t url_count() const { return url_to_uuid_.size(); } |
| 96 | 97 |
| 97 private: | 98 private: |
| 99 friend class ViewBlobInternalsJob; |
| 98 using BlobMap = base::ScopedPtrHashMap<std::string, scoped_ptr<Entry>>; | 100 using BlobMap = base::ScopedPtrHashMap<std::string, scoped_ptr<Entry>>; |
| 99 using URLMap = std::map<GURL, std::string>; | 101 using URLMap = std::map<GURL, std::string>; |
| 100 | 102 |
| 101 BlobMap blob_map_; | 103 BlobMap blob_map_; |
| 102 URLMap url_to_uuid_; | 104 URLMap url_to_uuid_; |
| 103 | 105 |
| 104 DISALLOW_COPY_AND_ASSIGN(BlobStorageRegistry); | 106 DISALLOW_COPY_AND_ASSIGN(BlobStorageRegistry); |
| 105 }; | 107 }; |
| 106 | 108 |
| 107 } // namespace storage | 109 } // namespace storage |
| 108 #endif // STORAGE_BROWSER_BLOB_BLOB_STORAGE_REGISTRY_H_ | 110 #endif // STORAGE_BROWSER_BLOB_BLOB_STORAGE_REGISTRY_H_ |
| OLD | NEW |