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

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

Issue 1513783005: [Blob] Fix for resetting reader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "storage/browser/blob/upload_blob_element_reader.h" 5 #include "storage/browser/blob/upload_blob_element_reader.h"
6 6
7 #include "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
8 #include "storage/browser/blob/blob_data_handle.h" 8 #include "storage/browser/blob/blob_data_handle.h"
9 #include "storage/browser/blob/blob_reader.h" 9 #include "storage/browser/blob/blob_reader.h"
10 #include "storage/browser/fileapi/file_system_context.h"
10 11
11 namespace storage { 12 namespace storage {
12 13
13 UploadBlobElementReader::UploadBlobElementReader( 14 UploadBlobElementReader::UploadBlobElementReader(
14 scoped_ptr<storage::BlobReader> reader, 15 scoped_ptr<BlobDataHandle> handle,
15 scoped_ptr<BlobDataHandle> handle) 16 FileSystemContext* file_system_context,
16 : reader_(reader.Pass()), handle_(handle.Pass()) {} 17 base::SingleThreadTaskRunner* file_task_runner)
18 : handle_(handle.Pass()),
19 file_system_context_(file_system_context),
20 file_runner_(file_task_runner) {
21 reader_ = handle_->CreateReader(file_system_context, file_task_runner);
22 }
17 23
18 UploadBlobElementReader::~UploadBlobElementReader() {} 24 UploadBlobElementReader::~UploadBlobElementReader() {}
19 25
20 int UploadBlobElementReader::Init(const net::CompletionCallback& callback) { 26 int UploadBlobElementReader::Init(const net::CompletionCallback& callback) {
27 if (reader_->dirty()) {
28 reader_ =
29 handle_->CreateReader(file_system_context_.get(), file_runner_.get());
michaeln 2015/12/11 02:17:01 i think this is a nice improvement! i think you c
30 }
21 BlobReader::Status status = reader_->CalculateSize(callback); 31 BlobReader::Status status = reader_->CalculateSize(callback);
22 switch (status) { 32 switch (status) {
23 case BlobReader::Status::NET_ERROR: 33 case BlobReader::Status::NET_ERROR:
24 return reader_->net_error(); 34 return reader_->net_error();
25 case BlobReader::Status::IO_PENDING: 35 case BlobReader::Status::IO_PENDING:
26 return net::ERR_IO_PENDING; 36 return net::ERR_IO_PENDING;
27 case BlobReader::Status::DONE: 37 case BlobReader::Status::DONE:
28 return net::OK; 38 return net::OK;
29 } 39 }
30 NOTREACHED(); 40 NOTREACHED();
(...skipping 27 matching lines...) Expand all
58 } 68 }
59 NOTREACHED(); 69 NOTREACHED();
60 return net::ERR_FAILED; 70 return net::ERR_FAILED;
61 } 71 }
62 72
63 const std::string& UploadBlobElementReader::uuid() const { 73 const std::string& UploadBlobElementReader::uuid() const {
64 return handle_->uuid(); 74 return handle_->uuid();
65 } 75 }
66 76
67 } // namespace storage 77 } // namespace storage
OLDNEW
« storage/browser/blob/blob_reader.h ('K') | « storage/browser/blob/upload_blob_element_reader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698