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 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 const base::Time& expected_modification_time); | 88 const base::Time& expected_modification_time); |
88 | 89 |
89 // You must know the length of the file, you cannot use kuint64max to specify | 90 // You must know the length of the file, you cannot use kuint64max to specify |
90 // the whole file. This method creates a ShareableFileReference to the given | 91 // the whole file. This method creates a ShareableFileReference to the given |
91 // file, which is stored in this builder. | 92 // file, which is stored in this builder. |
92 void AppendFile(const base::FilePath& file_path, | 93 void AppendFile(const base::FilePath& file_path, |
93 uint64_t offset, | 94 uint64_t offset, |
94 uint64_t length, | 95 uint64_t length, |
95 const base::Time& expected_modification_time); | 96 const base::Time& expected_modification_time); |
96 | 97 |
| 98 // You must know the length of the file, you cannot use kuint64max to specify |
| 99 // the whole file. |
| 100 void AppendShareableFileReference( |
| 101 const scoped_refptr<ShareableFileReference> file, |
| 102 uint64_t offset, |
| 103 uint64_t length, |
| 104 const base::Time& expected_modification_time); |
| 105 |
97 void AppendBlob(const std::string& uuid, uint64_t offset, uint64_t length); | 106 void AppendBlob(const std::string& uuid, uint64_t offset, uint64_t length); |
98 | 107 |
99 void AppendBlob(const std::string& uuid); | 108 void AppendBlob(const std::string& uuid); |
100 | 109 |
101 void AppendFileSystemFile(const GURL& url, | 110 void AppendFileSystemFile(const GURL& url, |
102 uint64_t offset, | 111 uint64_t offset, |
103 uint64_t length, | 112 uint64_t length, |
104 const base::Time& expected_modification_time); | 113 const base::Time& expected_modification_time); |
105 | 114 |
106 void AppendDiskCacheEntry(const scoped_refptr<DataHandle>& data_handle, | 115 void AppendDiskCacheEntry(const scoped_refptr<DataHandle>& data_handle, |
107 disk_cache::Entry* disk_cache_entry, | 116 disk_cache::Entry* disk_cache_entry, |
108 int disk_cache_stream_index); | 117 int disk_cache_stream_index); |
| 118 |
109 // The content of the side data is accessible with BlobReader::ReadSideData(). | 119 // The content of the side data is accessible with BlobReader::ReadSideData(). |
110 void AppendDiskCacheEntryWithSideData( | 120 void AppendDiskCacheEntryWithSideData( |
111 const scoped_refptr<DataHandle>& data_handle, | 121 const scoped_refptr<DataHandle>& data_handle, |
112 disk_cache::Entry* disk_cache_entry, | 122 disk_cache::Entry* disk_cache_entry, |
113 int disk_cache_stream_index, | 123 int disk_cache_stream_index, |
114 int disk_cache_side_stream_index); | 124 int disk_cache_side_stream_index); |
115 | 125 |
116 void set_content_type(const std::string& content_type) { | 126 void set_content_type(const std::string& content_type) { |
117 content_type_ = content_type; | 127 content_type_ = content_type; |
118 } | 128 } |
119 | 129 |
120 void set_content_disposition(const std::string& content_disposition) { | 130 void set_content_disposition(const std::string& content_disposition) { |
121 content_disposition_ = content_disposition; | 131 content_disposition_ = content_disposition; |
122 } | 132 } |
123 | 133 |
124 void Clear(); | 134 void Clear(); |
125 | 135 |
126 private: | 136 private: |
| 137 friend class BlobAsyncBuilderHostTest; |
| 138 friend class BlobFlattener; |
127 friend class BlobStorageContext; | 139 friend class BlobStorageContext; |
128 friend class BlobAsyncBuilderHostTest; | |
129 friend bool operator==(const BlobDataBuilder& a, const BlobDataBuilder& b); | 140 friend bool operator==(const BlobDataBuilder& a, const BlobDataBuilder& b); |
130 friend bool operator==(const BlobDataSnapshot& a, const BlobDataBuilder& b); | 141 friend bool operator==(const BlobDataSnapshot& a, const BlobDataBuilder& b); |
131 friend STORAGE_EXPORT void PrintTo(const BlobDataBuilder& x, | 142 friend STORAGE_EXPORT void PrintTo(const BlobDataBuilder& x, |
132 ::std::ostream* os); | 143 ::std::ostream* os); |
133 | 144 |
134 std::string uuid_; | 145 std::string uuid_; |
135 std::string content_type_; | 146 std::string content_type_; |
136 std::string content_disposition_; | 147 std::string content_disposition_; |
137 std::vector<scoped_refptr<BlobDataItem>> items_; | 148 std::vector<scoped_refptr<BlobDataItem>> items_; |
138 | 149 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 195 } |
185 | 196 |
186 inline bool operator!=(const BlobDataBuilder& a, const BlobDataSnapshot& b) { | 197 inline bool operator!=(const BlobDataBuilder& a, const BlobDataSnapshot& b) { |
187 return b != a; | 198 return b != a; |
188 } | 199 } |
189 | 200 |
190 #endif // defined(UNIT_TEST) | 201 #endif // defined(UNIT_TEST) |
191 | 202 |
192 } // namespace storage | 203 } // namespace storage |
193 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_ | 204 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_ |
OLD | NEW |