1 // Copyright (c) 2012 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_H_
6 #define NET_SERVER_WEB_SOCKET_H_
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string_piece.h"
18 class HttpServerRequestInfo
;
19 class WebSocketEncoder
;
21 class WebSocket final
{
30 static scoped_ptr
<WebSocket
> CreateWebSocket(
32 HttpConnection
* connection
,
33 const HttpServerRequestInfo
& request
);
35 void Accept(const HttpServerRequestInfo
& request
);
36 ParseResult
Read(std::string
* message
);
37 void Send(const std::string
& message
);
41 WebSocket(HttpServer
* server
,
42 HttpConnection
* connection
,
43 const HttpServerRequestInfo
& request
);
45 HttpServer
* const server_
;
46 HttpConnection
* const connection_
;
47 scoped_ptr
<WebSocketEncoder
> encoder_
;
48 std::string response_extensions_
;
51 DISALLOW_COPY_AND_ASSIGN(WebSocket
);
56 #endif // NET_SERVER_WEB_SOCKET_H_