Chromium Code Reviews| 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_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 "third_party/zlib/zlib.h" | |
| 14 | |
| 15 namespace net { | |
| 16 | |
| 17 class IOBufferWithSize; | |
| 18 | |
| 19 class WebSocketDeflater { | |
|
Adam Rice
2013/08/30 13:20:13
Please add NET_EXPORT_PRIVATE so that component bu
yhirano
2013/09/02 02:01:12
Done.
| |
| 20 public: | |
| 21 enum ContextTakeOverMode { | |
| 22 DO_NOT_TAKE_OVER_CONTEXT, | |
| 23 TAKE_OVER_CONTEXT, | |
| 24 }; | |
| 25 | |
| 26 // |window_bits| must be between 8 and 15 (both inclusive). | |
| 27 WebSocketDeflater(int window_bits, ContextTakeOverMode mode); | |
| 28 ~WebSocketDeflater(); | |
| 29 | |
| 30 // Adds bytes to |stream_|. | |
| 31 // Returns true if there is no error and false otherwise. | |
| 32 bool AddBytes(const char* data, size_t size); | |
| 33 | |
| 34 // Flushes and returns deflated result. | |
| 35 // Returns null if there is an error. | |
| 36 scoped_refptr<IOBufferWithSize> Finish(); | |
| 37 | |
| 38 private: | |
| 39 void Reset(); | |
| 40 int Deflate(size_t size, int flush); | |
| 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_ | |
| OLD | NEW |