| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_CONTEXT_H_ | 5 #ifndef STORAGE_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ |
| 6 #define STORAGE_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ | 6 #define STORAGE_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 size_t memory_usage() const { return memory_usage_; } | 78 size_t memory_usage() const { return memory_usage_; } |
| 79 size_t blob_count() const { return registry_.blob_count(); } | 79 size_t blob_count() const { return registry_.blob_count(); } |
| 80 size_t memory_available() const { | 80 size_t memory_available() const { |
| 81 return kBlobStorageMaxMemoryUsage - memory_usage_; | 81 return kBlobStorageMaxMemoryUsage - memory_usage_; |
| 82 } | 82 } |
| 83 | 83 |
| 84 const BlobStorageRegistry& registry() { return registry_; } | 84 const BlobStorageRegistry& registry() { return registry_; } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 using BlobRegistryEntry = BlobStorageRegistry::Entry; | 87 using BlobRegistryEntry = BlobStorageRegistry::Entry; |
| 88 using BlobConstructedCallback = BlobStorageRegistry::BlobConstructedCallback; |
| 88 friend class content::BlobDispatcherHost; | 89 friend class content::BlobDispatcherHost; |
| 89 friend class BlobAsyncBuilderHost; | 90 friend class BlobAsyncBuilderHost; |
| 90 friend class BlobAsyncBuilderHostTest; | 91 friend class BlobAsyncBuilderHostTest; |
| 91 friend class BlobDataHandle; | 92 friend class BlobDataHandle; |
| 92 friend class BlobDataHandle::BlobDataHandleShared; | 93 friend class BlobDataHandle::BlobDataHandleShared; |
| 93 friend class BlobReaderTest; | 94 friend class BlobReaderTest; |
| 94 FRIEND_TEST_ALL_PREFIXES(BlobReaderTest, HandleBeforeAsyncCancel); | 95 FRIEND_TEST_ALL_PREFIXES(BlobReaderTest, HandleBeforeAsyncCancel); |
| 95 FRIEND_TEST_ALL_PREFIXES(BlobReaderTest, ReadFromIncompleteBlob); | 96 FRIEND_TEST_ALL_PREFIXES(BlobReaderTest, ReadFromIncompleteBlob); |
| 96 friend class BlobStorageContextTest; | 97 friend class BlobStorageContextTest; |
| 97 FRIEND_TEST_ALL_PREFIXES(BlobStorageContextTest, IncrementDecrementRef); | 98 FRIEND_TEST_ALL_PREFIXES(BlobStorageContextTest, IncrementDecrementRef); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 117 void IncrementBlobRefCount(const std::string& uuid); | 118 void IncrementBlobRefCount(const std::string& uuid); |
| 118 void DecrementBlobRefCount(const std::string& uuid); | 119 void DecrementBlobRefCount(const std::string& uuid); |
| 119 | 120 |
| 120 // Methods called by BlobDataHandle: | 121 // Methods called by BlobDataHandle: |
| 121 // This will return an empty snapshot until the blob is complete. | 122 // This will return an empty snapshot until the blob is complete. |
| 122 // TODO(dmurph): After we make the snapshot method in BlobHandle private, then | 123 // TODO(dmurph): After we make the snapshot method in BlobHandle private, then |
| 123 // make this DCHECK on the blob not being complete. | 124 // make this DCHECK on the blob not being complete. |
| 124 std::unique_ptr<BlobDataSnapshot> CreateSnapshot(const std::string& uuid); | 125 std::unique_ptr<BlobDataSnapshot> CreateSnapshot(const std::string& uuid); |
| 125 bool IsBroken(const std::string& uuid) const; | 126 bool IsBroken(const std::string& uuid) const; |
| 126 bool IsBeingBuilt(const std::string& uuid) const; | 127 bool IsBeingBuilt(const std::string& uuid) const; |
| 127 // Runs |done| when construction completes, with true if it was successful. | 128 // Runs |done| when construction completes, with true if it was successful, |
| 129 // and false if there was an error, which is reported in the second argument |
| 130 // of the callback. |
| 128 void RunOnConstructionComplete(const std::string& uuid, | 131 void RunOnConstructionComplete(const std::string& uuid, |
| 129 const base::Callback<void(bool)>& done); | 132 const BlobConstructedCallback& done); |
| 130 | 133 |
| 131 // Appends the given blob item to the blob builder. The new blob | 134 // Appends the given blob item to the blob builder. The new blob |
| 132 // retains ownership of data_item if applicable, and returns false if there | 135 // retains ownership of data_item if applicable, and returns false if there |
| 133 // was an error and pouplates the error_code. We can either have an error of: | 136 // was an error and pouplates the error_code. We can either have an error of: |
| 134 // OUT_OF_MEMORY: We are out of memory to store this blob. | 137 // OUT_OF_MEMORY: We are out of memory to store this blob. |
| 135 // REFERENCED_BLOB_BROKEN: One of the referenced blobs is broken. | 138 // REFERENCED_BLOB_BROKEN: One of the referenced blobs is broken. |
| 136 bool AppendAllocatedBlobItem(const std::string& target_blob_uuid, | 139 bool AppendAllocatedBlobItem(const std::string& target_blob_uuid, |
| 137 scoped_refptr<BlobDataItem> data_item, | 140 scoped_refptr<BlobDataItem> data_item, |
| 138 InternalBlobData::Builder* target_blob_data, | 141 InternalBlobData::Builder* target_blob_data, |
| 139 IPCBlobCreationCancelCode* error_code); | 142 IPCBlobCreationCancelCode* error_code); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 159 // we count only the items of TYPE_DATA which are held in memory and not | 162 // we count only the items of TYPE_DATA which are held in memory and not |
| 160 // items of TYPE_FILE. | 163 // items of TYPE_FILE. |
| 161 size_t memory_usage_; | 164 size_t memory_usage_; |
| 162 | 165 |
| 163 DISALLOW_COPY_AND_ASSIGN(BlobStorageContext); | 166 DISALLOW_COPY_AND_ASSIGN(BlobStorageContext); |
| 164 }; | 167 }; |
| 165 | 168 |
| 166 } // namespace storage | 169 } // namespace storage |
| 167 | 170 |
| 168 #endif // STORAGE_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ | 171 #endif // STORAGE_BROWSER_BLOB_BLOB_STORAGE_CONTEXT_H_ |
| OLD | NEW |