| 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 { | 
|  | 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 | 
|  | 41   scoped_ptr<z_stream> stream_; | 
|  | 42   ContextTakeOverMode mode_; | 
|  | 43   std::vector<char> buffer_; | 
|  | 44   bool are_bytes_added_; | 
|  | 45 | 
|  | 46   DISALLOW_COPY_AND_ASSIGN(WebSocketDeflater); | 
|  | 47 }; | 
|  | 48 | 
|  | 49 }  // namespace net | 
|  | 50 | 
|  | 51 #endif  // NET_WEBSOCKETS_WEBSOCKET_DEFLATER_H_ | 
| OLD | NEW | 
|---|