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 #include "net/base/upload_data_stream.h" | 5 #include "net/base/upload_data_stream.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "net/base/file_stream.h" | 10 #include "net/base/file_stream.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 | 158 |
159 eof_ = IsEOF(); | 159 eof_ = IsEOF(); |
160 | 160 |
161 return OK; | 161 return OK; |
162 } | 162 } |
163 | 163 |
164 void UploadDataStream::AdvanceToNextElement() { | 164 void UploadDataStream::AdvanceToNextElement() { |
165 ++element_index_; | 165 ++element_index_; |
166 element_offset_ = 0; | 166 element_offset_ = 0; |
167 element_file_bytes_remaining_ = 0; | 167 element_file_bytes_remaining_ = 0; |
168 element_file_stream_.reset(); | 168 if (element_file_stream_.get()) { |
169 // Temporarily allow until fix: http://crbug.com/72001. | |
170 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
171 element_file_stream_.Close(); | |
eroman
2012/02/01 21:43:28
The call to Close() isn't strictly necessary right
satorux1
2012/02/01 21:46:09
you are right, but wanted to make it clear that fi
| |
172 element_file_stream_.reset(); | |
173 } | |
169 } | 174 } |
170 | 175 |
171 bool UploadDataStream::IsEOF() const { | 176 bool UploadDataStream::IsEOF() const { |
172 const std::vector<UploadData::Element>& elements = *upload_data_->elements(); | 177 const std::vector<UploadData::Element>& elements = *upload_data_->elements(); |
173 | 178 |
174 // Check if all elements are consumed and the buffer is empty. | 179 // Check if all elements are consumed and the buffer is empty. |
175 if (element_index_ == elements.size() && !buf_len_) { | 180 if (element_index_ == elements.size() && !buf_len_) { |
176 // If the upload data is chunked, check if the last element is the | 181 // If the upload data is chunked, check if the last element is the |
177 // last chunk. | 182 // last chunk. |
178 if (!upload_data_->is_chunked() || | 183 if (!upload_data_->is_chunked() || |
(...skipping 11 matching lines...) Expand all Loading... | |
190 (!elements.empty() && | 195 (!elements.empty() && |
191 element_index_ == elements.size() && | 196 element_index_ == elements.size() && |
192 elements.back().is_last_chunk())); | 197 elements.back().is_last_chunk())); |
193 } | 198 } |
194 | 199 |
195 bool UploadDataStream::IsInMemory() const { | 200 bool UploadDataStream::IsInMemory() const { |
196 return upload_data_->IsInMemory(); | 201 return upload_data_->IsInMemory(); |
197 } | 202 } |
198 | 203 |
199 } // namespace net | 204 } // namespace net |
OLD | NEW |