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

Unified Diff: storage/browser/blob/blob_data_builder.h

Issue 1288373002: [BlobAsync] Patch 2: Common Constants (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async1
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: storage/browser/blob/blob_data_builder.h
diff --git a/storage/browser/blob/blob_data_builder.h b/storage/browser/blob/blob_data_builder.h
index 115d1f4391a8ad1b9ab44bb29f553345c2cfa04a..91a10252092e002fdf8943e8fe7866e7a30743d9 100644
--- a/storage/browser/blob/blob_data_builder.h
+++ b/storage/browser/blob/blob_data_builder.h
@@ -6,6 +6,7 @@
#define STORAGE_BROWSER_BLOB_BLOB_DATA_BUILDER_H_
#include <stdint.h>
+#include <ostream>
#include <string>
#include <vector>
@@ -32,12 +33,24 @@ class STORAGE_EXPORT BlobDataBuilder {
const std::string& uuid() const { return uuid_; }
+ // Validates the data element, and copies the data if it's a 'bytes' element.
+ // Cannot append elements of BYTES_DESCRIPTION or DISK_CACHE_ENTRY types.
+ void AppendDataElement(const DataElement& element);
+
void AppendData(const std::string& data) {
AppendData(data.c_str(), data.size());
}
void AppendData(const char* data, size_t length);
+ // ***** Async construction methods *****
+ void AppendFutureData(size_t length);
+ bool PopulateFutureData(size_t index,
+ const char* data,
+ size_t offset,
+ size_t length);
+ // **************************************
+
// You must know the length of the file, you cannot use kuint64max to specify
// the whole file. This method creates a ShareableFileReference to the given
// file, which is stored in this builder.
@@ -67,10 +80,14 @@ class STORAGE_EXPORT BlobDataBuilder {
content_disposition_ = content_disposition;
}
+ void Clear();
+
private:
friend class BlobStorageContext;
+ friend class BlobAsyncBuilderHostTest;
friend bool operator==(const BlobDataBuilder& a, const BlobDataBuilder& b);
friend bool operator==(const BlobDataSnapshot& a, const BlobDataBuilder& b);
+ friend std::ostream& operator<<(std::ostream& os, const BlobDataBuilder& x);
std::string uuid_;
std::string content_type_;
@@ -80,6 +97,9 @@ class STORAGE_EXPORT BlobDataBuilder {
DISALLOW_COPY_AND_ASSIGN(BlobDataBuilder);
};
+STORAGE_EXPORT std::ostream& operator<<(std::ostream& os,
+ const BlobDataBuilder& x);
+
#if defined(UNIT_TEST)
inline bool operator==(const BlobDataBuilder& a, const BlobDataBuilder& b) {
if (a.content_type_ != b.content_type_)
@@ -89,7 +109,7 @@ inline bool operator==(const BlobDataBuilder& a, const BlobDataBuilder& b) {
if (a.items_.size() != b.items_.size())
return false;
for (size_t i = 0; i < a.items_.size(); ++i) {
- if (a.items_[i] != b.items_[i])
+ if (*(a.items_[i]) != *(b.items_[i]))
return false;
}
return true;
@@ -119,6 +139,7 @@ inline bool operator!=(const BlobDataSnapshot& a, const BlobDataBuilder& b) {
inline bool operator!=(const BlobDataBuilder& a, const BlobDataBuilder& b) {
return !(a == b);
}
+
#endif // defined(UNIT_TEST)
} // namespace storage

Powered by Google App Engine
This is Rietveld 408576698