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

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

Issue 2167253002: s/SYN_STREAM/HEADERS/ in frame types, method names, comments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. 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/spdy/spdy_stream.h ('k') | net/spdy/spdy_stream_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 (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/spdy/spdy_stream.h" 5 #include "net/spdy/spdy_stream.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 bool ContainsUppercaseAscii(const std::string& str) { 53 bool ContainsUppercaseAscii(const std::string& str) {
54 return std::any_of(str.begin(), str.end(), base::IsAsciiUpper<char>); 54 return std::any_of(str.begin(), str.end(), base::IsAsciiUpper<char>);
55 } 55 }
56 56
57 } // namespace 57 } // namespace
58 58
59 void SpdyStream::Delegate::OnTrailers(const SpdyHeaderBlock& trailers) {} 59 void SpdyStream::Delegate::OnTrailers(const SpdyHeaderBlock& trailers) {}
60 60
61 // A wrapper around a stream that calls into ProduceSynStreamFrame(). 61 // A wrapper around a stream that calls into ProduceHeadersFrame().
62 class SpdyStream::SynStreamBufferProducer : public SpdyBufferProducer { 62 class SpdyStream::HeadersBufferProducer : public SpdyBufferProducer {
63 public: 63 public:
64 SynStreamBufferProducer(const base::WeakPtr<SpdyStream>& stream) 64 HeadersBufferProducer(const base::WeakPtr<SpdyStream>& stream)
65 : stream_(stream) { 65 : stream_(stream) {
66 DCHECK(stream_.get()); 66 DCHECK(stream_.get());
67 } 67 }
68 68
69 ~SynStreamBufferProducer() override {} 69 ~HeadersBufferProducer() override {}
70 70
71 std::unique_ptr<SpdyBuffer> ProduceBuffer() override { 71 std::unique_ptr<SpdyBuffer> ProduceBuffer() override {
72 if (!stream_.get()) { 72 if (!stream_.get()) {
73 NOTREACHED(); 73 NOTREACHED();
74 return std::unique_ptr<SpdyBuffer>(); 74 return std::unique_ptr<SpdyBuffer>();
75 } 75 }
76 DCHECK_GT(stream_->stream_id(), 0u); 76 DCHECK_GT(stream_->stream_id(), 0u);
77 return std::unique_ptr<SpdyBuffer>( 77 return std::unique_ptr<SpdyBuffer>(
78 new SpdyBuffer(stream_->ProduceSynStreamFrame())); 78 new SpdyBuffer(stream_->ProduceHeadersFrame()));
79 } 79 }
80 80
81 private: 81 private:
82 const base::WeakPtr<SpdyStream> stream_; 82 const base::WeakPtr<SpdyStream> stream_;
83 }; 83 };
84 84
85 SpdyStream::SpdyStream(SpdyStreamType type, 85 SpdyStream::SpdyStream(SpdyStreamType type,
86 const base::WeakPtr<SpdySession>& session, 86 const base::WeakPtr<SpdySession>& session,
87 const GURL& url, 87 const GURL& url,
88 RequestPriority priority, 88 RequestPriority priority,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 if (eof) { 193 if (eof) {
194 DCHECK(pending_recv_data_.empty()); 194 DCHECK(pending_recv_data_.empty());
195 session_->CloseActiveStream(stream_id_, OK); 195 session_->CloseActiveStream(stream_id_, OK);
196 DCHECK(!weak_this); 196 DCHECK(!weak_this);
197 // |pending_recv_data_| is invalid at this point. 197 // |pending_recv_data_| is invalid at this point.
198 break; 198 break;
199 } 199 }
200 } 200 }
201 } 201 }
202 202
203 std::unique_ptr<SpdySerializedFrame> SpdyStream::ProduceSynStreamFrame() { 203 std::unique_ptr<SpdySerializedFrame> SpdyStream::ProduceHeadersFrame() {
204 CHECK_EQ(io_state_, STATE_IDLE); 204 CHECK_EQ(io_state_, STATE_IDLE);
205 CHECK(request_headers_valid_); 205 CHECK(request_headers_valid_);
206 CHECK_GT(stream_id_, 0u); 206 CHECK_GT(stream_id_, 0u);
207 207
208 SpdyControlFlags flags = 208 SpdyControlFlags flags =
209 (pending_send_status_ == NO_MORE_DATA_TO_SEND) ? 209 (pending_send_status_ == NO_MORE_DATA_TO_SEND) ?
210 CONTROL_FLAG_FIN : CONTROL_FLAG_NONE; 210 CONTROL_FLAG_FIN : CONTROL_FLAG_NONE;
211 std::unique_ptr<SpdySerializedFrame> frame(session_->CreateSynStream( 211 std::unique_ptr<SpdySerializedFrame> frame(session_->CreateHeaders(
212 stream_id_, priority_, flags, std::move(request_headers_))); 212 stream_id_, priority_, flags, std::move(request_headers_)));
213 request_headers_valid_ = false; 213 request_headers_valid_ = false;
214 send_time_ = base::TimeTicks::Now(); 214 send_time_ = base::TimeTicks::Now();
215 return frame; 215 return frame;
216 } 216 }
217 217
218 void SpdyStream::DetachDelegate() { 218 void SpdyStream::DetachDelegate() {
219 DCHECK(!IsClosed()); 219 DCHECK(!IsClosed());
220 delegate_ = NULL; 220 delegate_ = NULL;
221 Cancel(); 221 Cancel();
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 // May close the stream. 558 // May close the stream.
559 DecreaseRecvWindowSize(static_cast<int32_t>(len)); 559 DecreaseRecvWindowSize(static_cast<int32_t>(len));
560 if (!weak_this) 560 if (!weak_this)
561 return; 561 return;
562 IncreaseRecvWindowSize(static_cast<int32_t>(len)); 562 IncreaseRecvWindowSize(static_cast<int32_t>(len));
563 } 563 }
564 564
565 void SpdyStream::OnFrameWriteComplete(SpdyFrameType frame_type, 565 void SpdyStream::OnFrameWriteComplete(SpdyFrameType frame_type,
566 size_t frame_size) { 566 size_t frame_size) {
567 DCHECK_NE(type_, SPDY_PUSH_STREAM); 567 DCHECK_NE(type_, SPDY_PUSH_STREAM);
568 CHECK(frame_type == SYN_STREAM || 568 CHECK(frame_type == HEADERS || frame_type == DATA) << frame_type;
569 frame_type == DATA) << frame_type;
570 569
571 int result = (frame_type == SYN_STREAM) ? 570 int result =
572 OnRequestHeadersSent() : OnDataSent(frame_size); 571 (frame_type == HEADERS) ? OnRequestHeadersSent() : OnDataSent(frame_size);
573 if (result == ERR_IO_PENDING) { 572 if (result == ERR_IO_PENDING) {
574 // The write operation hasn't completed yet. 573 // The write operation hasn't completed yet.
575 return; 574 return;
576 } 575 }
577 576
578 if (pending_send_status_ == NO_MORE_DATA_TO_SEND) { 577 if (pending_send_status_ == NO_MORE_DATA_TO_SEND) {
579 if (io_state_ == STATE_OPEN) { 578 if (io_state_ == STATE_OPEN) {
580 io_state_ = STATE_HALF_CLOSED_LOCAL; 579 io_state_ = STATE_HALF_CLOSED_LOCAL;
581 } else if (io_state_ == STATE_HALF_CLOSED_REMOTE) { 580 } else if (io_state_ == STATE_HALF_CLOSED_REMOTE) {
582 io_state_ = STATE_CLOSED; 581 io_state_ = STATE_CLOSED;
583 } else { 582 } else {
584 NOTREACHED() << io_state_; 583 NOTREACHED() << io_state_;
585 } 584 }
586 } 585 }
587 // Notify delegate of write completion. Must not destroy |this|. 586 // Notify delegate of write completion. Must not destroy |this|.
588 CHECK(delegate_); 587 CHECK(delegate_);
589 { 588 {
590 base::WeakPtr<SpdyStream> weak_this = GetWeakPtr(); 589 base::WeakPtr<SpdyStream> weak_this = GetWeakPtr();
591 write_handler_guard_ = true; 590 write_handler_guard_ = true;
592 if (frame_type == SYN_STREAM) { 591 if (frame_type == HEADERS) {
593 delegate_->OnRequestHeadersSent(); 592 delegate_->OnRequestHeadersSent();
594 } else { 593 } else {
595 delegate_->OnDataSent(); 594 delegate_->OnDataSent();
596 } 595 }
597 CHECK(weak_this); 596 CHECK(weak_this);
598 write_handler_guard_ = false; 597 write_handler_guard_ = false;
599 } 598 }
600 599
601 if (io_state_ == STATE_CLOSED) { 600 if (io_state_ == STATE_CLOSED) {
602 // Deletes |this|. 601 // Deletes |this|.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 SpdySendStatus send_status) { 687 SpdySendStatus send_status) {
689 CHECK_NE(type_, SPDY_PUSH_STREAM); 688 CHECK_NE(type_, SPDY_PUSH_STREAM);
690 CHECK_EQ(pending_send_status_, MORE_DATA_TO_SEND); 689 CHECK_EQ(pending_send_status_, MORE_DATA_TO_SEND);
691 CHECK(!request_headers_valid_); 690 CHECK(!request_headers_valid_);
692 CHECK(!pending_send_data_.get()); 691 CHECK(!pending_send_data_.get());
693 CHECK_EQ(io_state_, STATE_IDLE); 692 CHECK_EQ(io_state_, STATE_IDLE);
694 request_headers_ = std::move(request_headers); 693 request_headers_ = std::move(request_headers);
695 request_headers_valid_ = true; 694 request_headers_valid_ = true;
696 url_from_header_block_ = GetUrlFromHeaderBlock(request_headers_); 695 url_from_header_block_ = GetUrlFromHeaderBlock(request_headers_);
697 pending_send_status_ = send_status; 696 pending_send_status_ = send_status;
698 session_->EnqueueStreamWrite(GetWeakPtr(), SYN_STREAM, 697 session_->EnqueueStreamWrite(GetWeakPtr(), HEADERS,
699 std::unique_ptr<SpdyBufferProducer>( 698 std::unique_ptr<SpdyBufferProducer>(
700 new SynStreamBufferProducer(GetWeakPtr()))); 699 new HeadersBufferProducer(GetWeakPtr())));
701 return ERR_IO_PENDING; 700 return ERR_IO_PENDING;
702 } 701 }
703 702
704 void SpdyStream::SendData(IOBuffer* data, 703 void SpdyStream::SendData(IOBuffer* data,
705 int length, 704 int length,
706 SpdySendStatus send_status) { 705 SpdySendStatus send_status) {
707 CHECK_NE(type_, SPDY_PUSH_STREAM); 706 CHECK_NE(type_, SPDY_PUSH_STREAM);
708 CHECK_EQ(pending_send_status_, MORE_DATA_TO_SEND); 707 CHECK_EQ(pending_send_status_, MORE_DATA_TO_SEND);
709 CHECK(io_state_ == STATE_OPEN || 708 CHECK(io_state_ == STATE_OPEN ||
710 io_state_ == STATE_HALF_CLOSED_REMOTE) << io_state_; 709 io_state_ == STATE_HALF_CLOSED_REMOTE) << io_state_;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 930 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
932 state); 931 state);
933 break; 932 break;
934 } 933 }
935 return description; 934 return description;
936 } 935 }
937 936
938 #undef STATE_CASE 937 #undef STATE_CASE
939 938
940 } // namespace net 939 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_stream.h ('k') | net/spdy/spdy_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698