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

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

Issue 1272283003: Add a new SpdyStream::Delegate method to handle trailers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 5 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 (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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 for (std::string::const_iterator i(str.begin()); i != str.end(); ++i) { 50 for (std::string::const_iterator i(str.begin()); i != str.end(); ++i) {
51 if (*i >= 'A' && *i <= 'Z') { 51 if (*i >= 'A' && *i <= 'Z') {
52 return true; 52 return true;
53 } 53 }
54 } 54 }
55 return false; 55 return false;
56 } 56 }
57 57
58 } // namespace 58 } // namespace
59 59
60 void SpdyStream::Delegate::OnTrailers(const SpdyHeaderBlock& trailers) {}
61
60 // A wrapper around a stream that calls into ProduceSynStreamFrame(). 62 // A wrapper around a stream that calls into ProduceSynStreamFrame().
61 class SpdyStream::SynStreamBufferProducer : public SpdyBufferProducer { 63 class SpdyStream::SynStreamBufferProducer : public SpdyBufferProducer {
62 public: 64 public:
63 SynStreamBufferProducer(const base::WeakPtr<SpdyStream>& stream) 65 SynStreamBufferProducer(const base::WeakPtr<SpdyStream>& stream)
64 : stream_(stream) { 66 : stream_(stream) {
65 DCHECK(stream_.get()); 67 DCHECK(stream_.get());
66 } 68 }
67 69
68 ~SynStreamBufferProducer() override {} 70 ~SynStreamBufferProducer() override {}
69 71
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 DCHECK_NE(io_state_, STATE_IDLE); 435 DCHECK_NE(io_state_, STATE_IDLE);
434 436
435 response_time_ = response_time; 437 response_time_ = response_time;
436 recv_first_byte_time_ = recv_first_byte_time; 438 recv_first_byte_time_ = recv_first_byte_time;
437 return MergeWithResponseHeaders(initial_response_headers); 439 return MergeWithResponseHeaders(initial_response_headers);
438 } 440 }
439 441
440 int SpdyStream::OnAdditionalResponseHeadersReceived( 442 int SpdyStream::OnAdditionalResponseHeadersReceived(
441 const SpdyHeaderBlock& additional_response_headers) { 443 const SpdyHeaderBlock& additional_response_headers) {
442 if (type_ == SPDY_REQUEST_RESPONSE_STREAM) { 444 if (type_ == SPDY_REQUEST_RESPONSE_STREAM) {
443 session_->ResetStream( 445 if (response_headers_status_ != RESPONSE_HEADERS_ARE_COMPLETE) {
444 stream_id_, RST_STREAM_PROTOCOL_ERROR, 446 session_->ResetStream(
445 "Additional headers received for request/response stream"); 447 stream_id_, RST_STREAM_PROTOCOL_ERROR,
446 return ERR_SPDY_PROTOCOL_ERROR; 448 "Additional headers received for request/response stream");
447 } else if (type_ == SPDY_PUSH_STREAM && 449 return ERR_SPDY_PROTOCOL_ERROR;
448 response_headers_status_ == RESPONSE_HEADERS_ARE_COMPLETE) { 450 }
451 response_headers_status_ = TRAILERS_RECEIVED;
452 delegate_->OnTrailers(additional_response_headers);
453 return OK;
454 }
455 if (type_ == SPDY_PUSH_STREAM &&
456 response_headers_status_ == RESPONSE_HEADERS_ARE_COMPLETE) {
449 session_->ResetStream( 457 session_->ResetStream(
450 stream_id_, RST_STREAM_PROTOCOL_ERROR, 458 stream_id_, RST_STREAM_PROTOCOL_ERROR,
451 "Additional headers received for push stream"); 459 "Additional headers received for push stream");
452 return ERR_SPDY_PROTOCOL_ERROR; 460 return ERR_SPDY_PROTOCOL_ERROR;
453 } 461 }
454 return MergeWithResponseHeaders(additional_response_headers); 462 return MergeWithResponseHeaders(additional_response_headers);
455 } 463 }
456 464
457 void SpdyStream::OnPushPromiseHeadersReceived(const SpdyHeaderBlock& headers) { 465 void SpdyStream::OnPushPromiseHeadersReceived(const SpdyHeaderBlock& headers) {
458 CHECK(!request_headers_.get()); 466 CHECK(!request_headers_.get());
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 927 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
920 state); 928 state);
921 break; 929 break;
922 } 930 }
923 return description; 931 return description;
924 } 932 }
925 933
926 #undef STATE_CASE 934 #undef STATE_CASE
927 935
928 } // namespace net 936 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698