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