OLD | NEW |
(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 #ifndef STORAGE_BROWSER_BLOB_UPLOAD_BLOB_ELEMENT_READER_H_ |
| 6 #define STORAGE_BROWSER_BLOB_UPLOAD_BLOB_ELEMENT_READER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "net/base/completion_callback.h" |
| 11 #include "net/base/upload_element_reader.h" |
| 12 #include "storage/browser/storage_browser_export.h" |
| 13 |
| 14 namespace net { |
| 15 class IOBuffer; |
| 16 } |
| 17 |
| 18 namespace storage { |
| 19 class BlobDataHandle; |
| 20 class BlobReader; |
| 21 |
| 22 // This class is a wrapper around the BlobReader to make it conform |
| 23 // to the net::UploadElementReader interface, and it also holds around the |
| 24 // handle to the blob so it stays in memory while we read it. |
| 25 class STORAGE_EXPORT UploadBlobElementReader |
| 26 : NON_EXPORTED_BASE(public net::UploadElementReader) { |
| 27 public: |
| 28 UploadBlobElementReader(scoped_ptr<BlobReader> reader, |
| 29 scoped_ptr<BlobDataHandle> handle); |
| 30 ~UploadBlobElementReader() override; |
| 31 |
| 32 int Init(const net::CompletionCallback& callback) override; |
| 33 |
| 34 uint64_t GetContentLength() const override; |
| 35 |
| 36 uint64_t BytesRemaining() const override; |
| 37 |
| 38 bool IsInMemory() const override; |
| 39 |
| 40 int Read(net::IOBuffer* buf, |
| 41 int buf_length, |
| 42 const net::CompletionCallback& callback) override; |
| 43 |
| 44 const std::string& uuid() const; |
| 45 |
| 46 private: |
| 47 scoped_ptr<BlobReader> reader_; |
| 48 scoped_ptr<BlobDataHandle> handle_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(UploadBlobElementReader); |
| 51 }; |
| 52 |
| 53 } // namespace storage |
| 54 #endif // STORAGE_BROWSER_BLOB_UPLOAD_BLOB_ELEMENT_READER_H_ |
OLD | NEW |