Land Recent QUIC Changes.
[chromium-blink-merge.git] / net / server / web_socket.h
blob49ced84ee6de03980ed90ad855d30db73f2b15ad
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"
12 namespace net {
14 class HttpConnection;
15 class HttpServerRequestInfo;
17 class WebSocket {
18 public:
19 enum ParseResult {
20 FRAME_OK,
21 FRAME_INCOMPLETE,
22 FRAME_CLOSE,
23 FRAME_ERROR
26 static WebSocket* CreateWebSocket(HttpConnection* connection,
27 const HttpServerRequestInfo& request,
28 size_t* pos);
30 static ParseResult DecodeFrameHybi17(const std::string& frame,
31 bool client_frame,
32 int* bytes_consumed,
33 std::string* output);
35 static std::string EncodeFrameHybi17(const std::string& data,
36 int masking_key);
38 virtual void Accept(const HttpServerRequestInfo& request) = 0;
39 virtual ParseResult Read(std::string* message) = 0;
40 virtual void Send(const std::string& message) = 0;
41 virtual ~WebSocket() {}
43 protected:
44 explicit WebSocket(HttpConnection* connection);
45 HttpConnection* connection_;
47 private:
48 DISALLOW_COPY_AND_ASSIGN(WebSocket);
51 } // namespace net
53 #endif // NET_SERVER_WEB_SOCKET_H_