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

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

Issue 1337153002: [Blob] BlobReader class & tests, and removal of all redundant reading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed prod/debug flakiness Created 5 years, 3 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 | « storage/browser/blob/upload_blob_element_reader.h ('k') | storage/storage_browser.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/browser/blob/upload_blob_element_reader.cc
diff --git a/storage/browser/blob/upload_blob_element_reader.cc b/storage/browser/blob/upload_blob_element_reader.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dd0058f3617e68b6330791469118980c03e71d0c
--- /dev/null
+++ b/storage/browser/blob/upload_blob_element_reader.cc
@@ -0,0 +1,67 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "storage/browser/blob/upload_blob_element_reader.h"
+
+#include "net/base/net_errors.h"
+#include "storage/browser/blob/blob_data_handle.h"
+#include "storage/browser/blob/blob_reader.h"
+
+namespace storage {
+
+UploadBlobElementReader::UploadBlobElementReader(
+ scoped_ptr<storage::BlobReader> reader,
+ scoped_ptr<BlobDataHandle> handle)
+ : reader_(reader.Pass()), handle_(handle.Pass()) {}
+
+UploadBlobElementReader::~UploadBlobElementReader() {}
+
+int UploadBlobElementReader::Init(const net::CompletionCallback& callback) {
+ BlobReader::Status status = reader_->CalculateSize(callback);
+ switch (status) {
+ case BlobReader::Status::NET_ERROR:
+ return reader_->net_error();
+ case BlobReader::Status::IO_PENDING:
+ return net::ERR_IO_PENDING;
+ case BlobReader::Status::DONE:
+ return net::OK;
+ }
+ NOTREACHED();
+ return net::ERR_FAILED;
+}
+
+uint64_t UploadBlobElementReader::GetContentLength() const {
+ return reader_->total_size();
+}
+
+uint64_t UploadBlobElementReader::BytesRemaining() const {
+ return reader_->remaining_bytes();
+}
+
+bool UploadBlobElementReader::IsInMemory() const {
+ return reader_->IsInMemory();
+}
+
+int UploadBlobElementReader::Read(net::IOBuffer* buf,
+ int buf_length,
+ const net::CompletionCallback& callback) {
+ int length = 0;
+ BlobReader::Status status = reader_->Read(buf, buf_length, &length, callback);
+ switch (status) {
+ case BlobReader::Status::NET_ERROR:
+ return reader_->net_error();
+ case BlobReader::Status::IO_PENDING:
+ return net::ERR_IO_PENDING;
+ case BlobReader::Status::DONE:
+ return length;
+ }
+ NOTREACHED();
+ return net::ERR_FAILED;
+}
+
+const std::string& UploadBlobElementReader::uuid() const {
+ return handle_->uuid();
+}
+
+} // namespace storage
« no previous file with comments | « storage/browser/blob/upload_blob_element_reader.h ('k') | storage/storage_browser.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698