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

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

Issue 647883002: git cl format the final third of the net/base directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 22 matching lines...) Expand all
33 ScopedVector<UploadElementReader> readers; 33 ScopedVector<UploadElementReader> readers;
34 readers.push_back(reader.release()); 34 readers.push_back(reader.release());
35 return scoped_ptr<UploadDataStream>( 35 return scoped_ptr<UploadDataStream>(
36 new ElementsUploadDataStream(readers.Pass(), identifier)); 36 new ElementsUploadDataStream(readers.Pass(), identifier));
37 } 37 }
38 38
39 int ElementsUploadDataStream::InitInternal() { 39 int ElementsUploadDataStream::InitInternal() {
40 return InitElements(0); 40 return InitElements(0);
41 } 41 }
42 42
43 int ElementsUploadDataStream::ReadInternal( 43 int ElementsUploadDataStream::ReadInternal(IOBuffer* buf, int buf_len) {
44 IOBuffer* buf,
45 int buf_len) {
46 DCHECK_GT(buf_len, 0); 44 DCHECK_GT(buf_len, 0);
47 return ReadElements(new DrainableIOBuffer(buf, buf_len)); 45 return ReadElements(new DrainableIOBuffer(buf, buf_len));
48 } 46 }
49 47
50 bool ElementsUploadDataStream::IsInMemory() const { 48 bool ElementsUploadDataStream::IsInMemory() const {
51 for (size_t i = 0; i < element_readers_.size(); ++i) { 49 for (size_t i = 0; i < element_readers_.size(); ++i) {
52 if (!element_readers_[i]->IsInMemory()) 50 if (!element_readers_[i]->IsInMemory())
53 return false; 51 return false;
54 } 52 }
55 return true; 53 return true;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 weak_ptr_factory_.GetWeakPtr(), 120 weak_ptr_factory_.GetWeakPtr(),
123 buf)); 121 buf));
124 if (result == ERR_IO_PENDING) 122 if (result == ERR_IO_PENDING)
125 return ERR_IO_PENDING; 123 return ERR_IO_PENDING;
126 ProcessReadResult(buf, result); 124 ProcessReadResult(buf, result);
127 } 125 }
128 126
129 if (read_failed_) { 127 if (read_failed_) {
130 // If an error occured during read operation, then pad with zero. 128 // If an error occured during read operation, then pad with zero.
131 // Otherwise the server will hang waiting for the rest of the data. 129 // Otherwise the server will hang waiting for the rest of the data.
132 int num_bytes_to_fill = std::min( 130 int num_bytes_to_fill =
133 static_cast<uint64>(buf->BytesRemaining()), 131 std::min(static_cast<uint64>(buf->BytesRemaining()),
134 size() - position() - buf->BytesConsumed()); 132 size() - position() - buf->BytesConsumed());
135 DCHECK_LE(0, num_bytes_to_fill); 133 DCHECK_LE(0, num_bytes_to_fill);
136 memset(buf->data(), 0, num_bytes_to_fill); 134 memset(buf->data(), 0, num_bytes_to_fill);
137 buf->DidConsume(num_bytes_to_fill); 135 buf->DidConsume(num_bytes_to_fill);
138 } 136 }
139 137
140 return buf->BytesConsumed(); 138 return buf->BytesConsumed();
141 } 139 }
142 140
143 void ElementsUploadDataStream::OnReadElementCompleted( 141 void ElementsUploadDataStream::OnReadElementCompleted(
144 const scoped_refptr<DrainableIOBuffer>& buf, 142 const scoped_refptr<DrainableIOBuffer>& buf,
(...skipping 12 matching lines...) Expand all
157 DCHECK(!read_failed_); 155 DCHECK(!read_failed_);
158 156
159 if (result >= 0) { 157 if (result >= 0) {
160 buf->DidConsume(result); 158 buf->DidConsume(result);
161 } else { 159 } else {
162 read_failed_ = true; 160 read_failed_ = true;
163 } 161 }
164 } 162 }
165 163
166 } // namespace net 164 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698