| 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 "base/single_thread_task_runner.h" |
| 7 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 8 #include "storage/browser/blob/blob_data_handle.h" | 9 #include "storage/browser/blob/blob_data_handle.h" |
| 9 #include "storage/browser/blob/blob_reader.h" | 10 #include "storage/browser/blob/blob_reader.h" |
| 11 #include "storage/browser/fileapi/file_system_context.h" |
| 10 | 12 |
| 11 namespace storage { | 13 namespace storage { |
| 12 | 14 |
| 13 UploadBlobElementReader::UploadBlobElementReader( | 15 UploadBlobElementReader::UploadBlobElementReader( |
| 14 scoped_ptr<storage::BlobReader> reader, | 16 scoped_ptr<BlobDataHandle> handle, |
| 15 scoped_ptr<BlobDataHandle> handle) | 17 FileSystemContext* file_system_context, |
| 16 : reader_(reader.Pass()), handle_(handle.Pass()) {} | 18 base::SingleThreadTaskRunner* file_task_runner) |
| 19 : handle_(handle.Pass()), |
| 20 file_system_context_(file_system_context), |
| 21 file_runner_(file_task_runner) {} |
| 17 | 22 |
| 18 UploadBlobElementReader::~UploadBlobElementReader() {} | 23 UploadBlobElementReader::~UploadBlobElementReader() {} |
| 19 | 24 |
| 20 int UploadBlobElementReader::Init(const net::CompletionCallback& callback) { | 25 int UploadBlobElementReader::Init(const net::CompletionCallback& callback) { |
| 26 reader_ = |
| 27 handle_->CreateReader(file_system_context_.get(), file_runner_.get()); |
| 21 BlobReader::Status status = reader_->CalculateSize(callback); | 28 BlobReader::Status status = reader_->CalculateSize(callback); |
| 22 switch (status) { | 29 switch (status) { |
| 23 case BlobReader::Status::NET_ERROR: | 30 case BlobReader::Status::NET_ERROR: |
| 24 return reader_->net_error(); | 31 return reader_->net_error(); |
| 25 case BlobReader::Status::IO_PENDING: | 32 case BlobReader::Status::IO_PENDING: |
| 26 return net::ERR_IO_PENDING; | 33 return net::ERR_IO_PENDING; |
| 27 case BlobReader::Status::DONE: | 34 case BlobReader::Status::DONE: |
| 28 return net::OK; | 35 return net::OK; |
| 29 } | 36 } |
| 30 NOTREACHED(); | 37 NOTREACHED(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 58 } | 65 } |
| 59 NOTREACHED(); | 66 NOTREACHED(); |
| 60 return net::ERR_FAILED; | 67 return net::ERR_FAILED; |
| 61 } | 68 } |
| 62 | 69 |
| 63 const std::string& UploadBlobElementReader::uuid() const { | 70 const std::string& UploadBlobElementReader::uuid() const { |
| 64 return handle_->uuid(); | 71 return handle_->uuid(); |
| 65 } | 72 } |
| 66 | 73 |
| 67 } // namespace storage | 74 } // namespace storage |
| OLD | NEW |