OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_header_list.h" | 5 #include "net/quic/core/quic_header_list.h" |
6 | 6 |
7 #include "net/quic/core/quic_flags.h" | 7 #include "net/quic/core/quic_flags.h" |
8 #include "net/quic/core/quic_packets.h" | 8 #include "net/quic/core/quic_packets.h" |
9 | 9 |
10 using std::string; | 10 using std::string; |
(...skipping 16 matching lines...) Expand all Loading... |
27 QuicHeaderList::~QuicHeaderList() {} | 27 QuicHeaderList::~QuicHeaderList() {} |
28 | 28 |
29 void QuicHeaderList::OnHeaderBlockStart() { | 29 void QuicHeaderList::OnHeaderBlockStart() { |
30 QUIC_BUG_IF(uncompressed_header_bytes_ != 0) | 30 QUIC_BUG_IF(uncompressed_header_bytes_ != 0) |
31 << "OnHeaderBlockStart called more than once!"; | 31 << "OnHeaderBlockStart called more than once!"; |
32 } | 32 } |
33 | 33 |
34 void QuicHeaderList::OnHeader(base::StringPiece name, base::StringPiece value) { | 34 void QuicHeaderList::OnHeader(base::StringPiece name, base::StringPiece value) { |
35 // Avoid infinte buffering of headers. No longer store headers | 35 // Avoid infinte buffering of headers. No longer store headers |
36 // once the current headers are over the limit. | 36 // once the current headers are over the limit. |
37 if (!FLAGS_quic_reloadable_flag_quic_limit_uncompressed_headers || | 37 if (uncompressed_header_bytes_ == 0 || !header_list_.empty()) { |
38 uncompressed_header_bytes_ == 0 || !header_list_.empty()) { | |
39 header_list_.emplace_back(name.as_string(), value.as_string()); | 38 header_list_.emplace_back(name.as_string(), value.as_string()); |
40 } | 39 } |
41 } | 40 } |
42 | 41 |
43 void QuicHeaderList::OnHeaderBlockEnd(size_t uncompressed_header_bytes) { | 42 void QuicHeaderList::OnHeaderBlockEnd(size_t uncompressed_header_bytes) { |
44 OnHeaderBlockEnd(uncompressed_header_bytes, uncompressed_header_bytes); | 43 OnHeaderBlockEnd(uncompressed_header_bytes, uncompressed_header_bytes); |
45 } | 44 } |
46 | 45 |
47 void QuicHeaderList::OnHeaderBlockEnd(size_t uncompressed_header_bytes, | 46 void QuicHeaderList::OnHeaderBlockEnd(size_t uncompressed_header_bytes, |
48 size_t compressed_header_bytes) { | 47 size_t compressed_header_bytes) { |
49 uncompressed_header_bytes_ = uncompressed_header_bytes; | 48 uncompressed_header_bytes_ = uncompressed_header_bytes; |
50 compressed_header_bytes_ = compressed_header_bytes; | 49 compressed_header_bytes_ = compressed_header_bytes; |
51 if (FLAGS_quic_reloadable_flag_quic_limit_uncompressed_headers && | 50 if (uncompressed_header_bytes_ > max_uncompressed_header_bytes_) { |
52 uncompressed_header_bytes_ > max_uncompressed_header_bytes_) { | |
53 Clear(); | 51 Clear(); |
54 } | 52 } |
55 } | 53 } |
56 | 54 |
57 void QuicHeaderList::Clear() { | 55 void QuicHeaderList::Clear() { |
58 header_list_.clear(); | 56 header_list_.clear(); |
59 uncompressed_header_bytes_ = 0; | 57 uncompressed_header_bytes_ = 0; |
60 } | 58 } |
61 | 59 |
62 string QuicHeaderList::DebugString() const { | 60 string QuicHeaderList::DebugString() const { |
63 string s = "{ "; | 61 string s = "{ "; |
64 for (const auto& p : *this) { | 62 for (const auto& p : *this) { |
65 s.append(p.first + "=" + p.second + ", "); | 63 s.append(p.first + "=" + p.second + ", "); |
66 } | 64 } |
67 s.append("}"); | 65 s.append("}"); |
68 return s; | 66 return s; |
69 } | 67 } |
70 | 68 |
71 } // namespace net | 69 } // namespace net |
OLD | NEW |