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 <stdint.h> | 8 #include <stdint.h> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "storage/browser/blob/blob_data_item.h" | 16 #include "storage/browser/blob/blob_data_item.h" |
17 #include "storage/browser/blob/blob_data_snapshot.h" | 17 #include "storage/browser/blob/blob_data_snapshot.h" |
18 #include "storage/browser/storage_browser_export.h" | 18 #include "storage/browser/storage_browser_export.h" |
19 | 19 |
20 namespace disk_cache { | 20 namespace disk_cache { |
21 class Entry; | 21 class Entry; |
22 } | 22 } |
23 | 23 |
24 namespace storage { | 24 namespace storage { |
25 class BlobStorageContext; | 25 class BlobStorageContext; |
| 26 class ShareableFileReference; |
26 | 27 |
27 class STORAGE_EXPORT BlobDataBuilder { | 28 class STORAGE_EXPORT BlobDataBuilder { |
28 public: | 29 public: |
29 using DataHandle = BlobDataItem::DataHandle; | 30 using DataHandle = BlobDataItem::DataHandle; |
30 | 31 |
31 explicit BlobDataBuilder(const std::string& uuid); | 32 explicit BlobDataBuilder(const std::string& uuid); |
32 ~BlobDataBuilder(); | 33 ~BlobDataBuilder(); |
33 | 34 |
34 const std::string& uuid() const { return uuid_; } | 35 const std::string& uuid() const { return uuid_; } |
35 | 36 |
(...skipping 22 matching lines...) Expand all Loading... |
58 // data element. | 59 // data element. |
59 // Returns true if: | 60 // Returns true if: |
60 // * The item was created by using AppendFutureData, | 61 // * The item was created by using AppendFutureData, |
61 // * The offset and length are valid, and | 62 // * The offset and length are valid, and |
62 // * data is a valid pointer. | 63 // * data is a valid pointer. |
63 bool PopulateFutureData(size_t index, | 64 bool PopulateFutureData(size_t index, |
64 const char* data, | 65 const char* data, |
65 size_t offset, | 66 size_t offset, |
66 size_t length); | 67 size_t length); |
67 | 68 |
| 69 // Adds an item that is flagged for future data population. Use |
| 70 // 'PopulateFutureFile' to set the file path and expected modification time |
| 71 // of this file. Returns the index of the item (to be used in |
| 72 // PopulateFutureFile). Length cannot be 0. |
| 73 size_t AppendFutureFile(uint64_t offset, uint64_t length); |
| 74 |
| 75 // Populates a part of an item previously allocated with AppendFutureFile. |
| 76 // Returns true if: |
| 77 // * The item was created by using AppendFutureFile and |
| 78 // * The filepath is valid. |
| 79 bool PopulateFutureFile( |
| 80 size_t index, |
| 81 const scoped_refptr<ShareableFileReference>& file_reference, |
| 82 const base::Time& expected_modification_time); |
| 83 |
68 // You must know the length of the file, you cannot use kuint64max to specify | 84 // You must know the length of the file, you cannot use kuint64max to specify |
69 // the whole file. This method creates a ShareableFileReference to the given | 85 // the whole file. This method creates a ShareableFileReference to the given |
70 // file, which is stored in this builder. | 86 // file, which is stored in this builder. |
71 void AppendFile(const base::FilePath& file_path, | 87 void AppendFile(const base::FilePath& file_path, |
72 uint64_t offset, | 88 uint64_t offset, |
73 uint64_t length, | 89 uint64_t length, |
74 const base::Time& expected_modification_time); | 90 const base::Time& expected_modification_time); |
75 | 91 |
76 void AppendBlob(const std::string& uuid, uint64_t offset, uint64_t length); | 92 void AppendBlob(const std::string& uuid, uint64_t offset, uint64_t length); |
77 | 93 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 165 } |
150 | 166 |
151 inline bool operator!=(const BlobDataBuilder& a, const BlobDataBuilder& b) { | 167 inline bool operator!=(const BlobDataBuilder& a, const BlobDataBuilder& b) { |
152 return !(a == b); | 168 return !(a == b); |
153 } | 169 } |
154 | 170 |
155 #endif // defined(UNIT_TEST) | 171 #endif // defined(UNIT_TEST) |
156 | 172 |
157 } // namespace storage | 173 } // namespace storage |
158 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_ | 174 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_ |
OLD | NEW |