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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "storage/browser/blob/blob_data_item.h" | 15 #include "storage/browser/blob/blob_data_item.h" |
16 #include "storage/browser/blob/blob_data_snapshot.h" | 16 #include "storage/browser/blob/blob_data_snapshot.h" |
17 #include "storage/browser/storage_browser_export.h" | 17 #include "storage/browser/storage_browser_export.h" |
18 | 18 |
| 19 namespace disk_cache { |
| 20 class Entry; |
| 21 } |
| 22 |
19 namespace storage { | 23 namespace storage { |
20 class BlobStorageContext; | 24 class BlobStorageContext; |
21 | 25 |
22 class STORAGE_EXPORT BlobDataBuilder { | 26 class STORAGE_EXPORT BlobDataBuilder { |
23 public: | 27 public: |
| 28 using DataHandle = BlobDataItem::DataHandle; |
| 29 |
24 explicit BlobDataBuilder(const std::string& uuid); | 30 explicit BlobDataBuilder(const std::string& uuid); |
25 ~BlobDataBuilder(); | 31 ~BlobDataBuilder(); |
26 | 32 |
27 const std::string& uuid() const { return uuid_; } | 33 const std::string& uuid() const { return uuid_; } |
28 | 34 |
29 void AppendData(const std::string& data) { | 35 void AppendData(const std::string& data) { |
30 AppendData(data.c_str(), data.size()); | 36 AppendData(data.c_str(), data.size()); |
31 } | 37 } |
32 | 38 |
33 void AppendData(const char* data, size_t length); | 39 void AppendData(const char* data, size_t length); |
34 | 40 |
35 // You must know the length of the file, you cannot use kuint64max to specify | 41 // You must know the length of the file, you cannot use kuint64max to specify |
36 // the whole file. This method creates a ShareableFileReference to the given | 42 // the whole file. This method creates a ShareableFileReference to the given |
37 // file, which is stored in this builder. | 43 // file, which is stored in this builder. |
38 void AppendFile(const base::FilePath& file_path, | 44 void AppendFile(const base::FilePath& file_path, |
39 uint64_t offset, | 45 uint64_t offset, |
40 uint64_t length, | 46 uint64_t length, |
41 const base::Time& expected_modification_time); | 47 const base::Time& expected_modification_time); |
42 | 48 |
43 void AppendBlob(const std::string& uuid, uint64_t offset, uint64_t length); | 49 void AppendBlob(const std::string& uuid, uint64_t offset, uint64_t length); |
44 | 50 |
45 void AppendBlob(const std::string& uuid); | 51 void AppendBlob(const std::string& uuid); |
46 | 52 |
47 void AppendFileSystemFile(const GURL& url, | 53 void AppendFileSystemFile(const GURL& url, |
48 uint64_t offset, | 54 uint64_t offset, |
49 uint64_t length, | 55 uint64_t length, |
50 const base::Time& expected_modification_time); | 56 const base::Time& expected_modification_time); |
51 | 57 |
| 58 void AppendDiskCacheEntry(const scoped_refptr<DataHandle>& data_handle, |
| 59 disk_cache::Entry* disk_cache_entry, |
| 60 int disk_cache_stream_index); |
| 61 |
52 void set_content_type(const std::string& content_type) { | 62 void set_content_type(const std::string& content_type) { |
53 content_type_ = content_type; | 63 content_type_ = content_type; |
54 } | 64 } |
55 | 65 |
56 void set_content_disposition(const std::string& content_disposition) { | 66 void set_content_disposition(const std::string& content_disposition) { |
57 content_disposition_ = content_disposition; | 67 content_disposition_ = content_disposition; |
58 } | 68 } |
59 | 69 |
60 private: | 70 private: |
61 friend class BlobStorageContext; | 71 friend class BlobStorageContext; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 return !(a == b); | 116 return !(a == b); |
107 } | 117 } |
108 | 118 |
109 inline bool operator!=(const BlobDataBuilder& a, const BlobDataBuilder& b) { | 119 inline bool operator!=(const BlobDataBuilder& a, const BlobDataBuilder& b) { |
110 return !(a == b); | 120 return !(a == b); |
111 } | 121 } |
112 #endif // defined(UNIT_TEST) | 122 #endif // defined(UNIT_TEST) |
113 | 123 |
114 } // namespace storage | 124 } // namespace storage |
115 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_ | 125 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_ |
OLD | NEW |