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

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
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
14 typedef struct z_stream_s z_stream;
Adam Rice 2013/08/29 12:04:33 z_stream_s has C linkage so this is actually a dif
yhirano 2013/08/30 06:20:35 Thanks, including zlib.h solves the problem.
15
16 namespace net {
17
18 class IOBufferWithSize;
19
20 class 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.
36 // Returns null if there is an error.
37 scoped_refptr<IOBufferWithSize> Finish();
38
39 private:
40 void Reset();
41
42 scoped_ptr<z_stream> stream_;
43 ContextTakeOverMode mode_;
44 std::vector<char> buffer_;
45 bool are_bytes_added_;
46
47 DISALLOW_COPY_AND_ASSIGN(WebSocketDeflater);
48 };
49
50 } // namespace net
51
52 #endif // NET_WEBSOCKETS_WEBSOCKET_DEFLATER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698