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

Side by Side Diff: net/spdy/hpack/hpack_encoder.h

Issue 2237113005: Adds a listener interface to HpackEncoder. Not used in production. Not protected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Comments Created 4 years, 3 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 | « no previous file | net/spdy/hpack/hpack_encoder.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef NET_SPDY_HPACK_HPACK_ENCODER_H_ 5 #ifndef NET_SPDY_HPACK_HPACK_ENCODER_H_
6 #define NET_SPDY_HPACK_HPACK_ENCODER_H_ 6 #define NET_SPDY_HPACK_HPACK_ENCODER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 18 matching lines...) Expand all
29 29
30 namespace test { 30 namespace test {
31 class HpackEncoderPeer; 31 class HpackEncoderPeer;
32 } // namespace test 32 } // namespace test
33 33
34 class NET_EXPORT_PRIVATE HpackEncoder { 34 class NET_EXPORT_PRIVATE HpackEncoder {
35 public: 35 public:
36 using Representation = std::pair<base::StringPiece, base::StringPiece>; 36 using Representation = std::pair<base::StringPiece, base::StringPiece>;
37 using Representations = std::vector<Representation>; 37 using Representations = std::vector<Representation>;
38 38
39 // Callers may provide a HeaderListener to be informed of header name-value
40 // pairs processed by this encoder.
41 typedef std::function<void(base::StringPiece, base::StringPiece)>
42 HeaderListener;
43
39 // An indexing policy should return true if the provided header name-value 44 // An indexing policy should return true if the provided header name-value
40 // pair should be inserted into the HPACK dynamic table. 45 // pair should be inserted into the HPACK dynamic table.
41 using IndexingPolicy = 46 using IndexingPolicy =
42 std::function<bool(base::StringPiece, base::StringPiece)>; 47 std::function<bool(base::StringPiece, base::StringPiece)>;
43 48
44 // |table| is an initialized HPACK Huffman table, having an 49 // |table| is an initialized HPACK Huffman table, having an
45 // externally-managed lifetime which spans beyond HpackEncoder. 50 // externally-managed lifetime which spans beyond HpackEncoder.
46 explicit HpackEncoder(const HpackHuffmanTable& table); 51 explicit HpackEncoder(const HpackHuffmanTable& table);
47 ~HpackEncoder(); 52 ~HpackEncoder();
48 53
(...skipping 17 matching lines...) Expand all
66 void ApplyHeaderTableSizeSetting(size_t size_setting); 71 void ApplyHeaderTableSizeSetting(size_t size_setting);
67 72
68 size_t CurrentHeaderTableSizeSetting() const { 73 size_t CurrentHeaderTableSizeSetting() const {
69 return header_table_.settings_size_bound(); 74 return header_table_.settings_size_bound();
70 } 75 }
71 76
72 // This HpackEncoder will use |policy| to determine whether to insert header 77 // This HpackEncoder will use |policy| to determine whether to insert header
73 // name-value pairs into the dynamic table. 78 // name-value pairs into the dynamic table.
74 void SetIndexingPolicy(IndexingPolicy policy) { should_index_ = policy; } 79 void SetIndexingPolicy(IndexingPolicy policy) { should_index_ = policy; }
75 80
81 // |listener| will be invoked for each header name-value pair processed by
82 // this encoder.
83 void SetHeaderListener(HeaderListener listener) { listener_ = listener; }
84
76 void SetHeaderTableDebugVisitor( 85 void SetHeaderTableDebugVisitor(
77 std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor) { 86 std::unique_ptr<HpackHeaderTable::DebugVisitorInterface> visitor) {
78 header_table_.set_debug_visitor(std::move(visitor)); 87 header_table_.set_debug_visitor(std::move(visitor));
79 } 88 }
80 89
81 private: 90 private:
82 friend class test::HpackEncoderPeer; 91 friend class test::HpackEncoderPeer;
83 92
84 class RepresentationIterator; 93 class RepresentationIterator;
85 94
(...skipping 21 matching lines...) Expand all
107 116
108 // Crumbles other header field values at \0 delimiters. 117 // Crumbles other header field values at \0 delimiters.
109 static void DecomposeRepresentation(const Representation& header_field, 118 static void DecomposeRepresentation(const Representation& header_field,
110 Representations* out); 119 Representations* out);
111 120
112 HpackHeaderTable header_table_; 121 HpackHeaderTable header_table_;
113 HpackOutputStream output_stream_; 122 HpackOutputStream output_stream_;
114 123
115 const HpackHuffmanTable& huffman_table_; 124 const HpackHuffmanTable& huffman_table_;
116 size_t min_table_size_setting_received_; 125 size_t min_table_size_setting_received_;
126 HeaderListener listener_;
117 IndexingPolicy should_index_; 127 IndexingPolicy should_index_;
118 bool allow_huffman_compression_; 128 bool allow_huffman_compression_;
119 bool should_emit_table_size_; 129 bool should_emit_table_size_;
120 130
121 DISALLOW_COPY_AND_ASSIGN(HpackEncoder); 131 DISALLOW_COPY_AND_ASSIGN(HpackEncoder);
122 }; 132 };
123 133
124 } // namespace net 134 } // namespace net
125 135
126 #endif // NET_SPDY_HPACK_HPACK_ENCODER_H_ 136 #endif // NET_SPDY_HPACK_HPACK_ENCODER_H_
OLDNEW
« no previous file with comments | « no previous file | net/spdy/hpack/hpack_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698