Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/core/quic_headers_stream.h" | 5 #include "net/quic/core/quic_headers_stream.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "net/quic/core/quic_bug_tracker.h" | 15 #include "net/quic/core/quic_bug_tracker.h" |
| 16 #include "net/quic/core/quic_flags.h" | 16 #include "net/quic/core/quic_flags.h" |
| 17 #include "net/quic/core/quic_header_list.h" | 17 #include "net/quic/core/quic_header_list.h" |
| 18 #include "net/quic/core/quic_server_session_base.h" | 18 #include "net/quic/core/quic_server_session_base.h" |
| 19 #include "net/quic/core/quic_spdy_session.h" | 19 #include "net/quic/core/quic_spdy_session.h" |
| 20 #include "net/quic/core/quic_time.h" | 20 #include "net/quic/core/quic_time.h" |
| 21 #include "net/spdy/spdy_protocol.h" | 21 #include "net/spdy/spdy_protocol.h" |
| 22 | 22 |
| 23 using base::StringPiece; | 23 using base::StringPiece; |
| 24 using net::HTTP2; | |
| 25 using net::SpdyFrameType; | 24 using net::SpdyFrameType; |
| 26 using std::string; | 25 using std::string; |
| 27 | 26 |
| 28 namespace net { | 27 namespace net { |
| 29 | 28 |
| 30 namespace { | 29 namespace { |
| 31 | 30 |
| 32 class HeaderTableDebugVisitor : public HpackHeaderTable::DebugVisitorInterface { | 31 class HeaderTableDebugVisitor : public HpackHeaderTable::DebugVisitorInterface { |
| 33 public: | 32 public: |
| 34 HeaderTableDebugVisitor( | 33 HeaderTableDebugVisitor( |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 } | 291 } |
| 293 } | 292 } |
| 294 | 293 |
| 295 void set_max_uncompressed_header_bytes( | 294 void set_max_uncompressed_header_bytes( |
| 296 size_t set_max_uncompressed_header_bytes) { | 295 size_t set_max_uncompressed_header_bytes) { |
| 297 header_list_.set_max_uncompressed_header_bytes( | 296 header_list_.set_max_uncompressed_header_bytes( |
| 298 set_max_uncompressed_header_bytes); | 297 set_max_uncompressed_header_bytes); |
| 299 } | 298 } |
| 300 | 299 |
| 301 private: | 300 private: |
| 302 void CloseConnection(const std::string& details) { | 301 void CloseConnection(const string& details) { |
|
Bence
2016/12/01 18:32:08
This is a driveby change.
| |
| 303 if (stream_->IsConnected()) { | 302 if (stream_->IsConnected()) { |
| 304 stream_->CloseConnectionWithDetails(QUIC_INVALID_HEADERS_STREAM_DATA, | 303 stream_->CloseConnectionWithDetails(QUIC_INVALID_HEADERS_STREAM_DATA, |
| 305 details); | 304 details); |
| 306 } | 305 } |
| 307 } | 306 } |
| 308 | 307 |
| 309 private: | 308 private: |
| 310 QuicHeadersStream* stream_; | 309 QuicHeadersStream* stream_; |
| 311 QuicHeaderList header_list_; | 310 QuicHeaderList header_list_; |
| 312 | 311 |
| 313 DISALLOW_COPY_AND_ASSIGN(SpdyFramerVisitor); | 312 DISALLOW_COPY_AND_ASSIGN(SpdyFramerVisitor); |
| 314 }; | 313 }; |
| 315 | 314 |
| 316 QuicHeadersStream::QuicHeadersStream(QuicSpdySession* session) | 315 QuicHeadersStream::QuicHeadersStream(QuicSpdySession* session) |
| 317 : QuicStream(kHeadersStreamId, session), | 316 : QuicStream(kHeadersStreamId, session), |
| 318 spdy_session_(session), | 317 spdy_session_(session), |
| 319 stream_id_(kInvalidStreamId), | 318 stream_id_(kInvalidStreamId), |
| 320 promised_stream_id_(kInvalidStreamId), | 319 promised_stream_id_(kInvalidStreamId), |
| 321 fin_(false), | 320 fin_(false), |
| 322 frame_len_(0), | 321 frame_len_(0), |
| 323 uncompressed_frame_len_(0), | 322 uncompressed_frame_len_(0), |
| 324 supports_push_promise_(session->perspective() == Perspective::IS_CLIENT), | 323 supports_push_promise_(session->perspective() == Perspective::IS_CLIENT), |
| 325 cur_max_timestamp_(QuicTime::Zero()), | 324 cur_max_timestamp_(QuicTime::Zero()), |
| 326 prev_max_timestamp_(QuicTime::Zero()), | 325 prev_max_timestamp_(QuicTime::Zero()), |
| 327 spdy_framer_(HTTP2), | |
| 328 spdy_framer_visitor_(new SpdyFramerVisitor(this)) { | 326 spdy_framer_visitor_(new SpdyFramerVisitor(this)) { |
| 329 spdy_framer_.set_visitor(spdy_framer_visitor_.get()); | 327 spdy_framer_.set_visitor(spdy_framer_visitor_.get()); |
| 330 spdy_framer_.set_debug_visitor(spdy_framer_visitor_.get()); | 328 spdy_framer_.set_debug_visitor(spdy_framer_visitor_.get()); |
| 331 // The headers stream is exempt from connection level flow control. | 329 // The headers stream is exempt from connection level flow control. |
| 332 DisableConnectionFlowControlForThisStream(); | 330 DisableConnectionFlowControlForThisStream(); |
| 333 } | 331 } |
| 334 | 332 |
| 335 QuicHeadersStream::~QuicHeadersStream() {} | 333 QuicHeadersStream::~QuicHeadersStream() {} |
| 336 | 334 |
| 337 size_t QuicHeadersStream::WriteHeaders(QuicStreamId stream_id, | 335 size_t QuicHeadersStream::WriteHeaders(QuicStreamId stream_id, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 WriteOrBufferData(StringPiece(frame.data(), frame.size()), false, nullptr); | 368 WriteOrBufferData(StringPiece(frame.data(), frame.size()), false, nullptr); |
| 371 return frame.size(); | 369 return frame.size(); |
| 372 } | 370 } |
| 373 | 371 |
| 374 QuicConsumedData QuicHeadersStream::WritevStreamData( | 372 QuicConsumedData QuicHeadersStream::WritevStreamData( |
| 375 QuicStreamId id, | 373 QuicStreamId id, |
| 376 QuicIOVector iov, | 374 QuicIOVector iov, |
| 377 QuicStreamOffset offset, | 375 QuicStreamOffset offset, |
| 378 bool fin, | 376 bool fin, |
| 379 QuicAckListenerInterface* ack_notifier_delegate) { | 377 QuicAckListenerInterface* ack_notifier_delegate) { |
| 380 const size_t max_len = kSpdyInitialFrameSizeLimit - | 378 const size_t max_len = |
| 381 SpdyConstants::GetDataFrameMinimumSize(HTTP2); | 379 kSpdyInitialFrameSizeLimit - SpdyConstants::kDataFrameMinimumSize; |
| 382 | 380 |
| 383 QuicConsumedData result(0, false); | 381 QuicConsumedData result(0, false); |
| 384 size_t total_length = iov.total_length; | 382 size_t total_length = iov.total_length; |
| 385 | 383 |
| 386 // Encapsulate the data into HTTP/2 DATA frames. The outer loop | 384 // Encapsulate the data into HTTP/2 DATA frames. The outer loop |
| 387 // handles each element of the source iov, the inner loop handles | 385 // handles each element of the source iov, the inner loop handles |
| 388 // the possibility of fragmenting eacho of those into multiple DATA | 386 // the possibility of fragmenting eacho of those into multiple DATA |
| 389 // frames, as the DATA frames have a max size of 16KB. | 387 // frames, as the DATA frames have a max size of 16KB. |
| 390 for (int i = 0; i < iov.iov_count; i++) { | 388 for (int i = 0; i < iov.iov_count; i++) { |
| 391 size_t offset = 0; | 389 size_t offset = 0; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 592 return true; | 590 return true; |
| 593 } | 591 } |
| 594 frame_len_ -= len; | 592 frame_len_ -= len; |
| 595 // Ignore fin_ while there is more data coming, if frame_len_ > 0. | 593 // Ignore fin_ while there is more data coming, if frame_len_ > 0. |
| 596 spdy_session_->OnStreamFrameData(stream_id, data, len, | 594 spdy_session_->OnStreamFrameData(stream_id, data, len, |
| 597 frame_len_ > 0 ? false : fin_); | 595 frame_len_ > 0 ? false : fin_); |
| 598 return true; | 596 return true; |
| 599 } | 597 } |
| 600 | 598 |
| 601 } // namespace net | 599 } // namespace net |
| OLD | NEW |