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_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 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 int ReadInternal(scoped_refptr<DrainableIOBuffer> buf, | 112 int ReadInternal(scoped_refptr<DrainableIOBuffer> buf, |
113 const CompletionCallback& callback); | 113 const CompletionCallback& callback); |
114 | 114 |
115 // Resumes pending read and calls callback with the result when necessary. | 115 // Resumes pending read and calls callback with the result when necessary. |
116 void ResumePendingRead(scoped_refptr<DrainableIOBuffer> buf, | 116 void ResumePendingRead(scoped_refptr<DrainableIOBuffer> buf, |
117 const CompletionCallback& callback, | 117 const CompletionCallback& callback, |
118 int previous_result); | 118 int previous_result); |
119 | 119 |
120 // Processes result of UploadElementReader::Read(). If |result| indicates | 120 // Processes result of UploadElementReader::Read(). If |result| indicates |
121 // success, updates |buf|'s offset. Otherwise, sets |read_failed_| to true. | 121 // success, updates |buf|'s offset. Otherwise, sets |read_failed_| to true. |
122 void ProcessReadResult(scoped_refptr<DrainableIOBuffer> buf, | 122 void ProcessReadResult(scoped_refptr<DrainableIOBuffer> buf, int result); |
123 int result); | |
124 | 123 |
125 ScopedVector<UploadElementReader> element_readers_; | 124 ScopedVector<UploadElementReader> element_readers_; |
126 | 125 |
127 // Index of the current upload element (i.e. the element currently being | 126 // Index of the current upload element (i.e. the element currently being |
128 // read). The index is used as a cursor to iterate over elements in | 127 // read). The index is used as a cursor to iterate over elements in |
129 // |upload_data_|. | 128 // |upload_data_|. |
130 size_t element_index_; | 129 size_t element_index_; |
131 | 130 |
132 // Size and current read position within the upload data stream. | 131 // Size and current read position within the upload data stream. |
133 // |total_size_| is set to zero when the data is chunked. | 132 // |total_size_| is set to zero when the data is chunked. |
(...skipping 15 matching lines...) Expand all Loading... |
149 base::Closure pending_chunked_read_callback_; | 148 base::Closure pending_chunked_read_callback_; |
150 | 149 |
151 base::WeakPtrFactory<UploadDataStream> weak_ptr_factory_; | 150 base::WeakPtrFactory<UploadDataStream> weak_ptr_factory_; |
152 | 151 |
153 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); | 152 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); |
154 }; | 153 }; |
155 | 154 |
156 } // namespace net | 155 } // namespace net |
157 | 156 |
158 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ | 157 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ |
OLD | NEW |