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 WebSocketEncoder(bool is_server); | |
yhirano
2014/12/08 05:06:29
+explicit
dgozman
2014/12/08 17:53:00
Done.
| |
39 WebSocketEncoder(bool is_server, int deflate_bits, int inflate_bits); | |
40 | |
41 static void ParseExtensions(const std::string& extensions, | |
42 bool* deflate, | |
43 int* client_window_bits, | |
44 int* server_window_bits); | |
45 | |
46 bool Inflate(std::string* message); | |
47 bool Deflate(const std::string& message, std::string* output); | |
48 | |
49 scoped_ptr<WebSocketDeflater> deflater_; | |
50 scoped_ptr<WebSocketInflater> inflater_; | |
51 bool is_server_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(WebSocketEncoder); | |
54 }; | |
55 | |
56 } // namespace net | |
57 | |
58 #endif // NET_SERVER_WEB_SOCKET_ENCODER_H_ | |
OLD | NEW |