Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / content / browser / renderer_host / websocket_host.h
blob39c1e41edbed3d56985f1bba437898bfae234c80
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 // The renderer process is going away.
44 // This function is virtual for testing.
45 virtual void GoAway();
47 // General message dispatch. WebSocketDispatcherHost::OnMessageReceived
48 // delegates to this method after looking up the |routing_id|.
49 virtual bool OnMessageReceived(const IPC::Message& message);
51 int routing_id() const { return routing_id_; }
53 private:
54 // Handlers for each message type, dispatched by OnMessageReceived(), as
55 // defined in content/common/websocket_messages.h
57 void OnAddChannelRequest(const GURL& socket_url,
58 const std::vector<std::string>& requested_protocols,
59 const url::Origin& origin,
60 int render_frame_id);
62 void OnSendFrame(bool fin,
63 WebSocketMessageType type,
64 const std::vector<char>& data);
66 void OnFlowControl(int64 quota);
68 void OnDropChannel(bool was_clean, uint16 code, const std::string& reason);
70 // The channel we use to send events to the network.
71 scoped_ptr<net::WebSocketChannel> channel_;
73 // The WebSocketHostDispatcher that created this object.
74 WebSocketDispatcherHost* const dispatcher_;
76 // The URL request context for the channel.
77 net::URLRequestContext* const url_request_context_;
79 // The ID used to route messages.
80 const int routing_id_;
82 DISALLOW_COPY_AND_ASSIGN(WebSocketHost);
85 } // namespace content
87 #endif // CONTENT_BROWSER_RENDERER_HOST_WEBSOCKET_HOST_H_