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

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 Andrei'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
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_);
260 CHECK_NE(0, read_buffer_len_);
261 int rv = ReadData(read_buffer_.get(), read_buffer_len_); 266 int rv = ReadData(read_buffer_.get(), read_buffer_len_);
262 if (rv == ERR_IO_PENDING) { 267 if (rv == ERR_IO_PENDING) {
263 // Spurrious notification. Wait for the next one. 268 // Spurrious notification. Wait for the next one.
264 return; 269 return;
265 } 270 }
266 read_buffer_ = nullptr; 271 read_buffer_ = nullptr;
267 read_buffer_len_ = 0; 272 read_buffer_len_ = 0;
268 if (delegate_) 273 if (delegate_)
269 delegate_->OnDataRead(rv); 274 delegate_->OnDataRead(rv);
270 } 275 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 if (!stream_) 361 if (!stream_)
357 return; 362 return;
358 closed_stream_received_bytes_ = stream_->stream_bytes_read(); 363 closed_stream_received_bytes_ = stream_->stream_bytes_read();
359 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); 364 closed_stream_sent_bytes_ = stream_->stream_bytes_written();
360 closed_is_first_stream_ = stream_->IsFirstStream(); 365 closed_is_first_stream_ = stream_->IsFirstStream();
361 stream_->SetDelegate(nullptr); 366 stream_->SetDelegate(nullptr);
362 stream_ = nullptr; 367 stream_ = nullptr;
363 } 368 }
364 369
365 } // namespace net 370 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/chromium/bidirectional_stream_quic_impl_unittest.cc » ('j') | net/quic/core/quic_spdy_stream.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698