Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: storage/browser/blob/blob_data_builder.h

Issue 810403004: [Storage] Blob Storage Refactoring pt 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: BUILD.gn file changes Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // TODO: Insert description here. (generated by dmurph)
2
3 #ifndef STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_
4 #define STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_
5
6 #include <string>
7 #include <vector>
8
9 #include "base/basictypes.h"
10 #include "base/files/file_path.h"
11 #include "storage/browser/blob/blob_data_item.h"
12 #include "storage/browser/blob/blob_data_snapshot.h"
13 #include "storage/browser/storage_browser_export.h"
14
15 namespace storage {
16 class BlobStorageContext;
17
18 class STORAGE_EXPORT BlobDataBuilder {
19 public:
20 explicit BlobDataBuilder(const std::string& uuid);
21 virtual ~BlobDataBuilder();
22
23 const std::string& uuid() const { return uuid_; }
24
25 void AppendData(const std::string& data) {
26 AppendData(data.c_str(), data.size());
27 }
28
29 void AppendData(const char* data, size_t length);
30
31 void AppendFile(const base::FilePath& file_path,
32 uint64 offset,
33 uint64 length,
34 const base::Time& expected_modification_time);
35
36 void AppendFile(const base::FilePath& file_path,
37 uint64 offset,
38 uint64 length,
39 const base::Time& expected_modification_time,
40 scoped_refptr<ShareableFileReference> shareable_file);
41
42 void AppendBlob(const std::string& uuid, uint64 offset, uint64 length);
43 void AppendFileSystemFile(const GURL& url,
44 uint64 offset,
45 uint64 length,
46 const base::Time& expected_modification_time);
47
48 void set_content_type(const std::string& content_type) {
49 content_type_ = content_type;
50 }
51
52 void set_content_disposition(const std::string& content_disposition) {
53 content_disposition_ = content_disposition;
54 }
55
56 size_t GetMemoryUsage() const;
57
58 scoped_ptr<BlobDataSnapshot> BuildSnapshot();
59
60 private:
61 friend class BlobStorageContext;
62 friend bool operator==(const BlobDataBuilder& a, const BlobDataBuilder& b);
63 friend bool operator==(const BlobDataSnapshot& a, const BlobDataBuilder& b);
64
65 std::string uuid_;
66 std::string content_type_;
67 std::string content_disposition_;
68 std::vector<scoped_refptr<BlobDataItem>> items_;
69
70 DISALLOW_COPY_AND_ASSIGN(BlobDataBuilder);
71 };
72
73 #if defined(UNIT_TEST)
74 inline bool operator==(const BlobDataBuilder& a, const BlobDataBuilder& b) {
75 if (a.content_type_ != b.content_type_)
76 return false;
77 if (a.content_disposition_ != b.content_disposition_)
78 return false;
79 if (a.items_.size() != b.items_.size())
80 return false;
81 for (size_t i = 0; i < a.items_.size(); ++i) {
82 if (a.items_[i] != b.items_[i])
83 return false;
84 }
85 return true;
86 }
87
88 inline bool operator==(const BlobDataSnapshot& a, const BlobDataBuilder& b) {
89 if (a.content_type() != b.content_type_) {
90 return false;
91 }
92 if (a.content_disposition() != b.content_disposition_) {
93 return false;
94 }
95 if (a.items().size() != b.items_.size()) {
96 return false;
97 }
98 for (size_t i = 0; i < a.items().size(); ++i) {
99 if (*(a.items()[i]) != *(b.items_[i])) {
100 return false;
101 }
102 }
103 return true;
104 }
105
106 inline bool operator!=(const BlobDataSnapshot& a, const BlobDataBuilder& b) {
107 return !(a == b);
108 }
109
110 inline bool operator!=(const BlobDataBuilder& a, const BlobDataBuilder& b) {
111 return !(a == b);
112 }
113 #endif // defined(UNIT_TEST)
114
115 } // namespace storage
116 #endif // STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698