| 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 PPAPI_PROXY_WEBSOCKET_RESOURCE_H_ | 5 #ifndef PPAPI_PROXY_WEBSOCKET_RESOURCE_H_ |
| 6 #define PPAPI_PROXY_WEBSOCKET_RESOURCE_H_ | 6 #define PPAPI_PROXY_WEBSOCKET_RESOURCE_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "ppapi/c/ppb_websocket.h" | 10 #include "ppapi/c/ppb_websocket.h" |
| 11 #include "ppapi/proxy/plugin_resource.h" | 11 #include "ppapi/proxy/plugin_resource.h" |
| 12 #include "ppapi/shared_impl/tracked_callback.h" | 12 #include "ppapi/shared_impl/tracked_callback.h" |
| 13 #include "ppapi/thunk/ppb_websocket_api.h" | 13 #include "ppapi/thunk/ppb_websocket_api.h" |
| 14 | 14 |
| 15 namespace ppapi { | 15 namespace ppapi { |
| 16 | 16 |
| 17 class StringVar; | 17 class StringVar; |
| 18 class Var; | 18 class Var; |
| 19 | 19 |
| 20 namespace proxy { | 20 namespace proxy { |
| 21 | 21 |
| 22 // This class contains protocol checks which doesn't affect security when it | 22 // This class contains protocol checks which doesn't affect security when it |
| 23 // run with untrusted code. | 23 // run with untrusted code. |
| 24 class PPAPI_PROXY_EXPORT WebSocketResource | 24 class PPAPI_PROXY_EXPORT WebSocketResource |
| 25 : public PluginResource, | 25 : public PluginResource, |
| 26 public NON_EXPORTED_BASE(thunk::PPB_WebSocket_API) { | 26 public NON_EXPORTED_BASE(thunk::PPB_WebSocket_API) { |
| 27 public: | 27 public: |
| 28 WebSocketResource(Connection connection, PP_Instance instance); | 28 WebSocketResource(Connection connection, PP_Instance instance); |
| 29 virtual ~WebSocketResource(); | 29 ~WebSocketResource() override; |
| 30 | 30 |
| 31 // PluginResource implementation. | 31 // PluginResource implementation. |
| 32 virtual thunk::PPB_WebSocket_API* AsPPB_WebSocket_API() override; | 32 thunk::PPB_WebSocket_API* AsPPB_WebSocket_API() override; |
| 33 | 33 |
| 34 // PPB_WebSocket_API implementation. | 34 // PPB_WebSocket_API implementation. |
| 35 virtual int32_t Connect(const PP_Var& url, | 35 int32_t Connect(const PP_Var& url, |
| 36 const PP_Var protocols[], | 36 const PP_Var protocols[], |
| 37 uint32_t protocol_count, | 37 uint32_t protocol_count, |
| 38 scoped_refptr<TrackedCallback> callback) override; | 38 scoped_refptr<TrackedCallback> callback) override; |
| 39 virtual int32_t Close(uint16_t code, | 39 int32_t Close(uint16_t code, |
| 40 const PP_Var& reason, | 40 const PP_Var& reason, |
| 41 scoped_refptr<TrackedCallback> callback) override; | 41 scoped_refptr<TrackedCallback> callback) override; |
| 42 virtual int32_t ReceiveMessage( | 42 int32_t ReceiveMessage( |
| 43 PP_Var* message, | 43 PP_Var* message, |
| 44 scoped_refptr<TrackedCallback> callback) override; | 44 scoped_refptr<TrackedCallback> callback) override; |
| 45 virtual int32_t SendMessage(const PP_Var& message) override; | 45 int32_t SendMessage(const PP_Var& message) override; |
| 46 virtual uint64_t GetBufferedAmount() override; | 46 uint64_t GetBufferedAmount() override; |
| 47 virtual uint16_t GetCloseCode() override; | 47 uint16_t GetCloseCode() override; |
| 48 virtual PP_Var GetCloseReason() override; | 48 PP_Var GetCloseReason() override; |
| 49 virtual PP_Bool GetCloseWasClean() override; | 49 PP_Bool GetCloseWasClean() override; |
| 50 virtual PP_Var GetExtensions() override; | 50 PP_Var GetExtensions() override; |
| 51 virtual PP_Var GetProtocol() override; | 51 PP_Var GetProtocol() override; |
| 52 virtual PP_WebSocketReadyState GetReadyState() override; | 52 PP_WebSocketReadyState GetReadyState() override; |
| 53 virtual PP_Var GetURL() override; | 53 PP_Var GetURL() override; |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 // PluginResource override. | 56 // PluginResource override. |
| 57 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, | 57 void OnReplyReceived(const ResourceMessageReplyParams& params, |
| 58 const IPC::Message& msg) override; | 58 const IPC::Message& msg) override; |
| 59 | 59 |
| 60 // IPC message handlers. | 60 // IPC message handlers. |
| 61 void OnPluginMsgConnectReply(const ResourceMessageReplyParams& params, | 61 void OnPluginMsgConnectReply(const ResourceMessageReplyParams& params, |
| 62 const std::string& url, | 62 const std::string& url, |
| 63 const std::string& protocol); | 63 const std::string& protocol); |
| 64 void OnPluginMsgCloseReply(const ResourceMessageReplyParams& params, | 64 void OnPluginMsgCloseReply(const ResourceMessageReplyParams& params, |
| 65 unsigned long buffered_amount, | 65 unsigned long buffered_amount, |
| 66 bool was_clean, | 66 bool was_clean, |
| 67 unsigned short code, | 67 unsigned short code, |
| 68 const std::string& reason); | 68 const std::string& reason); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // specification. The calculated value can be read via GetBufferedAmount(). | 148 // specification. The calculated value can be read via GetBufferedAmount(). |
| 149 uint64_t buffered_amount_after_close_; | 149 uint64_t buffered_amount_after_close_; |
| 150 | 150 |
| 151 DISALLOW_COPY_AND_ASSIGN(WebSocketResource); | 151 DISALLOW_COPY_AND_ASSIGN(WebSocketResource); |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 } // namespace proxy | 154 } // namespace proxy |
| 155 } // namespace ppapi | 155 } // namespace ppapi |
| 156 | 156 |
| 157 #endif // PPAPI_PROXY_WEBSOCKET_RESOURCE_H_ | 157 #endif // PPAPI_PROXY_WEBSOCKET_RESOURCE_H_ |
| OLD | NEW |