| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_CRONET_ANDROID_WRAPPED_CHANNEL_UPLOAD_ELEMENT_READER_H_ | 5 #ifndef COMPONENTS_CRONET_ANDROID_WRAPPED_CHANNEL_UPLOAD_ELEMENT_READER_H_ |
| 6 #define COMPONENTS_CRONET_ANDROID_WRAPPED_CHANNEL_UPLOAD_ELEMENT_READER_H_ | 6 #define COMPONENTS_CRONET_ANDROID_WRAPPED_CHANNEL_UPLOAD_ELEMENT_READER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "components/cronet/android/url_request_adapter.h" | 10 #include "components/cronet/android/url_request_adapter.h" |
| 11 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
| 12 #include "net/base/upload_element_reader.h" | 12 #include "net/base/upload_element_reader.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 class IOBuffer; | 15 class IOBuffer; |
| 16 } // namespace net | 16 } // namespace net |
| 17 | 17 |
| 18 namespace cronet { | 18 namespace cronet { |
| 19 | 19 |
| 20 // An UploadElementReader implementation for | 20 // An UploadElementReader implementation for |
| 21 // java.nio.channels.ReadableByteChannel. | 21 // java.nio.channels.ReadableByteChannel. |
| 22 // |channel_| should outlive this class because this class does not take the | 22 // |channel_| should outlive this class because this class does not take the |
| 23 // ownership of the data. | 23 // ownership of the data. |
| 24 class WrappedChannelElementReader : public net::UploadElementReader { | 24 class WrappedChannelElementReader : public net::UploadElementReader { |
| 25 public: | 25 public: |
| 26 WrappedChannelElementReader( | 26 WrappedChannelElementReader( |
| 27 scoped_refptr<URLRequestAdapter::URLRequestAdapterDelegate> delegate, | 27 scoped_refptr<URLRequestAdapter::URLRequestAdapterDelegate> delegate, |
| 28 uint64 length); | 28 uint64 length); |
| 29 virtual ~WrappedChannelElementReader(); | 29 ~WrappedChannelElementReader() override; |
| 30 | 30 |
| 31 // UploadElementReader overrides: | 31 // UploadElementReader overrides: |
| 32 virtual int Init(const net::CompletionCallback& callback) override; | 32 int Init(const net::CompletionCallback& callback) override; |
| 33 virtual uint64 GetContentLength() const override; | 33 uint64 GetContentLength() const override; |
| 34 virtual uint64 BytesRemaining() const override; | 34 uint64 BytesRemaining() const override; |
| 35 virtual bool IsInMemory() const override; | 35 bool IsInMemory() const override; |
| 36 virtual int Read(net::IOBuffer* buf, | 36 int Read(net::IOBuffer* buf, |
| 37 int buf_length, | 37 int buf_length, |
| 38 const net::CompletionCallback& callback) override; | 38 const net::CompletionCallback& callback) override; |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 const uint64 length_; | 41 const uint64 length_; |
| 42 uint64 offset_; | 42 uint64 offset_; |
| 43 scoped_refptr<URLRequestAdapter::URLRequestAdapterDelegate> delegate_; | 43 scoped_refptr<URLRequestAdapter::URLRequestAdapterDelegate> delegate_; |
| 44 | 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(WrappedChannelElementReader); | 45 DISALLOW_COPY_AND_ASSIGN(WrappedChannelElementReader); |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 } // namespace cronet | 48 } // namespace cronet |
| 49 | 49 |
| 50 #endif // COMPONENTS_CRONET_ANDROID_WRAPPED_CHANNEL_UPLOAD_ELEMENT_READER_H_ | 50 #endif // COMPONENTS_CRONET_ANDROID_WRAPPED_CHANNEL_UPLOAD_ELEMENT_READER_H_ |
| OLD | NEW |