| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_WEBSOCKET_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_WEBSOCKET_HOST_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_WEBSOCKET_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_WEBSOCKET_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "ppapi/host/host_message_context.h" | 16 #include "ppapi/host/host_message_context.h" |
| 17 #include "ppapi/host/resource_host.h" | 17 #include "ppapi/host/resource_host.h" |
| 18 #include "ppapi/proxy/resource_message_params.h" | 18 #include "ppapi/proxy/resource_message_params.h" |
| 19 #include "third_party/WebKit/public/web/WebSocket.h" | 19 #include "third_party/WebKit/public/web/WebPepperSocket.h" |
| 20 #include "third_party/WebKit/public/web/WebSocketClient.h" | 20 #include "third_party/WebKit/public/web/WebPepperSocketClient.h" |
| 21 | 21 |
| 22 namespace ppapi { | 22 namespace ppapi { |
| 23 class StringVar; | 23 class StringVar; |
| 24 class Var; | 24 class Var; |
| 25 } // namespace ppapi | 25 } // namespace ppapi |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 | 28 |
| 29 class RendererPpapiHost; | 29 class RendererPpapiHost; |
| 30 | 30 |
| 31 class CONTENT_EXPORT PepperWebSocketHost | 31 class CONTENT_EXPORT PepperWebSocketHost |
| 32 : public ppapi::host::ResourceHost, | 32 : public ppapi::host::ResourceHost, |
| 33 public NON_EXPORTED_BASE(::blink::WebSocketClient) { | 33 public NON_EXPORTED_BASE(::blink::WebPepperSocketClient) { |
| 34 public: | 34 public: |
| 35 explicit PepperWebSocketHost(RendererPpapiHost* host, | 35 explicit PepperWebSocketHost(RendererPpapiHost* host, |
| 36 PP_Instance instance, | 36 PP_Instance instance, |
| 37 PP_Resource resource); | 37 PP_Resource resource); |
| 38 ~PepperWebSocketHost() override; | 38 ~PepperWebSocketHost() override; |
| 39 | 39 |
| 40 int32_t OnResourceMessageReceived( | 40 int32_t OnResourceMessageReceived( |
| 41 const IPC::Message& msg, | 41 const IPC::Message& msg, |
| 42 ppapi::host::HostMessageContext* context) override; | 42 ppapi::host::HostMessageContext* context) override; |
| 43 | 43 |
| 44 // WebSocketClient implementation. | 44 // WebPepperSocketClient implementation. |
| 45 void didConnect() override; | 45 void didConnect() override; |
| 46 void didReceiveMessage(const blink::WebString& message) override; | 46 void didReceiveMessage(const blink::WebString& message) override; |
| 47 void didReceiveArrayBuffer(const blink::WebArrayBuffer& binaryData) override; | 47 void didReceiveArrayBuffer(const blink::WebArrayBuffer& binaryData) override; |
| 48 void didReceiveMessageError() override; | 48 void didReceiveMessageError() override; |
| 49 void didUpdateBufferedAmount(unsigned long buffered_amount) override; | 49 void didUpdateBufferedAmount(unsigned long buffered_amount) override; |
| 50 void didStartClosingHandshake() override; | 50 void didStartClosingHandshake() override; |
| 51 void didClose(unsigned long unhandled_buffered_amount, | 51 void didClose(unsigned long unhandled_buffered_amount, |
| 52 ClosingHandshakeCompletionStatus status, | 52 ClosingHandshakeCompletionStatus status, |
| 53 unsigned short code, | 53 unsigned short code, |
| 54 const blink::WebString& reason) override; | 54 const blink::WebString& reason) override; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 // A flag to indicate if server initiated closing handshake is performed. | 87 // A flag to indicate if server initiated closing handshake is performed. |
| 88 bool accepting_close_; | 88 bool accepting_close_; |
| 89 | 89 |
| 90 // Becomes true if any error is detected. Incoming data will be disposed | 90 // Becomes true if any error is detected. Incoming data will be disposed |
| 91 // if this variable is true. | 91 // if this variable is true. |
| 92 bool error_was_received_; | 92 bool error_was_received_; |
| 93 | 93 |
| 94 // Keeps the WebKit side WebSocket object. This is used for calling WebKit | 94 // Keeps the WebKit side WebSocket object. This is used for calling WebKit |
| 95 // side functions via WebKit API. | 95 // side functions via WebKit API. |
| 96 scoped_ptr<blink::WebSocket> websocket_; | 96 scoped_ptr<blink::WebPepperSocket> websocket_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(PepperWebSocketHost); | 98 DISALLOW_COPY_AND_ASSIGN(PepperWebSocketHost); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } // namespace content | 101 } // namespace content |
| 102 | 102 |
| 103 #endif // CONTENT_RENDERER_PEPPER_PEPPER_WEBSOCKET_HOST_H_ | 103 #endif // CONTENT_RENDERER_PEPPER_PEPPER_WEBSOCKET_HOST_H_ |
| OLD | NEW |