| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright 2014 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_SERVER_WEB_SOCKET_ENCODER_H_ | 
|  | 6 #define NET_SERVER_WEB_SOCKET_ENCODER_H_ | 
|  | 7 | 
|  | 8 #include <string> | 
|  | 9 | 
|  | 10 #include "base/basictypes.h" | 
|  | 11 #include "base/memory/scoped_ptr.h" | 
|  | 12 #include "base/strings/string_piece.h" | 
|  | 13 #include "net/server/web_socket.h" | 
|  | 14 #include "net/websockets/websocket_deflater.h" | 
|  | 15 #include "net/websockets/websocket_inflater.h" | 
|  | 16 | 
|  | 17 namespace net { | 
|  | 18 | 
|  | 19 class WebSocketEncoder { | 
|  | 20  public: | 
|  | 21   ~WebSocketEncoder(); | 
|  | 22 | 
|  | 23   static WebSocketEncoder* CreateServer(const std::string& request_extensions, | 
|  | 24                                         std::string* response_extensions); | 
|  | 25 | 
|  | 26   static const char kClientExtensions[]; | 
|  | 27   static WebSocketEncoder* CreateClient(const std::string& response_extensions); | 
|  | 28 | 
|  | 29   WebSocket::ParseResult DecodeFrame(const base::StringPiece& frame, | 
|  | 30                                      int* bytes_consumed, | 
|  | 31                                      std::string* output); | 
|  | 32 | 
|  | 33   void EncodeFrame(const std::string& frame, | 
|  | 34                    int masking_key, | 
|  | 35                    std::string* output); | 
|  | 36 | 
|  | 37  private: | 
|  | 38   explicit WebSocketEncoder(bool is_server); | 
|  | 39   WebSocketEncoder(bool is_server, | 
|  | 40                    int deflate_bits, | 
|  | 41                    int inflate_bits, | 
|  | 42                    bool no_context_takeover); | 
|  | 43 | 
|  | 44   static void ParseExtensions(const std::string& extensions, | 
|  | 45                               bool* deflate, | 
|  | 46                               int* client_window_bits, | 
|  | 47                               int* server_window_bits, | 
|  | 48                               bool* client_no_context_takeover, | 
|  | 49                               bool* server_no_context_takeover); | 
|  | 50 | 
|  | 51   bool Inflate(std::string* message); | 
|  | 52   bool Deflate(const std::string& message, std::string* output); | 
|  | 53 | 
|  | 54   scoped_ptr<WebSocketDeflater> deflater_; | 
|  | 55   scoped_ptr<WebSocketInflater> inflater_; | 
|  | 56   bool is_server_; | 
|  | 57 | 
|  | 58   DISALLOW_COPY_AND_ASSIGN(WebSocketEncoder); | 
|  | 59 }; | 
|  | 60 | 
|  | 61 }  // namespace net | 
|  | 62 | 
|  | 63 #endif  // NET_SERVER_WEB_SOCKET_ENCODER_H_ | 
| OLD | NEW | 
|---|