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

Unified Diff: storage/common/data_element.h

Issue 821913004: [Storage] Consoliation of BlobItems with small size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge and length calc fix 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/webblobregistry_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/common/data_element.h
diff --git a/storage/common/data_element.h b/storage/common/data_element.h
index bdc881296acab626574d2981697c8a7f10cbeb2c..0efe1550a91e9a509d1cc0548854167a58c3a689 100644
--- a/storage/common/data_element.h
+++ b/storage/common/data_element.h
@@ -50,8 +50,28 @@ class STORAGE_COMMON_EXPORT DataElement {
length_ = buf_.size();
}
+ // Sets TYPE_BYTES data, and clears the internal bytes buffer.
+ // For use with AppendBytes.
+ void SetToEmptyBytes() {
+ type_ = TYPE_BYTES;
+ buf_.clear();
+ length_ = 0;
+ bytes_ = nullptr;
+ }
+
+ // Copies and appends the given data into the element. SetToEmptyBytes or
+ // SetToBytes must be called before this method.
+ void AppendBytes(const char* bytes, int bytes_len) {
+ DCHECK_EQ(type_, TYPE_BYTES);
+ DCHECK_NE(length_, kuint64max);
+ DCHECK(!bytes_);
+ buf_.insert(buf_.end(), bytes, bytes + bytes_len);
+ length_ = buf_.size();
+ }
+
// Sets TYPE_BYTES data. This does NOT copy the given data and the caller
// should make sure the data is alive when this element is accessed.
+ // You cannot use AppendBytes with this method.
void SetToSharedBytes(const char* bytes, int bytes_len) {
type_ = TYPE_BYTES;
bytes_ = bytes;
« no previous file with comments | « content/child/webblobregistry_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698