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_CHILD_WEBSOCKET_BRIDGE_H_
6 #define CONTENT_CHILD_WEBSOCKET_BRIDGE_H_
12 #include "base/basictypes.h"
13 #include "content/common/websocket.h"
14 #include "ipc/ipc_message.h"
15 #include "third_party/WebKit/public/platform/WebSocketHandle.h"
16 #include "third_party/WebKit/public/platform/WebVector.h"
19 class WebSecurityOrigin
;
26 class WebSocketBridge
: public blink::WebSocketHandle
{
30 // Handles an IPC message from the browser process.
31 bool OnMessageReceived(const IPC::Message
& message
);
33 // WebSocketHandle functions.
34 void connect(const blink::WebURL
& url
,
35 const blink::WebVector
<blink::WebString
>& protocols
,
36 const blink::WebSecurityOrigin
& origin
,
37 blink::WebSocketHandleClient
* client
) override
;
39 WebSocketHandle::MessageType type
,
41 size_t size
) override
;
42 void flowControl(int64_t quota
) override
;
43 void close(unsigned short code
, const blink::WebString
& reason
) override
;
47 void set_render_frame_id(int id
) {
48 render_frame_id_
= id
;
52 ~WebSocketBridge() override
;
54 void DidConnect(const std::string
& selected_protocol
,
55 const std::string
& extensions
);
56 void DidStartOpeningHandshake(const WebSocketHandshakeRequest
& request
);
57 void DidFinishOpeningHandshake(const WebSocketHandshakeResponse
& response
);
58 void DidFail(const std::string
& message
);
59 void DidReceiveData(bool fin
,
60 WebSocketMessageType type
,
61 const std::vector
<char>& data
);
62 void DidReceiveFlowControl(int64_t quota
);
63 void DidClose(bool was_clean
, unsigned short code
, const std::string
& reason
);
64 void DidStartClosingHandshake();
68 blink::WebSocketHandleClient
* client_
;
70 static const int kInvalidChannelId
= -1;
73 } // namespace content
75 #endif // CONTENT_CHILD_WEBSOCKET_BRIDGE_H_