| 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 <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "ppapi/host/host_message_context.h" | 13 #include "ppapi/host/host_message_context.h" |
| 14 #include "ppapi/host/resource_host.h" | 14 #include "ppapi/host/resource_host.h" |
| 15 #include "ppapi/proxy/resource_message_params.h" | 15 #include "ppapi/proxy/resource_message_params.h" |
| 16 #include "third_party/WebKit/public/web/WebSocket.h" | 16 #include "third_party/WebKit/public/web/WebSocket.h" |
| 17 #include "third_party/WebKit/public/web/WebSocketClient.h" | 17 #include "third_party/WebKit/public/web/WebSocketClient.h" |
| 18 | 18 |
| 19 namespace ppapi { | 19 namespace ppapi { |
| 20 class StringVar; | 20 class StringVar; |
| 21 class Var; | 21 class Var; |
| 22 } // namespace ppapi | 22 } // namespace ppapi |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 class RendererPpapiHost; | 26 class RendererPpapiHost; |
| 27 | 27 |
| 28 class CONTENT_EXPORT PepperWebSocketHost | 28 class CONTENT_EXPORT PepperWebSocketHost |
| 29 : public ppapi::host::ResourceHost, | 29 : public ppapi::host::ResourceHost, |
| 30 public NON_EXPORTED_BASE(::WebKit::WebSocketClient) { | 30 public NON_EXPORTED_BASE(::blink::WebSocketClient) { |
| 31 public: | 31 public: |
| 32 explicit PepperWebSocketHost(RendererPpapiHost* host, | 32 explicit PepperWebSocketHost(RendererPpapiHost* host, |
| 33 PP_Instance instance, | 33 PP_Instance instance, |
| 34 PP_Resource resource); | 34 PP_Resource resource); |
| 35 virtual ~PepperWebSocketHost(); | 35 virtual ~PepperWebSocketHost(); |
| 36 | 36 |
| 37 virtual int32_t OnResourceMessageReceived( | 37 virtual int32_t OnResourceMessageReceived( |
| 38 const IPC::Message& msg, | 38 const IPC::Message& msg, |
| 39 ppapi::host::HostMessageContext* context) OVERRIDE; | 39 ppapi::host::HostMessageContext* context) OVERRIDE; |
| 40 | 40 |
| 41 // WebSocketClient implementation. | 41 // WebSocketClient implementation. |
| 42 virtual void didConnect(); | 42 virtual void didConnect(); |
| 43 virtual void didReceiveMessage(const WebKit::WebString& message); | 43 virtual void didReceiveMessage(const blink::WebString& message); |
| 44 virtual void didReceiveArrayBuffer(const WebKit::WebArrayBuffer& binaryData); | 44 virtual void didReceiveArrayBuffer(const blink::WebArrayBuffer& binaryData); |
| 45 virtual void didReceiveMessageError(); | 45 virtual void didReceiveMessageError(); |
| 46 virtual void didUpdateBufferedAmount(unsigned long buffered_amount); | 46 virtual void didUpdateBufferedAmount(unsigned long buffered_amount); |
| 47 virtual void didStartClosingHandshake(); | 47 virtual void didStartClosingHandshake(); |
| 48 virtual void didClose(unsigned long unhandled_buffered_amount, | 48 virtual void didClose(unsigned long unhandled_buffered_amount, |
| 49 ClosingHandshakeCompletionStatus status, | 49 ClosingHandshakeCompletionStatus status, |
| 50 unsigned short code, | 50 unsigned short code, |
| 51 const WebKit::WebString& reason); | 51 const blink::WebString& reason); |
| 52 private: | 52 private: |
| 53 // IPC message handlers. | 53 // IPC message handlers. |
| 54 int32_t OnHostMsgConnect(ppapi::host::HostMessageContext* context, | 54 int32_t OnHostMsgConnect(ppapi::host::HostMessageContext* context, |
| 55 const std::string& url, | 55 const std::string& url, |
| 56 const std::vector<std::string>& protocols); | 56 const std::vector<std::string>& protocols); |
| 57 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context, | 57 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context, |
| 58 int32_t code, | 58 int32_t code, |
| 59 const std::string& reason); | 59 const std::string& reason); |
| 60 int32_t OnHostMsgSendText(ppapi::host::HostMessageContext* context, | 60 int32_t OnHostMsgSendText(ppapi::host::HostMessageContext* context, |
| 61 const std::string& message); | 61 const std::string& message); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 82 | 82 |
| 83 // A flag to indicate if server initiated closing handshake is performed. | 83 // A flag to indicate if server initiated closing handshake is performed. |
| 84 bool accepting_close_; | 84 bool accepting_close_; |
| 85 | 85 |
| 86 // Becomes true if any error is detected. Incoming data will be disposed | 86 // Becomes true if any error is detected. Incoming data will be disposed |
| 87 // if this variable is true. | 87 // if this variable is true. |
| 88 bool error_was_received_; | 88 bool error_was_received_; |
| 89 | 89 |
| 90 // Keeps the WebKit side WebSocket object. This is used for calling WebKit | 90 // Keeps the WebKit side WebSocket object. This is used for calling WebKit |
| 91 // side functions via WebKit API. | 91 // side functions via WebKit API. |
| 92 scoped_ptr<WebKit::WebSocket> websocket_; | 92 scoped_ptr<blink::WebSocket> websocket_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(PepperWebSocketHost); | 94 DISALLOW_COPY_AND_ASSIGN(PepperWebSocketHost); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace content | 97 } // namespace content |
| 98 | 98 |
| 99 #endif // CONTENT_RENDERER_PEPPER_PEPPER_WEBSOCKET_HOST_H_ | 99 #endif // CONTENT_RENDERER_PEPPER_PEPPER_WEBSOCKET_HOST_H_ |
| OLD | NEW |