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

Side by Side Diff: net/websockets/websocket_deflater.h

Issue 23623008: Implement WebSocketDeflater. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 | « net/websockets/README ('k') | net/websockets/websocket_deflater.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 (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_WEBSOCKETS_WEBSOCKET_DEFLATER_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_DEFLATER_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "net/base/net_export.h"
14 #include "third_party/zlib/zlib.h"
15
16 namespace net {
17
18 class IOBufferWithSize;
19
20 class NET_EXPORT_PRIVATE WebSocketDeflater {
21 public:
22 enum ContextTakeOverMode {
23 DO_NOT_TAKE_OVER_CONTEXT,
24 TAKE_OVER_CONTEXT,
25 };
26
27 // |window_bits| must be between 8 and 15 (both inclusive).
28 WebSocketDeflater(int window_bits, ContextTakeOverMode mode);
29 ~WebSocketDeflater();
30
31 // Adds bytes to |stream_|.
32 // Returns true if there is no error and false otherwise.
33 bool AddBytes(const char* data, size_t size);
34
35 // Flushes and returns deflated result.
Adam Rice 2013/09/05 06:05:59 Remove the "and returns".
yhirano 2013/09/05 06:34:07 Thanks, done.
36 // Returns true if there is no error and false otherwise.
37 bool Finish();
38
39 // Returns the current deflated output.
40 // If the current output is larger than |size| bytes,
41 // returns the first |size| bytes of the current output.
42 // The returned bytes will be dropped from the current output and never be
43 // returned thereafter.
44 scoped_refptr<IOBufferWithSize> GetOutput(size_t size);
Adam Rice 2013/09/05 06:05:59 A minor issue is that if the size() of the return
45
46 // Returns the size of the current deflated output.
47 size_t CurrentOutputSize();
Adam Rice 2013/09/05 06:05:59 This can probably be a const method.
yhirano 2013/09/05 06:34:07 Done.
48
49 private:
50 void Reset();
51 int Deflate(size_t size, int flush);
52
53 scoped_ptr<z_stream> stream_;
54 ContextTakeOverMode mode_;
55 std::vector<char> buffer_;
Adam Rice 2013/09/05 06:05:59 Something like std::queue<std::vector<char> > migh
yhirano 2013/09/05 06:34:07 Done.
56 bool are_bytes_added_;
57
58 DISALLOW_COPY_AND_ASSIGN(WebSocketDeflater);
59 };
60
61 } // namespace net
62
63 #endif // NET_WEBSOCKETS_WEBSOCKET_DEFLATER_H_
OLDNEW
« no previous file with comments | « net/websockets/README ('k') | net/websockets/websocket_deflater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698