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.
5 #ifndef NET_SERVER_WEB_SOCKET_ENCODER_H_
6 #define NET_SERVER_WEB_SOCKET_ENCODER_H_
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"
19 class WebSocketEncoder
{
23 static WebSocketEncoder
* CreateServer(const std::string
& request_extensions
,
24 std::string
* response_extensions
);
26 static const char kClientExtensions
[];
27 static WebSocketEncoder
* CreateClient(const std::string
& response_extensions
);
29 WebSocket::ParseResult
DecodeFrame(const base::StringPiece
& frame
,
33 void EncodeFrame(const std::string
& frame
,
38 explicit WebSocketEncoder(bool is_server
);
39 WebSocketEncoder(bool is_server
,
42 bool no_context_takeover
);
44 static void ParseExtensions(const std::string
& extensions
,
46 int* client_window_bits
,
47 int* server_window_bits
,
48 bool* client_no_context_takeover
,
49 bool* server_no_context_takeover
);
51 bool Inflate(std::string
* message
);
52 bool Deflate(const std::string
& message
, std::string
* output
);
54 scoped_ptr
<WebSocketDeflater
> deflater_
;
55 scoped_ptr
<WebSocketInflater
> inflater_
;
58 DISALLOW_COPY_AND_ASSIGN(WebSocketEncoder
);
63 #endif // NET_SERVER_WEB_SOCKET_ENCODER_H_