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

Side by Side Diff: net/filter/brotli_filter.h

Issue 1431723002: Add brotli content-encoding filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix histograms.xml Created 5 years, 1 month 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 | « net/data/filter_unittests/google.br ('k') | net/filter/brotli_filter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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.
cbentzel 2015/11/14 01:20:10 Can you include a reference to Brotli here?
eustas 2015/11/16 14:26:23 Done.
7 //
8 // BrotliFilter is a subclass of Filter. See the latter's header file filter.h
9 // for sample usage.
10
11 #ifndef NET_FILTER_BROTLI_FILTER_H_
12 #define NET_FILTER_BROTLI_FILTER_H_
13
14 #include "base/basictypes.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "net/filter/filter.h"
17
18 struct BrotliStateStruct;
19
20 namespace net {
21
22 class BrotliFilter : public Filter {
23 public:
24 ~BrotliFilter() override;
25
26 // Initializes filter decoding mode and internal control blocks.
27 // The function returns true if success and false otherwise.
28 // The filter can only be initialized once.
29 bool InitDecoding();
30
31 // Decodes the pre-filter data and writes the output into the dest_buffer
32 // passed in.
33 // The function returns FilterStatus. See filter.h for its description.
34 //
35 // Upon entry, *dest_len is the total size (in number of chars) of the
36 // destination buffer. Upon exit, *dest_len is the actual number of chars
37 // written into the destination buffer.
38 //
39 // This function will fail if there is no pre-filter data in the
40 // stream_buffer_. On the other hand, *dest_len can be 0 upon successful
41 // return. For example, decompressor may process some pre-filter data
42 // but not produce output yet.
43 FilterStatus ReadFilteredData(char* dest_buffer, int* dest_len) override;
44
45 private:
46 enum DecodingStatus {
47 DECODING_UNINITIALIZED,
48 DECODING_IN_PROGRESS,
49 DECODING_DONE,
50 DECODING_ERROR
51 };
52
53 // Only to be instantiated by Filter::Factory.
54 BrotliFilter(FilterType type);
55 friend class Filter;
56
57 bool CheckBrotliHeader();
58
59 // Tracks the status of decoding.
60 // This variable is initialized by InitDecoding and updated only by
61 // ReadFilteredData.
62 DecodingStatus decoding_status_;
63
64 scoped_ptr<BrotliStateStruct> brotli_state_;
65
66 DISALLOW_COPY_AND_ASSIGN(BrotliFilter);
67 };
68
69 } // namespace net
70
71 #endif // NET_FILTER_BROTLI_FILTER_H__
OLDNEW
« no previous file with comments | « net/data/filter_unittests/google.br ('k') | net/filter/brotli_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698