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

Side by Side Diff: net/spdy/bidirectional_stream_spdy_impl.cc

Issue 2227083002: Remove net::BidirectionalStream::Cancel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/spdy/bidirectional_stream_spdy_impl.h" 5 #include "net/spdy/bidirectional_stream_spdy_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 23 matching lines...) Expand all
34 negotiated_protocol_(kProtoUnknown), 34 negotiated_protocol_(kProtoUnknown),
35 more_read_data_pending_(false), 35 more_read_data_pending_(false),
36 read_buffer_len_(0), 36 read_buffer_len_(0),
37 stream_closed_(false), 37 stream_closed_(false),
38 closed_stream_status_(ERR_FAILED), 38 closed_stream_status_(ERR_FAILED),
39 closed_stream_received_bytes_(0), 39 closed_stream_received_bytes_(0),
40 closed_stream_sent_bytes_(0), 40 closed_stream_sent_bytes_(0),
41 weak_factory_(this) {} 41 weak_factory_(this) {}
42 42
43 BidirectionalStreamSpdyImpl::~BidirectionalStreamSpdyImpl() { 43 BidirectionalStreamSpdyImpl::~BidirectionalStreamSpdyImpl() {
44 Cancel(); 44 // Sends a RST to the remote if the stream is destroyed before it completes.
45 ResetStream();
45 } 46 }
46 47
47 void BidirectionalStreamSpdyImpl::Start( 48 void BidirectionalStreamSpdyImpl::Start(
48 const BidirectionalStreamRequestInfo* request_info, 49 const BidirectionalStreamRequestInfo* request_info,
49 const BoundNetLog& net_log, 50 const BoundNetLog& net_log,
50 bool /*send_request_headers_automatically*/, 51 bool /*send_request_headers_automatically*/,
51 BidirectionalStreamImpl::Delegate* delegate, 52 BidirectionalStreamImpl::Delegate* delegate,
52 std::unique_ptr<base::Timer> timer) { 53 std::unique_ptr<base::Timer> timer) {
53 DCHECK(!stream_); 54 DCHECK(!stream_);
54 DCHECK(timer); 55 DCHECK(timer);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // TODO(xunjieli): Get rid of extra copy. Coalesce headers and data frames. 145 // TODO(xunjieli): Get rid of extra copy. Coalesce headers and data frames.
145 for (size_t i = 0; i < buffers.size(); ++i) { 146 for (size_t i = 0; i < buffers.size(); ++i) {
146 memcpy(pending_combined_buffer_->data() + len, buffers[i]->data(), 147 memcpy(pending_combined_buffer_->data() + len, buffers[i]->data(),
147 lengths[i]); 148 lengths[i]);
148 len += lengths[i]; 149 len += lengths[i];
149 } 150 }
150 stream_->SendData(pending_combined_buffer_.get(), total_len, 151 stream_->SendData(pending_combined_buffer_.get(), total_len,
151 end_stream ? NO_MORE_DATA_TO_SEND : MORE_DATA_TO_SEND); 152 end_stream ? NO_MORE_DATA_TO_SEND : MORE_DATA_TO_SEND);
152 } 153 }
153 154
154 void BidirectionalStreamSpdyImpl::Cancel() {
155 if (delegate_) {
156 delegate_ = nullptr;
157 // Cancel any pending callback.
158 weak_factory_.InvalidateWeakPtrs();
159 }
160 ResetStream();
161 }
162
163 NextProto BidirectionalStreamSpdyImpl::GetProtocol() const { 155 NextProto BidirectionalStreamSpdyImpl::GetProtocol() const {
164 return negotiated_protocol_; 156 return negotiated_protocol_;
165 } 157 }
166 158
167 int64_t BidirectionalStreamSpdyImpl::GetTotalReceivedBytes() const { 159 int64_t BidirectionalStreamSpdyImpl::GetTotalReceivedBytes() const {
168 if (stream_closed_) 160 if (stream_closed_)
169 return closed_stream_received_bytes_; 161 return closed_stream_received_bytes_;
170 162
171 if (!stream_) 163 if (!stream_)
172 return 0; 164 return 0;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 347
356 bool BidirectionalStreamSpdyImpl::ShouldWaitForMoreBufferedData() const { 348 bool BidirectionalStreamSpdyImpl::ShouldWaitForMoreBufferedData() const {
357 if (stream_closed_) 349 if (stream_closed_)
358 return false; 350 return false;
359 DCHECK_GT(read_buffer_len_, 0); 351 DCHECK_GT(read_buffer_len_, 0);
360 return read_data_queue_.GetTotalSize() < 352 return read_data_queue_.GetTotalSize() <
361 static_cast<size_t>(read_buffer_len_); 353 static_cast<size_t>(read_buffer_len_);
362 } 354 }
363 355
364 } // namespace net 356 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/bidirectional_stream_spdy_impl.h ('k') | net/spdy/bidirectional_stream_spdy_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698