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

Side by Side Diff: net/quic/chromium/bidirectional_stream_quic_impl.cc

Issue 2393233002: Remove OnDataAvailable() notification when trailers are to be delivered (Closed)
Patch Set: Address Misha's comments Created 4 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
« no previous file with comments | « no previous file | net/quic/chromium/bidirectional_stream_quic_impl_unittest.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/chromium/bidirectional_stream_quic_impl.h" 5 #include "net/quic/chromium/bidirectional_stream_quic_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 has_received_headers_ = true; 239 has_received_headers_ = true;
240 connect_timing_ = session_->GetConnectTiming(); 240 connect_timing_ = session_->GetConnectTiming();
241 if (delegate_) 241 if (delegate_)
242 delegate_->OnHeadersReceived(headers); 242 delegate_->OnHeadersReceived(headers);
243 } else { 243 } else {
244 if (stream_->IsDoneReading()) { 244 if (stream_->IsDoneReading()) {
245 // If the write side is closed, OnFinRead() will call 245 // If the write side is closed, OnFinRead() will call
246 // BidirectionalStreamQuicImpl::OnClose(). 246 // BidirectionalStreamQuicImpl::OnClose().
247 stream_->OnFinRead(); 247 stream_->OnFinRead();
248 } 248 }
249 if (delegate_) 249 if (!delegate_)
250 delegate_->OnTrailersReceived(headers); 250 return;
251 // Complete any remaining read. The task is posted because
252 // |delegate_|->OnTrailersReceived() might destroy |this|.
253 base::ThreadTaskRunnerHandle::Get()->PostTask(
254 FROM_HERE, base::Bind(&BidirectionalStreamQuicImpl::OnDataAvailable,
255 weak_factory_.GetWeakPtr()));
256 delegate_->OnTrailersReceived(headers);
257 // |this| can be destroyed after this point.
251 } 258 }
252 } 259 }
253 260
254 void BidirectionalStreamQuicImpl::OnDataAvailable() { 261 void BidirectionalStreamQuicImpl::OnDataAvailable() {
255 // Return early if ReadData has not been called. 262 // Return early if ReadData has not been called.
256 if (!read_buffer_) 263 if (!read_buffer_)
257 return; 264 return;
258 265
259 CHECK(read_buffer_); 266 DCHECK(read_buffer_);
kapishnikov 2016/10/05 21:05:08 Can we remove this DCHECK? The previous 'if' state
xunjieli 2016/10/05 21:56:28 Done. Ah, you are right. Not sure why I added thos
260 CHECK_NE(0, read_buffer_len_); 267 DCHECK_NE(0, read_buffer_len_);
261 int rv = ReadData(read_buffer_.get(), read_buffer_len_); 268 int rv = ReadData(read_buffer_.get(), read_buffer_len_);
262 if (rv == ERR_IO_PENDING) { 269 if (rv == ERR_IO_PENDING) {
263 // Spurrious notification. Wait for the next one. 270 // Spurrious notification. Wait for the next one.
264 return; 271 return;
265 } 272 }
266 read_buffer_ = nullptr; 273 read_buffer_ = nullptr;
267 read_buffer_len_ = 0; 274 read_buffer_len_ = 0;
268 if (delegate_) 275 if (delegate_)
269 delegate_->OnDataRead(rv); 276 delegate_->OnDataRead(rv);
270 } 277 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 if (!stream_) 363 if (!stream_)
357 return; 364 return;
358 closed_stream_received_bytes_ = stream_->stream_bytes_read(); 365 closed_stream_received_bytes_ = stream_->stream_bytes_read();
359 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); 366 closed_stream_sent_bytes_ = stream_->stream_bytes_written();
360 closed_is_first_stream_ = stream_->IsFirstStream(); 367 closed_is_first_stream_ = stream_->IsFirstStream();
361 stream_->SetDelegate(nullptr); 368 stream_->SetDelegate(nullptr);
362 stream_ = nullptr; 369 stream_ = nullptr;
363 } 370 }
364 371
365 } // namespace net 372 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/chromium/bidirectional_stream_quic_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698