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

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

Issue 1098853003: [BlobAsync] Patch 4: Browser Classes & Logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missed duplicate invalid test Created 5 years 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 | « storage/browser/blob/blob_data_builder.h ('k') | storage/browser/blob/blob_storage_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2ebfe89e454b094b5bab1b27ca80013021351831..69d9773bf7d00ce6e0c197c60c9f271e9b3de520 100644
--- a/storage/browser/blob/blob_data_builder.cc
+++ b/storage/browser/blob/blob_data_builder.cc
@@ -12,6 +12,9 @@
namespace storage {
+const char BlobDataBuilder::kAppendFutureFileTemporaryFileName[] =
+ "kFakeFilenameToBeChangedByPopulateFutureFile";
+
BlobDataBuilder::BlobDataBuilder(const std::string& uuid) : uuid_(uuid) {
}
BlobDataBuilder::~BlobDataBuilder() {
@@ -65,6 +68,7 @@ bool BlobDataBuilder::PopulateFutureData(size_t index,
const char* data,
size_t offset,
size_t length) {
+ DCHECK_LT(index, items_.size());
DCHECK(data);
DataElement* element = items_.at(index)->data_element_ptr();
@@ -93,6 +97,40 @@ bool BlobDataBuilder::PopulateFutureData(size_t index,
return true;
}
+size_t BlobDataBuilder::AppendFutureFile(uint64_t offset, uint64_t length) {
+ CHECK_NE(length, 0ull);
+ scoped_ptr<DataElement> element(new DataElement());
+ element->SetToFilePathRange(base::FilePath::FromUTF8Unsafe(std::string(
+ kAppendFutureFileTemporaryFileName)),
+ offset, length, base::Time());
+ items_.push_back(new BlobDataItem(element.Pass()));
+ return items_.size() - 1;
+}
+
+bool BlobDataBuilder::PopulateFutureFile(
+ size_t index,
+ const scoped_refptr<ShareableFileReference>& file_reference,
+ const base::Time& expected_modification_time) {
+ DCHECK_LT(index, items_.size());
+ DataElement* old_element = items_.at(index)->data_element_ptr();
+
+ if (old_element->type() != DataElement::TYPE_FILE) {
+ DVLOG(1) << "Invalid item type.";
+ return false;
+ } else if (old_element->path().AsUTF8Unsafe() !=
+ std::string(kAppendFutureFileTemporaryFileName)) {
+ DVLOG(1) << "Item not created by AppendFutureFile";
+ return false;
+ }
+ uint64_t length = old_element->length();
+ uint64_t offset = old_element->offset();
+ scoped_ptr<DataElement> element(new DataElement());
+ element->SetToFilePathRange(file_reference->path(), offset, length,
+ expected_modification_time);
+ items_[index] = new BlobDataItem(element.Pass(), file_reference);
+ return true;
+}
+
void BlobDataBuilder::AppendFile(const base::FilePath& file_path,
uint64_t offset,
uint64_t length,
« no previous file with comments | « storage/browser/blob/blob_data_builder.h ('k') | storage/browser/blob/blob_storage_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698