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

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

Issue 8698007: Revert r111596 "WebSocket Pepper API: in process API implementation" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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"
11 #include "ppapi/shared_impl/resource.h" 8 #include "ppapi/shared_impl/resource.h"
12 #include "ppapi/thunk/ppb_websocket_api.h" 9 #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 }
24 10
25 namespace webkit { 11 namespace webkit {
26 namespace ppapi { 12 namespace ppapi {
27 13
28 // All implementation is in this class for now. We should move some common 14 // All implementation is in this class for now. We should move some common
29 // implementation to shared_impl when we implement proxy interfaces. 15 // implementation to shared_impl when we implement proxy interfaces.
30 class PPB_WebSocket_Impl : public ::ppapi::Resource, 16 class PPB_WebSocket_Impl : public ::ppapi::Resource,
31 public ::ppapi::thunk::PPB_WebSocket_API, 17 public ::ppapi::thunk::PPB_WebSocket_API {
32 public ::WebKit::WebSocketClient {
33 public: 18 public:
34 explicit PPB_WebSocket_Impl(PP_Instance instance); 19 explicit PPB_WebSocket_Impl(PP_Instance instance);
35 virtual ~PPB_WebSocket_Impl(); 20 virtual ~PPB_WebSocket_Impl();
36 21
37 static PP_Resource Create(PP_Instance instance); 22 static PP_Resource Create(PP_Instance instance);
38 23
39 // Resource overrides. 24 // Resource overrides.
40 virtual ::ppapi::thunk::PPB_WebSocket_API* AsPPB_WebSocket_API() OVERRIDE; 25 virtual ::ppapi::thunk::PPB_WebSocket_API* AsPPB_WebSocket_API() OVERRIDE;
41 26
42 // PPB_WebSocket_API implementation. 27 // PPB_WebSocket_API implementation.
43 virtual int32_t Connect(PP_Var url, 28 virtual int32_t Connect(PP_Var url,
44 const PP_Var protocols[], 29 const PP_Var protocols[],
45 uint32_t protocol_count, 30 uint32_t protocol_count,
46 PP_CompletionCallback callback) OVERRIDE; 31 PP_CompletionCallback callback) OVERRIDE;
47 virtual int32_t Close(uint16_t code, 32 virtual int32_t Close(uint16_t code,
48 PP_Var reason, 33 PP_Var reason,
49 PP_CompletionCallback callback) OVERRIDE; 34 PP_CompletionCallback callback) OVERRIDE;
50 virtual int32_t ReceiveMessage(PP_Var* message, 35 virtual int32_t ReceiveMessage(PP_Var* message,
51 PP_CompletionCallback callbac) OVERRIDE; 36 PP_CompletionCallback callbac) OVERRIDE;
52 virtual int32_t SendMessage(PP_Var message) OVERRIDE; 37 virtual int32_t SendMessage(PP_Var message) OVERRIDE;
53 virtual uint64_t GetBufferedAmount() OVERRIDE; 38 virtual uint64_t GetBufferedAmount() OVERRIDE;
54 virtual uint16_t GetCloseCode() OVERRIDE; 39 virtual uint16_t GetCloseCode() OVERRIDE;
55 virtual PP_Var GetCloseReason() OVERRIDE; 40 virtual PP_Var GetCloseReason() OVERRIDE;
56 virtual PP_Bool GetCloseWasClean() OVERRIDE; 41 virtual PP_Bool GetCloseWasClean() OVERRIDE;
57 virtual PP_Var GetExtensions() OVERRIDE; 42 virtual PP_Var GetExtensions() OVERRIDE;
58 virtual PP_Var GetProtocol() OVERRIDE; 43 virtual PP_Var GetProtocol() OVERRIDE;
59 virtual PP_WebSocketReadyState_Dev GetReadyState() OVERRIDE; 44 virtual PP_WebSocketReadyState_Dev GetReadyState() OVERRIDE;
60 virtual PP_Var GetURL() OVERRIDE; 45 virtual PP_Var GetURL() OVERRIDE;
61 46
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
97 DISALLOW_COPY_AND_ASSIGN(PPB_WebSocket_Impl); 47 DISALLOW_COPY_AND_ASSIGN(PPB_WebSocket_Impl);
98 }; 48 };
99 49
100 } // namespace ppapi 50 } // namespace ppapi
101 } // namespace webkit 51 } // namespace webkit
102 52
103 #endif // WEBKIT_PLUGINS_PPAPI_PPB_WEBSOCKET_IMPL_H_ 53 #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