Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_DATA_ITEM_H_ | 5 #ifndef STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_ |
| 6 #define STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_ | 6 #define STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 // a different backend version (mem-to-disk or the reverse), then the item | 36 // a different backend version (mem-to-disk or the reverse), then the item |
| 37 // will be destructed after all pending reads are complete. | 37 // will be destructed after all pending reads are complete. |
| 38 class STORAGE_EXPORT DataHandle : public base::RefCounted<DataHandle> { | 38 class STORAGE_EXPORT DataHandle : public base::RefCounted<DataHandle> { |
| 39 protected: | 39 protected: |
| 40 virtual ~DataHandle() = 0; | 40 virtual ~DataHandle() = 0; |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 friend class base::RefCounted<DataHandle>; | 43 friend class base::RefCounted<DataHandle>; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 explicit BlobDataItem(std::unique_ptr<DataElement> item); | |
|
michaeln
2016/10/11 20:55:23
do these need to be public? what are the new consu
dmurph
2016/10/13 00:39:29
Done.
| |
| 47 BlobDataItem(std::unique_ptr<DataElement> item, | |
| 48 const scoped_refptr<DataHandle>& data_handle); | |
| 49 BlobDataItem(std::unique_ptr<DataElement> item, | |
| 50 const scoped_refptr<DataHandle>& data_handle, | |
| 51 disk_cache::Entry* entry, | |
| 52 int disk_cache_stream_index, | |
| 53 int disk_cache_side_stream_index); | |
| 54 | |
| 46 DataElement::Type type() const { return item_->type(); } | 55 DataElement::Type type() const { return item_->type(); } |
| 47 const char* bytes() const { return item_->bytes(); } | 56 const char* bytes() const { return item_->bytes(); } |
| 48 const base::FilePath& path() const { return item_->path(); } | 57 const base::FilePath& path() const { return item_->path(); } |
| 49 const GURL& filesystem_url() const { return item_->filesystem_url(); } | 58 const GURL& filesystem_url() const { return item_->filesystem_url(); } |
| 50 const std::string& blob_uuid() const { return item_->blob_uuid(); } | 59 const std::string& blob_uuid() const { return item_->blob_uuid(); } |
| 51 uint64_t offset() const { return item_->offset(); } | 60 uint64_t offset() const { return item_->offset(); } |
| 52 uint64_t length() const { return item_->length(); } | 61 uint64_t length() const { return item_->length(); } |
| 53 const base::Time& expected_modification_time() const { | 62 const base::Time& expected_modification_time() const { |
| 54 return item_->expected_modification_time(); | 63 return item_->expected_modification_time(); |
| 55 } | 64 } |
| 56 const DataElement& data_element() const { return *item_; } | 65 const DataElement& data_element() const { return *item_; } |
| 57 const DataElement* data_element_ptr() const { return item_.get(); } | 66 const DataElement* data_element_ptr() const { return item_.get(); } |
| 58 DataElement* data_element_ptr() { return item_.get(); } | 67 DataElement* data_element_ptr() { return item_.get(); } |
| 59 | 68 |
| 60 disk_cache::Entry* disk_cache_entry() const { return disk_cache_entry_; } | 69 disk_cache::Entry* disk_cache_entry() const { return disk_cache_entry_; } |
| 61 int disk_cache_stream_index() const { return disk_cache_stream_index_; } | 70 int disk_cache_stream_index() const { return disk_cache_stream_index_; } |
| 62 int disk_cache_side_stream_index() const { | 71 int disk_cache_side_stream_index() const { |
| 63 return disk_cache_side_stream_index_; | 72 return disk_cache_side_stream_index_; |
| 64 } | 73 } |
| 65 | 74 |
| 75 const scoped_refptr<DataHandle>& data_handle() const { return data_handle_; } | |
| 76 | |
| 66 private: | 77 private: |
| 67 friend class BlobDataBuilder; | 78 friend class BlobDataBuilder; |
| 68 friend class BlobStorageContext; | 79 friend class BlobStorageContext; |
| 69 friend class base::RefCounted<BlobDataItem>; | 80 friend class base::RefCounted<BlobDataItem>; |
| 70 friend STORAGE_EXPORT void PrintTo(const BlobDataItem& x, ::std::ostream* os); | 81 friend STORAGE_EXPORT void PrintTo(const BlobDataItem& x, ::std::ostream* os); |
| 71 | 82 |
| 72 explicit BlobDataItem(std::unique_ptr<DataElement> item); | |
| 73 BlobDataItem(std::unique_ptr<DataElement> item, | |
| 74 const scoped_refptr<DataHandle>& data_handle); | |
| 75 BlobDataItem(std::unique_ptr<DataElement> item, | |
| 76 const scoped_refptr<DataHandle>& data_handle, | |
| 77 disk_cache::Entry* entry, | |
| 78 int disk_cache_stream_index, | |
| 79 int disk_cache_side_stream_index); | |
| 80 virtual ~BlobDataItem(); | 83 virtual ~BlobDataItem(); |
| 81 | 84 |
| 82 std::unique_ptr<DataElement> item_; | 85 std::unique_ptr<DataElement> item_; |
| 83 scoped_refptr<DataHandle> data_handle_; | 86 scoped_refptr<DataHandle> data_handle_; |
| 84 | 87 |
| 85 // This naked pointer is safe because the scope is protected by the DataHandle | 88 // This naked pointer is safe because the scope is protected by the DataHandle |
| 86 // instance for disk cache entries during the lifetime of this BlobDataItem. | 89 // instance for disk cache entries during the lifetime of this BlobDataItem. |
| 87 disk_cache::Entry* disk_cache_entry_; | 90 disk_cache::Entry* disk_cache_entry_; |
| 88 int disk_cache_stream_index_; // For TYPE_DISK_CACHE_ENTRY. | 91 int disk_cache_stream_index_; // For TYPE_DISK_CACHE_ENTRY. |
| 89 int disk_cache_side_stream_index_; // For TYPE_DISK_CACHE_ENTRY. | 92 int disk_cache_side_stream_index_; // For TYPE_DISK_CACHE_ENTRY. |
| 90 }; | 93 }; |
| 91 | 94 |
| 92 STORAGE_EXPORT bool operator==(const BlobDataItem& a, const BlobDataItem& b); | 95 STORAGE_EXPORT bool operator==(const BlobDataItem& a, const BlobDataItem& b); |
| 93 STORAGE_EXPORT bool operator!=(const BlobDataItem& a, const BlobDataItem& b); | 96 STORAGE_EXPORT bool operator!=(const BlobDataItem& a, const BlobDataItem& b); |
| 94 | 97 |
| 95 } // namespace storage | 98 } // namespace storage |
| 96 | 99 |
| 97 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_ | 100 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_ITEM_H_ |
| OLD | NEW |