Chromium Code Reviews| 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 { |