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