Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: net/base/upload_data_stream.cc

Issue 9316048: net: Explicitly close a file stream in UploadDataStream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698