| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 // This class stores the blob data in the various states of construction, as | 26 // This class stores the blob data in the various states of construction, as |
| 27 // well as URL mappings to blob uuids. | 27 // well as URL mappings to blob uuids. |
| 28 // Implementation notes: | 28 // Implementation notes: |
| 29 // * There is no implicit refcounting in this class, except for setting the | 29 // * There is no implicit refcounting in this class, except for setting the |
| 30 // refcount to 1 on registration. | 30 // refcount to 1 on registration. |
| 31 // * When removing a uuid registration, we do not check for URL mappings to that | 31 // * When removing a uuid registration, we do not check for URL mappings to that |
| 32 // uuid. The user must keep track of these. | 32 // uuid. The user must keep track of these. |
| 33 class STORAGE_EXPORT BlobStorageRegistry { | 33 class STORAGE_EXPORT BlobStorageRegistry { |
| 34 public: | 34 public: |
| 35 // True means the blob was constructed successfully, and false means that |
| 36 // there was an error, which is reported in the second argument. |
| 37 using BlobConstructedCallback = |
| 38 base::Callback<void(bool, IPCBlobCreationCancelCode)>; |
| 39 |
| 35 enum class BlobState { | 40 enum class BlobState { |
| 36 // The blob is pending transportation from the renderer. This is the default | 41 // The blob is pending transportation from the renderer. This is the default |
| 37 // state on entry construction. | 42 // state on entry construction. |
| 38 PENDING, | 43 PENDING, |
| 39 // The blob is complete and can be read from. | 44 // The blob is complete and can be read from. |
| 40 COMPLETE, | 45 COMPLETE, |
| 41 // The blob is broken and no longer holds data. This happens when there was | 46 // The blob is broken and no longer holds data. This happens when there was |
| 42 // a problem constructing the blob, or we've run out of memory. | 47 // a problem constructing the blob, or we've run out of memory. |
| 43 BROKEN | 48 BROKEN |
| 44 }; | 49 }; |
| 45 | 50 |
| 46 struct STORAGE_EXPORT Entry { | 51 struct STORAGE_EXPORT Entry { |
| 47 size_t refcount; | 52 size_t refcount; |
| 48 BlobState state; | 53 BlobState state; |
| 49 std::vector<base::Callback<void(bool)>> build_completion_callbacks; | 54 std::vector<BlobConstructedCallback> build_completion_callbacks; |
| 50 | 55 |
| 51 // Only applicable if the state == BROKEN. | 56 // Only applicable if the state == BROKEN. |
| 52 IPCBlobCreationCancelCode broken_reason = | 57 IPCBlobCreationCancelCode broken_reason = |
| 53 IPCBlobCreationCancelCode::UNKNOWN; | 58 IPCBlobCreationCancelCode::UNKNOWN; |
| 54 | 59 |
| 55 // data and data_builder are mutually exclusive. | 60 // data and data_builder are mutually exclusive. |
| 56 std::unique_ptr<InternalBlobData> data; | 61 std::unique_ptr<InternalBlobData> data; |
| 57 std::unique_ptr<InternalBlobData::Builder> data_builder; | 62 std::unique_ptr<InternalBlobData::Builder> data_builder; |
| 58 | 63 |
| 59 std::string content_type; | 64 std::string content_type; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 using URLMap = std::map<GURL, std::string>; | 118 using URLMap = std::map<GURL, std::string>; |
| 114 | 119 |
| 115 BlobMap blob_map_; | 120 BlobMap blob_map_; |
| 116 URLMap url_to_uuid_; | 121 URLMap url_to_uuid_; |
| 117 | 122 |
| 118 DISALLOW_COPY_AND_ASSIGN(BlobStorageRegistry); | 123 DISALLOW_COPY_AND_ASSIGN(BlobStorageRegistry); |
| 119 }; | 124 }; |
| 120 | 125 |
| 121 } // namespace storage | 126 } // namespace storage |
| 122 #endif // STORAGE_BROWSER_BLOB_BLOB_STORAGE_REGISTRY_H_ | 127 #endif // STORAGE_BROWSER_BLOB_BLOB_STORAGE_REGISTRY_H_ |
| OLD | NEW |