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

Side by Side Diff: net/quic/quic_chromium_client_stream.cc

Issue 1856073002: Coalesce small buffers in net::BidirectionalStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Javadoc Created 4 years, 8 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/quic/quic_chromium_client_stream.h" 5 #include "net/quic/quic_chromium_client_stream.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 DCHECK(!HasBufferedData()); 131 DCHECK(!HasBufferedData());
132 // Writes the data, or buffers it. 132 // Writes the data, or buffers it.
133 WriteOrBufferData(data, fin, nullptr); 133 WriteOrBufferData(data, fin, nullptr);
134 if (!HasBufferedData()) { 134 if (!HasBufferedData()) {
135 return OK; 135 return OK;
136 } 136 }
137 137
138 callback_ = callback; 138 callback_ = callback;
139 return ERR_IO_PENDING; 139 return ERR_IO_PENDING;
140 } 140 }
141 int QuicChromiumClientStream::WritevStreamData(
142 const std::vector<base::StringPiece>& data,
143 bool fin,
144 const CompletionCallback& callback) {
145 // We should not have data buffered.
146 DCHECK(!HasBufferedData());
147 // Writes the data, or buffers it.
148 for (size_t i = 0; i < data.size(); ++i) {
149 bool is_fin = fin && (i == data.size() - 1);
150 WriteOrBufferData(data[i], is_fin, nullptr);
151 }
152 if (!HasBufferedData()) {
153 return OK;
154 }
155
156 callback_ = callback;
157 return ERR_IO_PENDING;
158 }
141 159
142 void QuicChromiumClientStream::SetDelegate( 160 void QuicChromiumClientStream::SetDelegate(
143 QuicChromiumClientStream::Delegate* delegate) { 161 QuicChromiumClientStream::Delegate* delegate) {
144 DCHECK(!(delegate_ && delegate)); 162 DCHECK(!(delegate_ && delegate));
145 delegate_ = delegate; 163 delegate_ = delegate;
146 while (!delegate_tasks_.empty()) { 164 while (!delegate_tasks_.empty()) {
147 base::Closure closure = delegate_tasks_.front(); 165 base::Closure closure = delegate_tasks_.front();
148 delegate_tasks_.pop_front(); 166 delegate_tasks_.pop_front();
149 closure.Run(); 167 closure.Run();
150 } 168 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 } else { 249 } else {
232 delegate_tasks_.push_back(closure); 250 delegate_tasks_.push_back(closure);
233 } 251 }
234 } 252 }
235 253
236 void QuicChromiumClientStream::DisableConnectionMigration() { 254 void QuicChromiumClientStream::DisableConnectionMigration() {
237 can_migrate_ = false; 255 can_migrate_ = false;
238 } 256 }
239 257
240 } // namespace net 258 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698