Add a FrameHostMsg_BeginNavigation IPC
[chromium-blink-merge.git] / content / browser / renderer_host / websocket_host.h
blob21c77dcbbd558fe56d77ca147f3e60f208875779
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_
8 #include <string>
9 #include <vector>
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_export.h"
13 #include "content/common/websocket.h"
15 class GURL;
17 namespace url {
18 class Origin;
19 } // namespace url
21 namespace net {
22 class WebSocketChannel;
23 class URLRequestContext;
24 } // namespace net
26 namespace IPC {
27 class Message;
28 } // namespace IPC
30 namespace content {
32 class WebSocketDispatcherHost;
34 // Host of net::WebSocketChannel. The lifetime of an instance of this class is
35 // completely controlled by the WebSocketDispatcherHost object.
36 class CONTENT_EXPORT WebSocketHost {
37 public:
38 WebSocketHost(int routing_id,
39 WebSocketDispatcherHost* dispatcher,
40 net::URLRequestContext* url_request_context);
41 virtual ~WebSocketHost();
43 // General message dispatch. WebSocketDispatcherHost::OnMessageReceived
44 // delegates to this method after looking up the |routing_id|.
45 virtual bool OnMessageReceived(const IPC::Message& message);
47 private:
48 // Handlers for each message type, dispatched by OnMessageReceived(), as
49 // defined in content/common/websocket_messages.h
51 void OnAddChannelRequest(const GURL& socket_url,
52 const std::vector<std::string>& requested_protocols,
53 const url::Origin& origin,
54 int render_frame_id);
56 void OnSendFrame(bool fin,
57 WebSocketMessageType type,
58 const std::vector<char>& data);
60 void OnFlowControl(int64 quota);
62 void OnDropChannel(bool was_clean, uint16 code, const std::string& reason);
64 // The channel we use to send events to the network.
65 scoped_ptr<net::WebSocketChannel> channel_;
67 // The WebSocketHostDispatcher that created this object.
68 WebSocketDispatcherHost* const dispatcher_;
70 // The URL request context for the channel.
71 net::URLRequestContext* const url_request_context_;
73 // The ID used to route messages.
74 const int routing_id_;
76 DISALLOW_COPY_AND_ASSIGN(WebSocketHost);
79 } // namespace content
81 #endif // CONTENT_BROWSER_RENDERER_HOST_WEBSOCKET_HOST_H_