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

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

Issue 2007013003: Introduce error handling in HttpStreamParser on UploadDataStream::Read() failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added upload_data_stream.cc/h in order to be able to land the cl Created 4 years, 6 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
« no previous file with comments | « net/base/upload_data_stream.h ('k') | net/http/http_stream_parser.cc » ('j') | 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/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 if (result == OK) { 102 if (result == OK) {
103 initialized_successfully_ = true; 103 initialized_successfully_ = true;
104 if (!is_chunked_ && total_size_ == 0) 104 if (!is_chunked_ && total_size_ == 0)
105 is_eof_ = true; 105 is_eof_ = true;
106 } 106 }
107 if (!callback_.is_null()) 107 if (!callback_.is_null())
108 base::ResetAndReturn(&callback_).Run(result); 108 base::ResetAndReturn(&callback_).Run(result);
109 } 109 }
110 110
111 void UploadDataStream::OnReadCompleted(int result) { 111 void UploadDataStream::OnReadCompleted(int result) {
112 DCHECK_GE(result, 0);
113 DCHECK(initialized_successfully_); 112 DCHECK(initialized_successfully_);
113 DCHECK(result != 0 || is_eof_);
114 DCHECK_NE(ERR_IO_PENDING, result);
114 115
115 current_position_ += result; 116 if (result > 0) {
116 if (!is_chunked_) { 117 current_position_ += result;
117 DCHECK_LE(current_position_, total_size_); 118 if (!is_chunked_) {
118 if (current_position_ == total_size_) 119 DCHECK_LE(current_position_, total_size_);
119 is_eof_ = true; 120 if (current_position_ == total_size_)
121 is_eof_ = true;
122 }
120 } 123 }
121 124
122 DCHECK(result > 0 || is_eof_);
123
124 if (!callback_.is_null()) 125 if (!callback_.is_null())
125 base::ResetAndReturn(&callback_).Run(result); 126 base::ResetAndReturn(&callback_).Run(result);
126 } 127 }
127 128
128 } // namespace net 129 } // namespace net
OLDNEW
« no previous file with comments | « net/base/upload_data_stream.h ('k') | net/http/http_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698