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/elements_upload_data_stream.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/dns_util.cc ('k') | net/base/file_stream_context.h » ('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/elements_upload_data_stream.h" 5 #include "net/base/elements_upload_data_stream.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "net/base/completion_callback.h" 9 #include "net/base/completion_callback.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 weak_ptr_factory_.GetWeakPtr(), 122 weak_ptr_factory_.GetWeakPtr(),
123 buf)); 123 buf));
124 if (result == ERR_IO_PENDING) 124 if (result == ERR_IO_PENDING)
125 return ERR_IO_PENDING; 125 return ERR_IO_PENDING;
126 ProcessReadResult(buf, result); 126 ProcessReadResult(buf, result);
127 } 127 }
128 128
129 if (read_failed_) { 129 if (read_failed_) {
130 // If an error occured during read operation, then pad with zero. 130 // If an error occured during read operation, then pad with zero.
131 // Otherwise the server will hang waiting for the rest of the data. 131 // Otherwise the server will hang waiting for the rest of the data.
132 int num_bytes_to_fill = std::min( 132 int num_bytes_to_fill = static_cast<int>(std::min(
133 static_cast<uint64>(buf->BytesRemaining()), 133 static_cast<uint64>(buf->BytesRemaining()),
134 size() - position() - buf->BytesConsumed()); 134 size() - position() - buf->BytesConsumed()));
135 DCHECK_LE(0, num_bytes_to_fill); 135 DCHECK_GE(num_bytes_to_fill, 0);
136 memset(buf->data(), 0, num_bytes_to_fill); 136 memset(buf->data(), 0, num_bytes_to_fill);
137 buf->DidConsume(num_bytes_to_fill); 137 buf->DidConsume(num_bytes_to_fill);
138 } 138 }
139 139
140 return buf->BytesConsumed(); 140 return buf->BytesConsumed();
141 } 141 }
142 142
143 void ElementsUploadDataStream::OnReadElementCompleted( 143 void ElementsUploadDataStream::OnReadElementCompleted(
144 const scoped_refptr<DrainableIOBuffer>& buf, 144 const scoped_refptr<DrainableIOBuffer>& buf,
145 int result) { 145 int result) {
(...skipping 11 matching lines...) Expand all
157 DCHECK(!read_failed_); 157 DCHECK(!read_failed_);
158 158
159 if (result >= 0) { 159 if (result >= 0) {
160 buf->DidConsume(result); 160 buf->DidConsume(result);
161 } else { 161 } else {
162 read_failed_ = true; 162 read_failed_ = true;
163 } 163 }
164 } 164 }
165 165
166 } // namespace net 166 } // namespace net
OLDNEW
« no previous file with comments | « net/base/dns_util.cc ('k') | net/base/file_stream_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698