Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / net / server / web_socket.h
blob5a13fdc54bb6d0c54d6a0387cdcaadfeb5f69d2a
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_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string_piece.h"
14 namespace net {
16 class HttpConnection;
17 class HttpServer;
18 class HttpServerRequestInfo;
19 class WebSocketEncoder;
21 class WebSocket final {
22 public:
23 enum ParseResult {
24 FRAME_OK,
25 FRAME_INCOMPLETE,
26 FRAME_CLOSE,
27 FRAME_ERROR
30 static WebSocket* CreateWebSocket(HttpServer* server,
31 HttpConnection* connection,
32 const HttpServerRequestInfo& request);
34 void Accept(const HttpServerRequestInfo& request);
35 ParseResult Read(std::string* message);
36 void Send(const std::string& message);
37 ~WebSocket();
39 private:
40 WebSocket(HttpServer* server,
41 HttpConnection* connection,
42 const HttpServerRequestInfo& request);
44 HttpServer* const server_;
45 HttpConnection* const connection_;
46 scoped_ptr<WebSocketEncoder> encoder_;
47 std::string response_extensions_;
48 bool closed_;
50 DISALLOW_COPY_AND_ASSIGN(WebSocket);
53 } // namespace net
55 #endif // NET_SERVER_WEB_SOCKET_H_