OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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. |
| 4 |
| 5 #ifndef CONTENT_CHILD_WEBSOCKET_BRIDGE_H_ |
| 6 #define CONTENT_CHILD_WEBSOCKET_BRIDGE_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "content/common/websocket.h" |
| 13 #include "ipc/ipc_message.h" |
| 14 #include "third_party/WebKit/public/platform/WebSocketHandle.h" |
| 15 #include "third_party/WebKit/public/platform/WebString.h" |
| 16 #include "third_party/WebKit/public/platform/WebURL.h" |
| 17 #include "third_party/WebKit/public/platform/WebVector.h" |
| 18 |
| 19 namespace content { |
| 20 |
| 21 class WebSocketBridge : public WebKit::WebSocketHandle { |
| 22 public: |
| 23 WebSocketBridge(); |
| 24 |
| 25 // Handles an IPC message from the browser process. |
| 26 bool OnMessageReceived(const IPC::Message& message); |
| 27 |
| 28 // WebSocketHandle functions. |
| 29 virtual void connect(const WebKit::WebURL& url, |
| 30 const WebKit::WebVector<WebKit::WebString>& protocols, |
| 31 const WebKit::WebString& origin, |
| 32 WebKit::WebSocketHandleClient* client) OVERRIDE; |
| 33 virtual void send(bool fin, |
| 34 WebSocketHandle::MessageType type, |
| 35 const char* data, |
| 36 size_t size) OVERRIDE; |
| 37 virtual void flowControl(int64_t quota) OVERRIDE; |
| 38 virtual void close(unsigned short code, |
| 39 const WebKit::WebString& reason) OVERRIDE; |
| 40 |
| 41 virtual void Disconnect(); |
| 42 |
| 43 private: |
| 44 virtual ~WebSocketBridge(); |
| 45 |
| 46 void DidConnect(bool fail, |
| 47 const std::string& selected_protocol, |
| 48 const std::string& extensions); |
| 49 void DidReceiveData(bool fin, |
| 50 WebSocketMessageType type, |
| 51 const std::vector<char>& data); |
| 52 void DidReceiveFlowControl(int64_t quota); |
| 53 void DidClose(unsigned short code, const std::string& reason); |
| 54 |
| 55 int channel_id_; |
| 56 WebKit::WebSocketHandleClient* client_; |
| 57 |
| 58 static const int kInvalidChannelId = -1; |
| 59 }; |
| 60 |
| 61 } // namespace content |
| 62 |
| 63 #endif // CONTENT_CHILD_WEBSOCKET_BRIDGE_H_ |
OLD | NEW |