OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 // BrotliFilter applies Brotli content decoding to a data | |
6 // stream. Brotli format specification: | |
7 // http://www.ietf.org/id/draft-alakuijala-brotli | |
8 // | |
9 // BrotliFilter is a subclass of Filter. See the latter's header file filter.h | |
10 // for sample usage. | |
11 | |
12 #ifndef NET_FILTER_BROTLI_FILTER_H_ | |
13 #define NET_FILTER_BROTLI_FILTER_H_ | |
14 | |
15 #include "base/basictypes.h" | |
16 #include "base/memory/scoped_ptr.h" | |
17 #include "net/filter/filter.h" | |
18 | |
19 struct BrotliStateStruct; | |
20 | |
21 namespace net { | |
22 | |
23 class BrotliFilter : public Filter { | |
24 public: | |
25 ~BrotliFilter() override; | |
26 | |
27 // Initializes filter decoding mode and internal control blocks. | |
28 // The function returns true if success and false otherwise. | |
29 // The filter can only be initialized once. | |
30 bool InitDecoding(); | |
31 | |
32 // Decodes the pre-filter data and writes the output into the dest_buffer | |
33 // passed in. | |
34 // The function returns FilterStatus. See filter.h for its description. | |
35 // | |
36 // Upon entry, *dest_len is the total size (in number of chars) of the | |
37 // destination buffer. Upon exit, *dest_len is the actual number of chars | |
38 // written into the destination buffer. | |
39 // | |
40 // This function will fail if there is no pre-filter data in the | |
41 // stream_buffer_. On the other hand, *dest_len can be 0 upon successful | |
xunjieli
2015/11/17 16:16:12
nit: Please surround the variables using pipes.
e
eustas
2015/11/17 17:57:21
Surely. Done.
| |
42 // return. For example, decompressor may process some pre-filter data | |
43 // but not produce output yet. | |
44 FilterStatus ReadFilteredData(char* dest_buffer, int* dest_len) override; | |
45 | |
46 private: | |
47 enum DecodingStatus { | |
48 DECODING_UNINITIALIZED, | |
49 DECODING_IN_PROGRESS, | |
50 DECODING_DONE, | |
51 DECODING_ERROR | |
52 }; | |
53 | |
54 // Only to be instantiated by Filter::Factory. | |
55 BrotliFilter(FilterType type); | |
56 friend class Filter; | |
57 | |
58 bool CheckBrotliHeader(); | |
59 | |
60 // Tracks the status of decoding. | |
61 // This variable is initialized by InitDecoding and updated only by | |
62 // ReadFilteredData. | |
63 DecodingStatus decoding_status_; | |
64 | |
65 scoped_ptr<BrotliStateStruct> brotli_state_; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(BrotliFilter); | |
68 }; | |
69 | |
70 } // namespace net | |
71 | |
72 #endif // NET_FILTER_BROTLI_FILTER_H__ | |
OLD | NEW |