Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_DATA_STREAM_H_ | 5 #ifndef NET_BASE_UPLOAD_DATA_STREAM_H_ |
| 6 #define NET_BASE_UPLOAD_DATA_STREAM_H_ | 6 #define NET_BASE_UPLOAD_DATA_STREAM_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "net/base/upload_data.h" | 10 #include "net/base/upload_data.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 class FileStream; | 14 class FileStream; |
| 15 class IOBuffer; | 15 class IOBuffer; |
| 16 | 16 |
| 17 class UploadDataStream { | 17 class UploadDataStream { |
| 18 public: | 18 public: |
| 19 ~UploadDataStream(); | 19 ~UploadDataStream(); |
| 20 | 20 |
| 21 // Returns a new instance of UploadDataStream if it can be created and | 21 // Returns a new instance of UploadDataStream if it can be created and |
| 22 // initialized successfully. If not, NULL will be returned and the error | 22 // initialized successfully. If not, NULL will be returned and the error |
| 23 // code will be set if the output parameter error_code is not empty. | 23 // code will be set if the output parameter error_code is not empty. |
| 24 static UploadDataStream* Create(UploadData* data, int* error_code); | 24 static UploadDataStream* Create(UploadData* data, int* error_code); |
| 25 | 25 |
| 26 // Returns the stream's buffer and buffer length. | 26 // Returns the stream's buffer and buffer length. |
| 27 IOBuffer* buf() const { return buf_; } | 27 IOBuffer* buf() const { return buf_; } |
| 28 size_t buf_len() const { return buf_len_; } | 28 size_t buf_len() const { return buf_len_; } |
| 29 | 29 |
| 30 // TODO: We should ideally have UploadDataStream expose a Read() method which | |
|
willchan no longer on Chromium
2011/03/02 18:44:40
Put a username on this TODO, either yours or mine.
Satish
2011/03/03 13:50:10
Done.
| |
| 31 // returns data in a caller provided IOBuffer. That would do away with this | |
| 32 // method and make the interface cleaner as well with less memmove calls. | |
| 33 size_t GetMaxBufferSize() const { return kBufSize; } | |
| 34 | |
| 30 // Call to indicate that a portion of the stream's buffer was consumed. This | 35 // Call to indicate that a portion of the stream's buffer was consumed. This |
| 31 // call modifies the stream's buffer so that it contains the next segment of | 36 // call modifies the stream's buffer so that it contains the next segment of |
| 32 // the upload data to be consumed. | 37 // the upload data to be consumed. |
| 33 void MarkConsumedAndFillBuffer(size_t num_bytes); | 38 void MarkConsumedAndFillBuffer(size_t num_bytes); |
| 34 | 39 |
| 35 // Sets the callback to be invoked when new chunks are available to upload. | 40 // Sets the callback to be invoked when new chunks are available to upload. |
| 36 void set_chunk_callback(ChunkCallback* callback) { | 41 void set_chunk_callback(ChunkCallback* callback) { |
| 37 data_->set_chunk_callback(callback); | 42 data_->set_chunk_callback(callback); |
| 38 } | 43 } |
| 39 | 44 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 | 97 |
| 93 // Whether there is no data left to read. | 98 // Whether there is no data left to read. |
| 94 bool eof_; | 99 bool eof_; |
| 95 | 100 |
| 96 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); | 101 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); |
| 97 }; | 102 }; |
| 98 | 103 |
| 99 } // namespace net | 104 } // namespace net |
| 100 | 105 |
| 101 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ | 106 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ |
| OLD | NEW |