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