OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_QUIC_QUIC_SPDY_DECOMPRESSOR_H_ | |
6 #define NET_QUIC_QUIC_SPDY_DECOMPRESSOR_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/strings/string_piece.h" | |
13 #include "net/base/net_export.h" | |
14 #include "net/quic/quic_protocol.h" | |
15 #include "net/spdy/spdy_framer.h" | |
16 | |
17 namespace net { | |
18 | |
19 class SpdyFramerVisitor; | |
20 | |
21 // Handles the compression of request/response headers blocks. | |
22 class NET_EXPORT_PRIVATE QuicSpdyDecompressor { | |
23 public: | |
24 // Interface that receives callbacks with decompressed data as it | |
25 // becomes available. | |
26 class NET_EXPORT_PRIVATE Visitor { | |
27 public: | |
28 virtual ~Visitor() {} | |
29 virtual bool OnDecompressedData(base::StringPiece data) = 0; | |
30 virtual void OnDecompressionError() = 0; | |
31 }; | |
32 | |
33 QuicSpdyDecompressor(); | |
34 ~QuicSpdyDecompressor(); | |
35 | |
36 // Decompresses the data in |data| and invokes |OnDecompressedData|, | |
37 // possibly multiple times, on |visitor|. Returns number of bytes | |
38 // consumed from |data|. | |
39 size_t DecompressData(base::StringPiece data, Visitor* visitor); | |
40 | |
41 QuicHeaderId current_header_id() { return current_header_id_; } | |
42 | |
43 private: | |
44 void ResetForNextHeaders(); | |
45 | |
46 SpdyFramer spdy_framer_; | |
47 scoped_ptr<SpdyFramerVisitor> spdy_visitor_; | |
48 // ID of the header currently being parsed. | |
49 QuicHeaderId current_header_id_; | |
50 // True when the size of the headers has been parsed. | |
51 bool has_current_compressed_size_; | |
52 // Size of the headers being parsed. | |
53 uint32 current_compressed_size_; | |
54 // Buffer into which the partial compressed size is written until | |
55 // it is fully parsed. | |
56 std::string compressed_size_buffer_; | |
57 // Number of compressed bytes consumed, out of the total in | |
58 // |current_compressed_size_|. | |
59 uint32 compressed_bytes_consumed_; | |
60 DISALLOW_COPY_AND_ASSIGN(QuicSpdyDecompressor); | |
61 }; | |
62 | |
63 } // namespace net | |
64 | |
65 #endif // NET_QUIC_QUIC_SPDY_DECOMPRESSOR_H_ | |
OLD | NEW |