Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: webkit/plugins/ppapi/ppb_websocket_impl.h

Issue 8558017: WebSocket Pepper API: in process API implementation (reland) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test too Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_websocket.cc ('k') | webkit/plugins/ppapi/ppb_websocket_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 WEBKIT_PLUGINS_PPAPI_PPB_WEBSOCKET_IMPL_H_ 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_WEBSOCKET_IMPL_H_
6 #define WEBKIT_PLUGINS_PPAPI_PPB_WEBSOCKET_IMPL_H_ 6 #define WEBKIT_PLUGINS_PPAPI_PPB_WEBSOCKET_IMPL_H_
7 7
8 #include <queue>
9
10 #include "base/memory/scoped_ptr.h"
8 #include "ppapi/shared_impl/resource.h" 11 #include "ppapi/shared_impl/resource.h"
9 #include "ppapi/thunk/ppb_websocket_api.h" 12 #include "ppapi/thunk/ppb_websocket_api.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSocketClient.h"
14
15 struct PPB_Var;
16
17 namespace ppapi {
18 class StringVar;
19 }
20
21 namespace WebKit {
22 class WebSocket;
23 }
10 24
11 namespace webkit { 25 namespace webkit {
12 namespace ppapi { 26 namespace ppapi {
13 27
14 // All implementation is in this class for now. We should move some common 28 // All implementation is in this class for now. We should move some common
15 // implementation to shared_impl when we implement proxy interfaces. 29 // implementation to shared_impl when we implement proxy interfaces.
16 class PPB_WebSocket_Impl : public ::ppapi::Resource, 30 class PPB_WebSocket_Impl : public ::ppapi::Resource,
17 public ::ppapi::thunk::PPB_WebSocket_API { 31 public ::ppapi::thunk::PPB_WebSocket_API,
32 public ::WebKit::WebSocketClient {
18 public: 33 public:
19 explicit PPB_WebSocket_Impl(PP_Instance instance); 34 explicit PPB_WebSocket_Impl(PP_Instance instance);
20 virtual ~PPB_WebSocket_Impl(); 35 virtual ~PPB_WebSocket_Impl();
21 36
22 static PP_Resource Create(PP_Instance instance); 37 static PP_Resource Create(PP_Instance instance);
23 38
24 // Resource overrides. 39 // Resource overrides.
25 virtual ::ppapi::thunk::PPB_WebSocket_API* AsPPB_WebSocket_API() OVERRIDE; 40 virtual ::ppapi::thunk::PPB_WebSocket_API* AsPPB_WebSocket_API() OVERRIDE;
26 41
27 // PPB_WebSocket_API implementation. 42 // PPB_WebSocket_API implementation.
28 virtual int32_t Connect(PP_Var url, 43 virtual int32_t Connect(PP_Var url,
29 const PP_Var protocols[], 44 const PP_Var protocols[],
30 uint32_t protocol_count, 45 uint32_t protocol_count,
31 PP_CompletionCallback callback) OVERRIDE; 46 PP_CompletionCallback callback) OVERRIDE;
32 virtual int32_t Close(uint16_t code, 47 virtual int32_t Close(uint16_t code,
33 PP_Var reason, 48 PP_Var reason,
34 PP_CompletionCallback callback) OVERRIDE; 49 PP_CompletionCallback callback) OVERRIDE;
35 virtual int32_t ReceiveMessage(PP_Var* message, 50 virtual int32_t ReceiveMessage(PP_Var* message,
36 PP_CompletionCallback callbac) OVERRIDE; 51 PP_CompletionCallback callbac) OVERRIDE;
37 virtual int32_t SendMessage(PP_Var message) OVERRIDE; 52 virtual int32_t SendMessage(PP_Var message) OVERRIDE;
38 virtual uint64_t GetBufferedAmount() OVERRIDE; 53 virtual uint64_t GetBufferedAmount() OVERRIDE;
39 virtual uint16_t GetCloseCode() OVERRIDE; 54 virtual uint16_t GetCloseCode() OVERRIDE;
40 virtual PP_Var GetCloseReason() OVERRIDE; 55 virtual PP_Var GetCloseReason() OVERRIDE;
41 virtual PP_Bool GetCloseWasClean() OVERRIDE; 56 virtual PP_Bool GetCloseWasClean() OVERRIDE;
42 virtual PP_Var GetExtensions() OVERRIDE; 57 virtual PP_Var GetExtensions() OVERRIDE;
43 virtual PP_Var GetProtocol() OVERRIDE; 58 virtual PP_Var GetProtocol() OVERRIDE;
44 virtual PP_WebSocketReadyState_Dev GetReadyState() OVERRIDE; 59 virtual PP_WebSocketReadyState_Dev GetReadyState() OVERRIDE;
45 virtual PP_Var GetURL() OVERRIDE; 60 virtual PP_Var GetURL() OVERRIDE;
46 61
62 // WebSocketClient implementation.
63 virtual void didConnect() OVERRIDE;
64 virtual void didReceiveMessage(const WebKit::WebString& message) OVERRIDE;
65 virtual void didReceiveBinaryData(
66 const WebKit::WebData& binaryData) OVERRIDE;
67 virtual void didReceiveMessageError() OVERRIDE;
68 virtual void didStartClosingHandshake() OVERRIDE;
69 virtual void didClose(unsigned long bufferedAmount,
70 ClosingHandshakeCompletionStatus status,
71 unsigned short code,
72 const WebKit::WebString& reason) OVERRIDE;
73 private:
74 int32_t DoReceive();
75
76 scoped_ptr<WebKit::WebSocket> websocket_;
77 PP_WebSocketReadyState_Dev state_;
78
79 PP_CompletionCallback connect_callback_;
80
81 PP_CompletionCallback receive_callback_;
82 PP_Var* receive_callback_var_;
83 bool wait_for_receive_;
84 // TODO(toyoshim): Use std::queue<Var> when it supports binary.
85 std::queue<PP_Var> received_messages_;
86
87 PP_CompletionCallback close_callback_;
88 uint16_t close_code_;
89 scoped_refptr< ::ppapi::StringVar> close_reason_;
90 PP_Bool close_was_clean_;
91
92 scoped_refptr< ::ppapi::StringVar> empty_string_;
93 scoped_refptr< ::ppapi::StringVar> extensions_;
94 scoped_refptr< ::ppapi::StringVar> protocol_;
95 scoped_refptr< ::ppapi::StringVar> url_;
96
47 DISALLOW_COPY_AND_ASSIGN(PPB_WebSocket_Impl); 97 DISALLOW_COPY_AND_ASSIGN(PPB_WebSocket_Impl);
48 }; 98 };
49 99
50 } // namespace ppapi 100 } // namespace ppapi
51 } // namespace webkit 101 } // namespace webkit
52 102
53 #endif // WEBKIT_PLUGINS_PPAPI_PPB_WEBSOCKET_IMPL_H_ 103 #endif // WEBKIT_PLUGINS_PPAPI_PPB_WEBSOCKET_IMPL_H_
OLDNEW
« no previous file with comments | « ppapi/tests/test_websocket.cc ('k') | webkit/plugins/ppapi/ppb_websocket_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698