OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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( |
| 24 const std::string& request_extensions, |
| 25 std::string* response_extensions); |
| 26 |
| 27 static const char kClientExtensions[]; |
| 28 static WebSocketEncoder* CreateClient( |
| 29 const std::string& response_extensions); |
| 30 |
| 31 WebSocket::ParseResult DecodeFrame( |
| 32 const base::StringPiece& frame, |
| 33 int* bytes_consumed, |
| 34 std::string* output); |
| 35 |
| 36 void EncodeFrame( |
| 37 const std::string& frame, |
| 38 int masking_key, |
| 39 std::string* output); |
| 40 |
| 41 private: |
| 42 WebSocketEncoder(bool is_server); |
| 43 WebSocketEncoder(bool is_server, int deflate_bits, int inflate_bits); |
| 44 |
| 45 static void ParseExtensions( |
| 46 const std::string& extensions, |
| 47 bool *deflate, int *client_window_bits, int *server_window_bits); |
| 48 |
| 49 WebSocket::ParseResult Inflate(std::string* message); |
| 50 WebSocket::ParseResult Deflate( |
| 51 const std::string& message, std::string* output); |
| 52 |
| 53 scoped_ptr<WebSocketDeflater> deflater_; |
| 54 scoped_ptr<WebSocketInflater> inflater_; |
| 55 bool is_server_; |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(WebSocketEncoder); |
| 58 }; |
| 59 |
| 60 } // namespace net |
| 61 |
| 62 #endif // NET_SERVER_WEB_SOCKET_ENCODER_H_ |
OLD | NEW |