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

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: 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) {
445 if (response_headers_status_ != RESPONSE_HEADERS_ARE_COMPLETE) {
443 session_->ResetStream( 446 session_->ResetStream(
444 stream_id_, RST_STREAM_PROTOCOL_ERROR, 447 stream_id_, RST_STREAM_PROTOCOL_ERROR,
445 "Additional headers received for request/response stream"); 448 "Additional headers received for request/response stream");
446 return ERR_SPDY_PROTOCOL_ERROR; 449 return ERR_SPDY_PROTOCOL_ERROR;
450 }
451 response_headers_status_ = TRAILERS_RECEIVED;
452 delegate_->OnTrailers(additional_response_headers);
453 return OK;
447 } else if (type_ == SPDY_PUSH_STREAM && 454 } else if (type_ == SPDY_PUSH_STREAM &&
Bence 2015/08/06 15:02:41 Once you are here, you might want to consider remo
xunjieli 2015/08/06 16:10:13 Done.
448 response_headers_status_ == RESPONSE_HEADERS_ARE_COMPLETE) { 455 response_headers_status_ == RESPONSE_HEADERS_ARE_COMPLETE) {
449 session_->ResetStream( 456 session_->ResetStream(
450 stream_id_, RST_STREAM_PROTOCOL_ERROR, 457 stream_id_, RST_STREAM_PROTOCOL_ERROR,
451 "Additional headers received for push stream"); 458 "Additional headers received for push stream");
452 return ERR_SPDY_PROTOCOL_ERROR; 459 return ERR_SPDY_PROTOCOL_ERROR;
453 } 460 }
454 return MergeWithResponseHeaders(additional_response_headers); 461 return MergeWithResponseHeaders(additional_response_headers);
455 } 462 }
456 463
457 void SpdyStream::OnPushPromiseHeadersReceived(const SpdyHeaderBlock& headers) { 464 void SpdyStream::OnPushPromiseHeadersReceived(const SpdyHeaderBlock& headers) {
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 926 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
920 state); 927 state);
921 break; 928 break;
922 } 929 }
923 return description; 930 return description;
924 } 931 }
925 932
926 #undef STATE_CASE 933 #undef STATE_CASE
927 934
928 } // namespace net 935 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698