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/WebString.h"
17 #include "third_party/WebKit/public/platform/WebURL.h"
18 #include "third_party/WebKit/public/platform/WebVector.h"
22 class WebSocketBridge
: public blink::WebSocketHandle
{
26 // Handles an IPC message from the browser process.
27 bool OnMessageReceived(const IPC::Message
& message
);
29 // WebSocketHandle functions.
30 virtual void connect(const blink::WebURL
& url
,
31 const blink::WebVector
<blink::WebString
>& protocols
,
32 const blink::WebString
& origin
,
33 blink::WebSocketHandleClient
* client
) OVERRIDE
;
34 virtual void send(bool fin
,
35 WebSocketHandle::MessageType type
,
37 size_t size
) OVERRIDE
;
38 virtual void flowControl(int64_t quota
) OVERRIDE
;
39 virtual void close(unsigned short code
,
40 const blink::WebString
& reason
) OVERRIDE
;
42 virtual void Disconnect();
45 virtual ~WebSocketBridge();
47 void DidConnect(bool fail
,
48 const std::string
& selected_protocol
,
49 const std::string
& extensions
);
50 void DidStartOpeningHandshake(const WebSocketHandshakeRequest
& request
);
51 void DidFinishOpeningHandshake(const WebSocketHandshakeResponse
& response
);
52 void DidFail(const std::string
& message
);
53 void DidReceiveData(bool fin
,
54 WebSocketMessageType type
,
55 const std::vector
<char>& data
);
56 void DidReceiveFlowControl(int64_t quota
);
57 void DidClose(bool was_clean
, unsigned short code
, const std::string
& reason
);
58 void DidStartClosingHandshake();
61 blink::WebSocketHandleClient
* client_
;
63 static const int kInvalidChannelId
= -1;
66 } // namespace content
68 #endif // CONTENT_CHILD_WEBSOCKET_BRIDGE_H_