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

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

Issue 12217165: net: Fix DCHECK failure on large file upload (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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_file_element_reader.h" 5 #include "net/base/upload_file_element_reader.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 if (!callback.is_null()) 215 if (!callback.is_null())
216 callback.Run(result); 216 callback.Run(result);
217 } 217 }
218 218
219 void UploadFileElementReader::OnReadCompleted( 219 void UploadFileElementReader::OnReadCompleted(
220 ScopedFileStreamPtr file_stream, 220 ScopedFileStreamPtr file_stream,
221 const CompletionCallback& callback, 221 const CompletionCallback& callback,
222 int result) { 222 int result) {
223 file_stream_.swap(file_stream); 223 file_stream_.swap(file_stream);
224 if (result > 0) { 224 if (result > 0) {
225 DCHECK_GE(static_cast<int>(bytes_remaining_), result); 225 DCHECK_GE(bytes_remaining_, static_cast<uint64>(result));
226 bytes_remaining_ -= result; 226 bytes_remaining_ -= result;
227 } 227 }
228 if (!callback.is_null()) 228 if (!callback.is_null())
229 callback.Run(result); 229 callback.Run(result);
230 } 230 }
231 231
232 UploadFileElementReader::ScopedOverridingContentLengthForTests:: 232 UploadFileElementReader::ScopedOverridingContentLengthForTests::
233 ScopedOverridingContentLengthForTests(uint64 value) { 233 ScopedOverridingContentLengthForTests(uint64 value) {
234 overriding_content_length = value; 234 overriding_content_length = value;
235 } 235 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 uint64 UploadFileElementReaderSync::BytesRemaining() const { 274 uint64 UploadFileElementReaderSync::BytesRemaining() const {
275 return bytes_remaining_; 275 return bytes_remaining_;
276 } 276 }
277 277
278 int UploadFileElementReaderSync::Read(IOBuffer* buf, 278 int UploadFileElementReaderSync::Read(IOBuffer* buf,
279 int buf_length, 279 int buf_length,
280 const CompletionCallback& callback) { 280 const CompletionCallback& callback) {
281 const int result = ReadInternal(buf, buf_length, BytesRemaining(), 281 const int result = ReadInternal(buf, buf_length, BytesRemaining(),
282 file_stream_.get()); 282 file_stream_.get());
283 if (result > 0) { 283 if (result > 0) {
284 DCHECK_GE(static_cast<int>(bytes_remaining_), result); 284 DCHECK_GE(bytes_remaining_, static_cast<uint64>(result));
285 bytes_remaining_ -= result; 285 bytes_remaining_ -= result;
286 } 286 }
287 return result; 287 return result;
288 } 288 }
289 289
290 } // namespace net 290 } // 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