| OLD | NEW |
| (Empty) | |
| 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. |
| 4 |
| 5 #ifndef CONTENT_CHILD_WEBSOCKET_BRIDGE_H_ |
| 6 #define CONTENT_CHILD_WEBSOCKET_BRIDGE_H_ |
| 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 13 #include "content/common/websocket.h" |
| 14 #include "ipc/ipc_message.h" |
| 15 #include "third_party/WebKit/public/platform/WebVector.h" |
| 16 #include "third_party/WebKit/public/platform/modules/websockets/WebSocketHandle.
h" |
| 17 |
| 18 namespace blink { |
| 19 class WebSecurityOrigin; |
| 20 class WebString; |
| 21 class WebURL; |
| 22 } // namespace blink |
| 23 |
| 24 namespace content { |
| 25 |
| 26 class WebSocketBridge : public blink::WebSocketHandle { |
| 27 public: |
| 28 WebSocketBridge(); |
| 29 |
| 30 // Handles an IPC message from the browser process. |
| 31 bool OnMessageReceived(const IPC::Message& message); |
| 32 |
| 33 // WebSocketHandle functions. |
| 34 void connect(const blink::WebURL& url, |
| 35 const blink::WebVector<blink::WebString>& protocols, |
| 36 const blink::WebSecurityOrigin& origin, |
| 37 const blink::WebURL& first_party_for_cookies, |
| 38 const blink::WebString& user_agent_override, |
| 39 blink::WebSocketHandleClient* client) override; |
| 40 void send(bool fin, |
| 41 WebSocketHandle::MessageType type, |
| 42 const char* data, |
| 43 size_t size) override; |
| 44 void flowControl(int64_t quota) override; |
| 45 void close(unsigned short code, const blink::WebString& reason) override; |
| 46 |
| 47 void Disconnect(); |
| 48 |
| 49 void set_render_frame_id(int id) { |
| 50 render_frame_id_ = id; |
| 51 } |
| 52 |
| 53 private: |
| 54 ~WebSocketBridge() override; |
| 55 |
| 56 void DidConnect(const std::string& selected_protocol, |
| 57 const std::string& extensions); |
| 58 void DidStartOpeningHandshake(const WebSocketHandshakeRequest& request); |
| 59 void DidFinishOpeningHandshake(const WebSocketHandshakeResponse& response); |
| 60 void DidFail(const std::string& message); |
| 61 void DidReceiveData(bool fin, |
| 62 WebSocketMessageType type, |
| 63 const std::vector<char>& data); |
| 64 void DidReceiveFlowControl(int64_t quota); |
| 65 void DidClose(bool was_clean, unsigned short code, const std::string& reason); |
| 66 void DidStartClosingHandshake(); |
| 67 |
| 68 int channel_id_; |
| 69 int render_frame_id_; |
| 70 blink::WebSocketHandleClient* client_; |
| 71 |
| 72 static const int kInvalidChannelId = -1; |
| 73 }; |
| 74 |
| 75 } // namespace content |
| 76 |
| 77 #endif // CONTENT_CHILD_WEBSOCKET_BRIDGE_H_ |
| OLD | NEW |