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

Side by Side Diff: storage/browser/blob/upload_blob_element_reader.cc

Issue 1376123002: Revert of [Blob] BlobReader class & tests, and removal of all redundant reading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "storage/browser/blob/upload_blob_element_reader.h"
6
7 #include "net/base/net_errors.h"
8 #include "storage/browser/blob/blob_data_handle.h"
9 #include "storage/browser/blob/blob_reader.h"
10
11 namespace storage {
12
13 UploadBlobElementReader::UploadBlobElementReader(
14 scoped_ptr<storage::BlobReader> reader,
15 scoped_ptr<BlobDataHandle> handle)
16 : reader_(reader.Pass()), handle_(handle.Pass()) {}
17
18 UploadBlobElementReader::~UploadBlobElementReader() {}
19
20 int UploadBlobElementReader::Init(const net::CompletionCallback& callback) {
21 BlobReader::Status status = reader_->CalculateSize(callback);
22 switch (status) {
23 case BlobReader::Status::NET_ERROR:
24 return reader_->net_error();
25 case BlobReader::Status::IO_PENDING:
26 return net::ERR_IO_PENDING;
27 case BlobReader::Status::DONE:
28 return net::OK;
29 }
30 NOTREACHED();
31 return net::ERR_FAILED;
32 }
33
34 uint64_t UploadBlobElementReader::GetContentLength() const {
35 return reader_->total_size();
36 }
37
38 uint64_t UploadBlobElementReader::BytesRemaining() const {
39 return reader_->remaining_bytes();
40 }
41
42 bool UploadBlobElementReader::IsInMemory() const {
43 return reader_->IsInMemory();
44 }
45
46 int UploadBlobElementReader::Read(net::IOBuffer* buf,
47 int buf_length,
48 const net::CompletionCallback& callback) {
49 int length = 0;
50 BlobReader::Status status = reader_->Read(buf, buf_length, &length, callback);
51 switch (status) {
52 case BlobReader::Status::NET_ERROR:
53 return reader_->net_error();
54 case BlobReader::Status::IO_PENDING:
55 return net::ERR_IO_PENDING;
56 case BlobReader::Status::DONE:
57 return length;
58 }
59 NOTREACHED();
60 return net::ERR_FAILED;
61 }
62
63 const std::string& UploadBlobElementReader::uuid() const {
64 return handle_->uuid();
65 }
66
67 } // namespace storage
OLDNEW
« 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