| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 NET_BASE_UPLOAD_BYTES_ELEMENT_READER_H_ | 5 #ifndef NET_BASE_UPLOAD_BYTES_ELEMENT_READER_H_ |
| 6 #define NET_BASE_UPLOAD_BYTES_ELEMENT_READER_H_ | 6 #define NET_BASE_UPLOAD_BYTES_ELEMENT_READER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "net/base/upload_element_reader.h" | 13 #include "net/base/upload_element_reader.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 // An UploadElementReader implementation for bytes. | 17 // An UploadElementReader implementation for bytes. |
| 18 // |data| should outlive this class because this class does not take the | 18 // |data| should outlive this class because this class does not take the |
| 19 // ownership of the data. | 19 // ownership of the data. |
| 20 class NET_EXPORT UploadBytesElementReader : public UploadElementReader { | 20 class NET_EXPORT UploadBytesElementReader : public UploadElementReader { |
| 21 public: | 21 public: |
| 22 UploadBytesElementReader(const char* bytes, uint64 length); | 22 UploadBytesElementReader(const char* bytes, uint64 length); |
| 23 virtual ~UploadBytesElementReader(); | 23 virtual ~UploadBytesElementReader(); |
| 24 | 24 |
| 25 const char* bytes() const { return bytes_; } | 25 const char* bytes() const { return bytes_; } |
| 26 uint64 length() const { return length_; } | 26 uint64 length() const { return length_; } |
| 27 | 27 |
| 28 // UploadElementReader overrides: | 28 // UploadElementReader overrides: |
| 29 virtual const UploadBytesElementReader* AsBytesReader() const OVERRIDE; | 29 virtual const UploadBytesElementReader* AsBytesReader() const override; |
| 30 virtual int Init(const CompletionCallback& callback) OVERRIDE; | 30 virtual int Init(const CompletionCallback& callback) override; |
| 31 virtual uint64 GetContentLength() const OVERRIDE; | 31 virtual uint64 GetContentLength() const override; |
| 32 virtual uint64 BytesRemaining() const OVERRIDE; | 32 virtual uint64 BytesRemaining() const override; |
| 33 virtual bool IsInMemory() const OVERRIDE; | 33 virtual bool IsInMemory() const override; |
| 34 virtual int Read(IOBuffer* buf, | 34 virtual int Read(IOBuffer* buf, |
| 35 int buf_length, | 35 int buf_length, |
| 36 const CompletionCallback& callback) OVERRIDE; | 36 const CompletionCallback& callback) override; |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 const char* const bytes_; | 39 const char* const bytes_; |
| 40 const uint64 length_; | 40 const uint64 length_; |
| 41 uint64 offset_; | 41 uint64 offset_; |
| 42 | 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(UploadBytesElementReader); | 43 DISALLOW_COPY_AND_ASSIGN(UploadBytesElementReader); |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 // A subclass of UplodBytesElementReader which owns the data given as a vector. | 46 // A subclass of UplodBytesElementReader which owns the data given as a vector. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 std::vector<char> data_; | 59 std::vector<char> data_; |
| 60 | 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(UploadOwnedBytesElementReader); | 61 DISALLOW_COPY_AND_ASSIGN(UploadOwnedBytesElementReader); |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 } // namespace net | 64 } // namespace net |
| 65 | 65 |
| 66 #endif // NET_BASE_UPLOAD_BYTES_ELEMENT_READER_H_ | 66 #endif // NET_BASE_UPLOAD_BYTES_ELEMENT_READER_H_ |
| OLD | NEW |