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

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

Issue 895933007: [Storage] Blob items are now shared between blobs. Ready for disk swap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: storage/browser/blob/blob_data_builder.cc
diff --git a/storage/browser/blob/blob_data_builder.cc b/storage/browser/blob/blob_data_builder.cc
index 120bc44bbe492f44289e13411c7832e041802841..c8d54c0d973bd36eaa7876078e88035392d297e2 100644
--- a/storage/browser/blob/blob_data_builder.cc
+++ b/storage/browser/blob/blob_data_builder.cc
@@ -2,35 +2,43 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <storage/browser/blob/blob_data_builder.h>
+#include "storage/browser/blob/blob_data_builder.h"
+
#include "base/time/time.h"
+#include "storage/browser/blob/blob_storage_context.h"
namespace storage {
+BlobDataBuilder* BlobDataBuilder::Create(const std::string& uuid) {
+ return new BlobDataBuilder(uuid);
+}
BlobDataBuilder::BlobDataBuilder(const std::string& uuid) : uuid_(uuid) {
}
BlobDataBuilder::~BlobDataBuilder() {
}
-void BlobDataBuilder::AppendData(const char* data, size_t length) {
+BlobDataBuilder* BlobDataBuilder::AppendData(const char* data, size_t length) {
DCHECK(length > 0);
scoped_ptr<DataElement> element(new DataElement());
element->SetToBytes(data, length);
items_.push_back(new BlobDataItem(element.Pass()));
+ return this;
}
-void BlobDataBuilder::AppendFile(const base::FilePath& file_path,
- uint64 offset,
- uint64 length,
- const base::Time& expected_modification_time) {
+BlobDataBuilder* BlobDataBuilder::AppendFile(
+ const base::FilePath& file_path,
+ uint64 offset,
+ uint64 length,
+ const base::Time& expected_modification_time) {
DCHECK(length > 0);
scoped_ptr<DataElement> element(new DataElement());
element->SetToFilePathRange(file_path, offset, length,
expected_modification_time);
items_.push_back(new BlobDataItem(element.Pass()));
+ return this;
}
-void BlobDataBuilder::AppendFile(
+BlobDataBuilder* BlobDataBuilder::AppendFile(
const base::FilePath& file_path,
uint64 offset,
uint64 length,
@@ -41,18 +49,27 @@ void BlobDataBuilder::AppendFile(
element->SetToFilePathRange(file_path, offset, length,
expected_modification_time);
items_.push_back(new BlobDataItem(element.Pass(), shareable_file));
+ return this;
}
-void BlobDataBuilder::AppendBlob(const std::string& uuid,
- uint64 offset,
- uint64 length) {
+BlobDataBuilder* BlobDataBuilder::AppendBlob(const std::string& uuid,
+ uint64 offset,
+ uint64 length) {
DCHECK_GT(length, 0ul);
scoped_ptr<DataElement> element(new DataElement());
element->SetToBlobRange(uuid, offset, length);
items_.push_back(new BlobDataItem(element.Pass()));
+ return this;
+}
+
+BlobDataBuilder* BlobDataBuilder::AppendBlob(const std::string& uuid) {
+ scoped_ptr<DataElement> element(new DataElement());
+ element->SetToBlob(uuid);
+ items_.push_back(new BlobDataItem(element.Pass()));
+ return this;
}
-void BlobDataBuilder::AppendFileSystemFile(
+BlobDataBuilder* BlobDataBuilder::AppendFileSystemFile(
const GURL& url,
uint64 offset,
uint64 length,
@@ -62,6 +79,21 @@ void BlobDataBuilder::AppendFileSystemFile(
element->SetToFileSystemUrlRange(url, offset, length,
expected_modification_time);
items_.push_back(new BlobDataItem(element.Pass()));
+ return this;
+}
+
+scoped_ptr<BlobDataBuilder> BlobDataBuilder::Clone() {
michaeln 2015/02/05 20:02:09 Is there a use case for Clone()?
dmurph 2015/02/06 01:32:30 Nope, removed. Left over from having the context
+ scoped_ptr<BlobDataBuilder> other(new BlobDataBuilder(this->uuid_));
+ other->content_type_ = this->content_type_;
+ other->content_disposition_ = this->content_disposition_;
+ other->items_.reserve(this->items_.size());
+ for (const auto& data_item : items_) {
+ scoped_ptr<DataElement> element(new DataElement());
+ *element = data_item->data_element();
+ other->items_.push_back(
+ new BlobDataItem(element.Pass(), data_item->file_handle_));
michaeln 2015/02/05 20:02:09 Why make a new item instead of letting the new bui
dmurph 2015/02/06 01:32:30 this was for a deep clone method, we don't need it
+ }
+ return other.Pass();
}
size_t BlobDataBuilder::GetMemoryUsage() const {

Powered by Google App Engine
This is Rietveld 408576698