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_BUILDER_H_ | 5 #ifndef STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_ |
6 #define STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_ | 6 #define STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <ostream> | 10 #include <ostream> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "storage/browser/blob/blob_data_item.h" | 17 #include "storage/browser/blob/blob_data_item.h" |
18 #include "storage/browser/blob/blob_data_snapshot.h" | 18 #include "storage/browser/blob/blob_data_snapshot.h" |
19 #include "storage/browser/blob/shareable_file_reference.h" | |
19 #include "storage/browser/storage_browser_export.h" | 20 #include "storage/browser/storage_browser_export.h" |
20 | 21 |
21 namespace disk_cache { | 22 namespace disk_cache { |
22 class Entry; | 23 class Entry; |
23 } | 24 } |
24 | 25 |
25 namespace storage { | 26 namespace storage { |
26 class BlobStorageContext; | 27 class BlobStorageContext; |
27 class ShareableFileReference; | 28 class ShareableFileReference; |
28 | 29 |
30 // A builder should only be used once to create a blob. Use | |
31 // BlobDataHandle::GetBlobStatus to check for an error after creating the blob. | |
29 class STORAGE_EXPORT BlobDataBuilder { | 32 class STORAGE_EXPORT BlobDataBuilder { |
30 public: | 33 public: |
31 using DataHandle = BlobDataItem::DataHandle; | 34 using DataHandle = BlobDataItem::DataHandle; |
32 | 35 |
33 // This is the filename used for the temporary file items added by | 36 // This is the filename used for the temporary file items added by |
34 // AppendFutureFile. | 37 // AppendFutureFile. |
35 const static char kAppendFutureFileTemporaryFileName[]; | 38 const static char kAppendFutureFileTemporaryFileName[]; |
michaeln
2016/08/15 22:44:42
shorter symbol names, maybe kUnpopulatedFileName o
| |
36 | 39 |
37 explicit BlobDataBuilder(const std::string& uuid); | 40 explicit BlobDataBuilder(const std::string& uuid); |
38 ~BlobDataBuilder(); | 41 ~BlobDataBuilder(); |
39 | 42 |
40 const std::string& uuid() const { return uuid_; } | 43 const std::string& uuid() const { return uuid_; } |
41 | 44 |
42 // Validates the data element that was sent over IPC, and copies the data if | 45 // Validates the data element that was sent over IPC, and copies the data if |
43 // it's a 'bytes' element. Data elements of BYTES_DESCRIPTION or | 46 // it's a 'bytes' element. Data elements of BYTES_DESCRIPTION or |
44 // DISK_CACHE_ENTRY types are not valid IPC data element types, and cannot be | 47 // DISK_CACHE_ENTRY types are not valid IPC data element types, and cannot be |
45 // given to this method. | 48 // given to this method. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 void AppendBlob(const std::string& uuid); | 102 void AppendBlob(const std::string& uuid); |
100 | 103 |
101 void AppendFileSystemFile(const GURL& url, | 104 void AppendFileSystemFile(const GURL& url, |
102 uint64_t offset, | 105 uint64_t offset, |
103 uint64_t length, | 106 uint64_t length, |
104 const base::Time& expected_modification_time); | 107 const base::Time& expected_modification_time); |
105 | 108 |
106 void AppendDiskCacheEntry(const scoped_refptr<DataHandle>& data_handle, | 109 void AppendDiskCacheEntry(const scoped_refptr<DataHandle>& data_handle, |
107 disk_cache::Entry* disk_cache_entry, | 110 disk_cache::Entry* disk_cache_entry, |
108 int disk_cache_stream_index); | 111 int disk_cache_stream_index); |
112 | |
109 // The content of the side data is accessible with BlobReader::ReadSideData(). | 113 // The content of the side data is accessible with BlobReader::ReadSideData(). |
110 void AppendDiskCacheEntryWithSideData( | 114 void AppendDiskCacheEntryWithSideData( |
111 const scoped_refptr<DataHandle>& data_handle, | 115 const scoped_refptr<DataHandle>& data_handle, |
112 disk_cache::Entry* disk_cache_entry, | 116 disk_cache::Entry* disk_cache_entry, |
113 int disk_cache_stream_index, | 117 int disk_cache_stream_index, |
114 int disk_cache_side_stream_index); | 118 int disk_cache_side_stream_index); |
115 | 119 |
116 void set_content_type(const std::string& content_type) { | 120 void set_content_type(const std::string& content_type) { |
117 content_type_ = content_type; | 121 content_type_ = content_type; |
118 } | 122 } |
119 | 123 |
120 void set_content_disposition(const std::string& content_disposition) { | 124 void set_content_disposition(const std::string& content_disposition) { |
121 content_disposition_ = content_disposition; | 125 content_disposition_ = content_disposition; |
122 } | 126 } |
123 | 127 |
124 void Clear(); | 128 void Clear(); |
125 | 129 |
126 private: | 130 private: |
131 friend class BlobAsyncBuilderHostTest; | |
132 friend struct BlobFlattener; | |
127 friend class BlobStorageContext; | 133 friend class BlobStorageContext; |
128 friend class BlobAsyncBuilderHostTest; | 134 FRIEND_TEST_ALL_PREFIXES(BlobStorageContextTest, BuildBlobFuzzish); |
129 friend bool operator==(const BlobDataBuilder& a, const BlobDataBuilder& b); | 135 friend bool operator==(const BlobDataBuilder& a, const BlobDataBuilder& b); |
130 friend bool operator==(const BlobDataSnapshot& a, const BlobDataBuilder& b); | 136 friend bool operator==(const BlobDataSnapshot& a, const BlobDataBuilder& b); |
131 friend STORAGE_EXPORT void PrintTo(const BlobDataBuilder& x, | 137 friend STORAGE_EXPORT void PrintTo(const BlobDataBuilder& x, |
132 ::std::ostream* os); | 138 ::std::ostream* os); |
133 | 139 |
134 std::string uuid_; | 140 std::string uuid_; |
135 std::string content_type_; | 141 std::string content_type_; |
136 std::string content_disposition_; | 142 std::string content_disposition_; |
137 std::vector<scoped_refptr<BlobDataItem>> items_; | 143 std::vector<scoped_refptr<BlobDataItem>> items_; |
138 | 144 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 } | 190 } |
185 | 191 |
186 inline bool operator!=(const BlobDataBuilder& a, const BlobDataSnapshot& b) { | 192 inline bool operator!=(const BlobDataBuilder& a, const BlobDataSnapshot& b) { |
187 return b != a; | 193 return b != a; |
188 } | 194 } |
189 | 195 |
190 #endif // defined(UNIT_TEST) | 196 #endif // defined(UNIT_TEST) |
191 | 197 |
192 } // namespace storage | 198 } // namespace storage |
193 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_ | 199 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_ |
OLD | NEW |