summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi/ppb_websocket_impl.h
diff options
context:
space:
mode:
authortoyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-25 14:50:58 +0000
committertoyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-25 14:50:58 +0000
commit3138146004b13a2f1a249da15531d96a53f3e2d2 (patch)
tree5adf3ed0d951b465a7bb9d6d914773bb9089a1b1 /webkit/plugins/ppapi/ppb_websocket_impl.h
parent9da4b1b94613562bf00cb3bc4a0b80af3c2fdc94 (diff)
downloadchromium_src-3138146004b13a2f1a249da15531d96a53f3e2d2.zip
chromium_src-3138146004b13a2f1a249da15531d96a53f3e2d2.tar.gz
chromium_src-3138146004b13a2f1a249da15531d96a53f3e2d2.tar.bz2
WebSocket Pepper API: in process API implementation
This change enable in process Websocket Pepper API. For now, some unit tests are disabled because they need external a WebSocket server. These disabled tests run manually with external pywebsocket and --gtest_also_run_disabled_tests flag as follows. These tests will enabled in a few days. TBR=dmichael@chromium.org BUG=87310 TEST=ui_tests --gtest_filter='PPAPITest.WebSocket*' Review URL: http://codereview.chromium.org/8558017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111596 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi/ppb_websocket_impl.h')
-rw-r--r--webkit/plugins/ppapi/ppb_websocket_impl.h52
1 files changed, 51 insertions, 1 deletions
diff --git a/webkit/plugins/ppapi/ppb_websocket_impl.h b/webkit/plugins/ppapi/ppb_websocket_impl.h
index a966171..7ae430b 100644
--- a/webkit/plugins/ppapi/ppb_websocket_impl.h
+++ b/webkit/plugins/ppapi/ppb_websocket_impl.h
@@ -5,8 +5,22 @@
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_WEBSOCKET_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_WEBSOCKET_IMPL_H_
+#include <queue>
+
+#include "base/memory/scoped_ptr.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/thunk/ppb_websocket_api.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSocketClient.h"
+
+struct PPB_Var;
+
+namespace ppapi {
+class StringVar;
+}
+
+namespace WebKit {
+class WebSocket;
+}
namespace webkit {
namespace ppapi {
@@ -14,7 +28,8 @@ namespace ppapi {
// All implementation is in this class for now. We should move some common
// implementation to shared_impl when we implement proxy interfaces.
class PPB_WebSocket_Impl : public ::ppapi::Resource,
- public ::ppapi::thunk::PPB_WebSocket_API {
+ public ::ppapi::thunk::PPB_WebSocket_API,
+ public ::WebKit::WebSocketClient {
public:
explicit PPB_WebSocket_Impl(PP_Instance instance);
virtual ~PPB_WebSocket_Impl();
@@ -44,6 +59,41 @@ class PPB_WebSocket_Impl : public ::ppapi::Resource,
virtual PP_WebSocketReadyState_Dev GetReadyState() OVERRIDE;
virtual PP_Var GetURL() OVERRIDE;
+ // WebSocketClient implementation.
+ virtual void didConnect() OVERRIDE;
+ virtual void didReceiveMessage(const WebKit::WebString& message) OVERRIDE;
+ virtual void didReceiveBinaryData(
+ const WebKit::WebData& binaryData) OVERRIDE;
+ virtual void didReceiveMessageError() OVERRIDE;
+ virtual void didStartClosingHandshake() OVERRIDE;
+ virtual void didClose(unsigned long bufferedAmount,
+ ClosingHandshakeCompletionStatus status,
+ unsigned short code,
+ const WebKit::WebString& reason) OVERRIDE;
+ private:
+ int32_t DoReceive();
+
+ scoped_ptr<WebKit::WebSocket> websocket_;
+ PP_WebSocketReadyState_Dev state_;
+
+ PP_CompletionCallback connect_callback_;
+
+ PP_CompletionCallback receive_callback_;
+ PP_Var* receive_callback_var_;
+ bool wait_for_receive_;
+ // TODO(toyoshim): Use std::queue<Var> when it supports binary.
+ std::queue<PP_Var> received_messages_;
+
+ PP_CompletionCallback close_callback_;
+ uint16_t close_code_;
+ scoped_refptr< ::ppapi::StringVar> close_reason_;
+ PP_Bool close_was_clean_;
+
+ scoped_refptr< ::ppapi::StringVar> empty_string_;
+ scoped_refptr< ::ppapi::StringVar> extensions_;
+ scoped_refptr< ::ppapi::StringVar> protocol_;
+ scoped_refptr< ::ppapi::StringVar> url_;
+
DISALLOW_COPY_AND_ASSIGN(PPB_WebSocket_Impl);
};