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

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: moved definition to cc file Created 5 years, 2 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..17fb12144bbbe82e3360cc7297ce267204d25869 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,36 @@ class STORAGE_EXPORT BlobDataBuilder {
const std::string& uuid() const { return uuid_; }
+ // Validates the data element that was sent over IPC, and copies the data if
+ // it's a 'bytes' element. Data elements of BYTES_DESCRIPTION or
+ // DISK_CACHE_ENTRY types are not valid IPC data element types, and cannot be
+ // given to this method.
+ void AppendIPCDataElement(const DataElement& element);
michaeln 2015/10/20 20:50:02 nit: use same param name in .h and .cc
dmurph 2015/10/20 22:49:35 Done.
+
+ // Copies the given data into the blob.
void AppendData(const std::string& data) {
AppendData(data.c_str(), data.size());
}
+ // Copies the given data into the blob.
void AppendData(const char* data, size_t length);
+ // Adds an item that is flagged for future data population. The memory is not
+ // allocated until the first call to PopulateFutureData.
+ void AppendFutureData(size_t length);
+
+ // Populates a part of an item previously allocated with AppendFutureData.
+ // The first call to PopulateFutureData lazily allocates the memory for the
+ // data element.
+ // Returns true if:
+ // * The item was created by using AppendFutureData,
+ // * The offset and length are valid, and
+ // * data is a valid pointer.
+ 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 +92,15 @@ 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 STORAGE_EXPORT void PrintTo(const BlobDataBuilder& x,
+ ::std::ostream* os);
std::string uuid_;
std::string content_type_;
@@ -89,7 +119,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 +149,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