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 size_t GetMaxBufferSize() const { return kBufSize; } | |
willchan no longer on Chromium
2011/02/01 23:35:59
It's annoying we have to expose this. We should ju
Satish
2011/02/22 14:25:44
We don't write to a buffer provided by the caller,
willchan no longer on Chromium
2011/02/24 19:03:39
I was thinking that instead of an interface like M
| |
29 | 30 |
30 // Call to indicate that a portion of the stream's buffer was consumed. This | 31 // 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 | 32 // call modifies the stream's buffer so that it contains the next segment of |
32 // the upload data to be consumed. | 33 // the upload data to be consumed. |
33 void MarkConsumedAndFillBuffer(size_t num_bytes); | 34 void MarkConsumedAndFillBuffer(size_t num_bytes); |
34 | 35 |
35 // Sets the callback to be invoked when new chunks are available to upload. | 36 // Sets the callback to be invoked when new chunks are available to upload. |
36 void set_chunk_callback(ChunkCallback* callback) { | 37 void set_chunk_callback(ChunkCallback* callback) { |
37 data_->set_chunk_callback(callback); | 38 data_->set_chunk_callback(callback); |
38 } | 39 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 | 93 |
93 // Whether there is no data left to read. | 94 // Whether there is no data left to read. |
94 bool eof_; | 95 bool eof_; |
95 | 96 |
96 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); | 97 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); |
97 }; | 98 }; |
98 | 99 |
99 } // namespace net | 100 } // namespace net |
100 | 101 |
101 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ | 102 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ |
OLD | NEW |