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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 if (element_file_stream_.get()) { | 168 if (element_file_stream_.get()) { |
169 // Temporarily allow until fix: http://crbug.com/72001. | 169 // Temporarily allow until fix: http://crbug.com/72001. |
170 base::ThreadRestrictions::ScopedAllowIO allow_io; | 170 base::ThreadRestrictions::ScopedAllowIO allow_io; |
171 element_file_stream_->Close(); | 171 element_file_stream_->CloseSync(); |
172 element_file_stream_.reset(); | 172 element_file_stream_.reset(); |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 bool UploadDataStream::IsEOF() const { | 176 bool UploadDataStream::IsEOF() const { |
177 const std::vector<UploadData::Element>& elements = *upload_data_->elements(); | 177 const std::vector<UploadData::Element>& elements = *upload_data_->elements(); |
178 | 178 |
179 // Check if all elements are consumed and the buffer is empty. | 179 // Check if all elements are consumed and the buffer is empty. |
180 if (element_index_ == elements.size() && !buf_len_) { | 180 if (element_index_ == elements.size() && !buf_len_) { |
181 // 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 |
(...skipping 17 matching lines...) Expand all Loading... |
199 elements.back().is_last_chunk())); | 199 elements.back().is_last_chunk())); |
200 } | 200 } |
201 | 201 |
202 bool UploadDataStream::IsInMemory() const { | 202 bool UploadDataStream::IsInMemory() const { |
203 DCHECK(initialized_successfully_); | 203 DCHECK(initialized_successfully_); |
204 | 204 |
205 return upload_data_->IsInMemory(); | 205 return upload_data_->IsInMemory(); |
206 } | 206 } |
207 | 207 |
208 } // namespace net | 208 } // namespace net |
OLD | NEW |