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

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

Issue 2140673006: Add CHECK to make sure QuicHttpStream does not get destroyed during DoLoop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « net/quic/quic_http_stream.h ('k') | no next file » | 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/quic/quic_http_stream.h" 5 #include "net/quic/quic_http_stream.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/auto_reset.h"
9 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
10 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
11 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
12 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
13 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.h"
14 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
15 #include "net/http/http_response_headers.h" 16 #include "net/http/http_response_headers.h"
16 #include "net/http/http_util.h" 17 #include "net/http/http_util.h"
17 #include "net/quic/quic_client_promised_info.h" 18 #include "net/quic/quic_client_promised_info.h"
18 #include "net/quic/quic_http_utils.h" 19 #include "net/quic/quic_http_utils.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 response_headers_received_(false), 56 response_headers_received_(false),
56 headers_bytes_received_(0), 57 headers_bytes_received_(0),
57 headers_bytes_sent_(0), 58 headers_bytes_sent_(0),
58 closed_stream_received_bytes_(0), 59 closed_stream_received_bytes_(0),
59 closed_stream_sent_bytes_(0), 60 closed_stream_sent_bytes_(0),
60 user_buffer_len_(0), 61 user_buffer_len_(0),
61 quic_connection_error_(QUIC_NO_ERROR), 62 quic_connection_error_(QUIC_NO_ERROR),
62 port_migration_detected_(false), 63 port_migration_detected_(false),
63 found_promise_(false), 64 found_promise_(false),
64 push_handle_(nullptr), 65 push_handle_(nullptr),
66 in_loop_(false),
65 weak_factory_(this) { 67 weak_factory_(this) {
66 DCHECK(session_); 68 DCHECK(session_);
67 session_->AddObserver(this); 69 session_->AddObserver(this);
68 } 70 }
69 71
70 QuicHttpStream::~QuicHttpStream() { 72 QuicHttpStream::~QuicHttpStream() {
73 CHECK(!in_loop_);
71 Close(false); 74 Close(false);
72 if (session_) 75 if (session_)
73 session_->RemoveObserver(this); 76 session_->RemoveObserver(this);
74 } 77 }
75 78
76 bool QuicHttpStream::CheckVary(const SpdyHeaderBlock& client_request, 79 bool QuicHttpStream::CheckVary(const SpdyHeaderBlock& client_request,
77 const SpdyHeaderBlock& promise_request, 80 const SpdyHeaderBlock& promise_request,
78 const SpdyHeaderBlock& promise_response) { 81 const SpdyHeaderBlock& promise_response) {
79 HttpResponseInfo promise_response_info; 82 HttpResponseInfo promise_response_info;
80 83
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 rv = DoLoop(rv); 551 rv = DoLoop(rv);
549 552
550 if (rv != ERR_IO_PENDING && !callback_.is_null()) { 553 if (rv != ERR_IO_PENDING && !callback_.is_null()) {
551 DoCallback(rv); 554 DoCallback(rv);
552 } 555 }
553 } 556 }
554 557
555 void QuicHttpStream::DoCallback(int rv) { 558 void QuicHttpStream::DoCallback(int rv) {
556 CHECK_NE(rv, ERR_IO_PENDING); 559 CHECK_NE(rv, ERR_IO_PENDING);
557 CHECK(!callback_.is_null()); 560 CHECK(!callback_.is_null());
561 CHECK(!in_loop_);
558 562
559 // The client callback can do anything, including destroying this class, 563 // The client callback can do anything, including destroying this class,
560 // so any pending callback must be issued after everything else is done. 564 // so any pending callback must be issued after everything else is done.
561 base::ResetAndReturn(&callback_).Run(rv); 565 base::ResetAndReturn(&callback_).Run(rv);
562 } 566 }
563 567
564 int QuicHttpStream::DoLoop(int rv) { 568 int QuicHttpStream::DoLoop(int rv) {
569 CHECK(!in_loop_);
570 base::AutoReset<bool> auto_reset_in_loop(&in_loop_, true);
565 do { 571 do {
566 State state = next_state_; 572 State state = next_state_;
567 next_state_ = STATE_NONE; 573 next_state_ = STATE_NONE;
568 switch (state) { 574 switch (state) {
569 case STATE_REQUEST_STREAM: 575 case STATE_REQUEST_STREAM:
570 rv = DoStreamRequest(); 576 rv = DoStreamRequest();
571 break; 577 break;
572 case STATE_SET_REQUEST_PRIORITY: 578 case STATE_SET_REQUEST_PRIORITY:
573 rv = DoSetRequestPriority(); 579 rv = DoSetRequestPriority();
574 break; 580 break;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); 825 closed_stream_sent_bytes_ = stream_->stream_bytes_written();
820 stream_ = nullptr; 826 stream_ = nullptr;
821 827
822 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress 828 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress
823 // read. 829 // read.
824 if (request_body_stream_) 830 if (request_body_stream_)
825 request_body_stream_->Reset(); 831 request_body_stream_->Reset();
826 } 832 }
827 833
828 } // namespace net 834 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_http_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698