| OLD | NEW |
| 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 | 10 |
| 11 namespace storage { | 11 namespace storage { |
| 12 | 12 |
| 13 UploadBlobElementReader::UploadBlobElementReader( | 13 UploadBlobElementReader::UploadBlobElementReader( |
| 14 scoped_ptr<storage::BlobReader> reader, | 14 scoped_ptr<storage::BlobReader> reader, |
| 15 scoped_ptr<BlobDataHandle> handle) | 15 scoped_ptr<BlobDataHandle> handle) |
| 16 : reader_(reader.Pass()), handle_(handle.Pass()) {} | 16 : reader_(reader.Pass()), handle_(handle.Pass()) {} |
| 17 | 17 |
| 18 UploadBlobElementReader::~UploadBlobElementReader() {} | 18 UploadBlobElementReader::~UploadBlobElementReader() {} |
| 19 | 19 |
| 20 int UploadBlobElementReader::Init(const net::CompletionCallback& callback) { | 20 int UploadBlobElementReader::Init(const net::CompletionCallback& callback) { |
| 21 if (reader_->reader_used()) { |
| 22 reader_->Reset(); |
| 23 } |
| 21 BlobReader::Status status = reader_->CalculateSize(callback); | 24 BlobReader::Status status = reader_->CalculateSize(callback); |
| 22 switch (status) { | 25 switch (status) { |
| 23 case BlobReader::Status::NET_ERROR: | 26 case BlobReader::Status::NET_ERROR: |
| 24 return reader_->net_error(); | 27 return reader_->net_error(); |
| 25 case BlobReader::Status::IO_PENDING: | 28 case BlobReader::Status::IO_PENDING: |
| 26 return net::ERR_IO_PENDING; | 29 return net::ERR_IO_PENDING; |
| 27 case BlobReader::Status::DONE: | 30 case BlobReader::Status::DONE: |
| 28 return net::OK; | 31 return net::OK; |
| 29 } | 32 } |
| 30 NOTREACHED(); | 33 NOTREACHED(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 58 } | 61 } |
| 59 NOTREACHED(); | 62 NOTREACHED(); |
| 60 return net::ERR_FAILED; | 63 return net::ERR_FAILED; |
| 61 } | 64 } |
| 62 | 65 |
| 63 const std::string& UploadBlobElementReader::uuid() const { | 66 const std::string& UploadBlobElementReader::uuid() const { |
| 64 return handle_->uuid(); | 67 return handle_->uuid(); |
| 65 } | 68 } |
| 66 | 69 |
| 67 } // namespace storage | 70 } // namespace storage |
| OLD | NEW |