1 // Copyright 2013 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 CONTENT_BROWSER_RENDERER_HOST_WEBSOCKET_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_WEBSOCKET_HOST_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_export.h"
13 #include "content/common/websocket.h"
18 class WebSocketChannel;
19 class URLRequestContext;
28 class WebSocketDispatcherHost;
30 // Host of net::WebSocketChannel. The lifetime of an instance of this class is
31 // completely controlled by the WebSocketDispatcherHost object.
32 class CONTENT_EXPORT WebSocketHost {
34 WebSocketHost(int routing_id,
35 WebSocketDispatcherHost* dispatcher,
36 net::URLRequestContext* url_request_context);
37 virtual ~WebSocketHost();
39 // General message dispatch. WebSocketDispatcherHost::OnMessageReceived
40 // delegates to this method after looking up the |routing_id|.
41 virtual bool OnMessageReceived(const IPC::Message& message,
42 bool* message_was_ok);
45 // Handlers for each message type, dispatched by OnMessageReceived(), as
46 // defined in content/common/websocket_messages.h
48 void OnAddChannelRequest(const GURL& socket_url,
49 const std::vector<std::string>& requested_protocols,
52 void OnSendFrame(bool fin,
53 WebSocketMessageType type,
54 const std::vector<char>& data);
56 void OnFlowControl(int64 quota);
58 void OnDropChannel(uint16 code, const std::string& reason);
60 // The channel we use to send events to the network.
61 scoped_ptr<net::WebSocketChannel> channel_;
63 // The ID used to route messages.
66 DISALLOW_COPY_AND_ASSIGN(WebSocketHost);
69 } // namespace content
71 #endif // CONTENT_BROWSER_RENDERER_HOST_WEBSOCKET_HOST_H_