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 NET_BASE_UPLOAD_DISK_CACHE_ENTRY_ELEMENT_READER_H_ |
| 6 #define NET_BASE_UPLOAD_DISK_CACHE_ENTRY_ELEMENT_READER_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "net/base/upload_element_reader.h" |
| 12 |
| 13 namespace disk_cache { |
| 14 class Entry; |
| 15 } |
| 16 |
| 17 namespace net { |
| 18 |
| 19 // An UploadElementReader implementation for disk_cache::Entry objects. |
| 20 // |entry| should outlive this class because this class does not take the |
| 21 // ownership of the data. |
| 22 class NET_EXPORT UploadDiskCacheEntryElementReader |
| 23 : public UploadElementReader { |
| 24 public: |
| 25 UploadDiskCacheEntryElementReader(disk_cache::Entry* disk_cache_entry, |
| 26 int disk_cache_stream_index, |
| 27 int range_offset, |
| 28 int range_length); |
| 29 ~UploadDiskCacheEntryElementReader() override; |
| 30 |
| 31 int range_offset() const { return range_offset_; } |
| 32 int range_length() const { return range_length_; } |
| 33 |
| 34 // UploadElementReader overrides: |
| 35 const UploadDiskCacheEntryElementReader* AsDiskCacheEntryReader() |
| 36 const override; |
| 37 int Init(const CompletionCallback& callback) override; |
| 38 uint64_t GetContentLength() const override; |
| 39 uint64_t BytesRemaining() const override; |
| 40 bool IsInMemory() const override; |
| 41 int Read(IOBuffer* buf, |
| 42 int buf_length, |
| 43 const CompletionCallback& callback) override; |
| 44 |
| 45 private: |
| 46 void OnReadCompleted(const CompletionCallback& callback, int result); |
| 47 |
| 48 disk_cache::Entry* const disk_cache_entry_; |
| 49 const int disk_cache_stream_index_; |
| 50 |
| 51 const int range_offset_; |
| 52 const int range_length_; |
| 53 |
| 54 int offset_; |
| 55 |
| 56 base::WeakPtrFactory<UploadDiskCacheEntryElementReader> weak_factory_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(UploadDiskCacheEntryElementReader); |
| 59 }; |
| 60 |
| 61 } // namespace net |
| 62 |
| 63 #endif // NET_BASE_UPLOAD_DISK_CACHE_ENTRY_ELEMENT_READER_H_ |
OLD | NEW |