| 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_ELEMENT_READER_H_ | 5 #ifndef NET_BASE_UPLOAD_ELEMENT_READER_H_ |
| 6 #define NET_BASE_UPLOAD_ELEMENT_READER_H_ | 6 #define NET_BASE_UPLOAD_ELEMENT_READER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
| 10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 class IOBuffer; | 14 class IOBuffer; |
| 15 class UploadBytesElementReader; |
| 15 class UploadElement; | 16 class UploadElement; |
| 17 class UploadFileElementReader; |
| 16 | 18 |
| 17 // An interface to read an upload data element. | 19 // An interface to read an upload data element. |
| 18 class NET_EXPORT UploadElementReader { | 20 class NET_EXPORT UploadElementReader { |
| 19 public: | 21 public: |
| 20 UploadElementReader() {} | 22 UploadElementReader() {} |
| 21 virtual ~UploadElementReader() {} | 23 virtual ~UploadElementReader() {} |
| 22 | 24 |
| 23 // Creates an appropriate UploadElementReader instance for the given element. | 25 // Creates an appropriate UploadElementReader instance for the given element. |
| 24 static UploadElementReader* Create(const UploadElement& element); | 26 static UploadElementReader* Create(const UploadElement& element); |
| 25 | 27 |
| 28 // Returns this instance's pointer as UploadBytesElementReader when possible, |
| 29 // otherwise returns NULL. |
| 30 virtual const UploadBytesElementReader* AsBytesReader() const; |
| 31 |
| 32 // Returns this instance's pointer as UploadFileElementReader when possible, |
| 33 // otherwise returns NULL. |
| 34 virtual const UploadFileElementReader* AsFileReader() const; |
| 35 |
| 26 // Initializes the instance synchronously when possible, otherwise does | 36 // Initializes the instance synchronously when possible, otherwise does |
| 27 // initialization aynschronously, returns ERR_IO_PENDING and runs callback. | 37 // initialization aynschronously, returns ERR_IO_PENDING and runs callback. |
| 28 // Calling this method again after a Init() success results in resetting the | 38 // Calling this method again after a Init() success results in resetting the |
| 29 // state. | 39 // state. |
| 30 virtual int Init(const CompletionCallback& callback) = 0; | 40 virtual int Init(const CompletionCallback& callback) = 0; |
| 31 | 41 |
| 32 // Initializes the instance always synchronously. | 42 // Initializes the instance always synchronously. |
| 33 // Use this method only if the thread is IO allowed or the data is in-memory. | 43 // Use this method only if the thread is IO allowed or the data is in-memory. |
| 34 virtual int InitSync(); | 44 virtual int InitSync(); |
| 35 | 45 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 57 // Use this method only if the thread is IO allowed or the data is in-memory. | 67 // Use this method only if the thread is IO allowed or the data is in-memory. |
| 58 virtual int ReadSync(IOBuffer* buf, int buf_length); | 68 virtual int ReadSync(IOBuffer* buf, int buf_length); |
| 59 | 69 |
| 60 private: | 70 private: |
| 61 DISALLOW_COPY_AND_ASSIGN(UploadElementReader); | 71 DISALLOW_COPY_AND_ASSIGN(UploadElementReader); |
| 62 }; | 72 }; |
| 63 | 73 |
| 64 } // namespace net | 74 } // namespace net |
| 65 | 75 |
| 66 #endif // NET_BASE_UPLOAD_ELEMENT_READER_H_ | 76 #endif // NET_BASE_UPLOAD_ELEMENT_READER_H_ |
| OLD | NEW |