Chromium Code Reviews| 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 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> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "ppapi/shared_impl/resource.h" | 11 #include "ppapi/shared_impl/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 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSocket.h" | |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSocketClient.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSocketClient.h" |
| 15 | 16 |
| 16 namespace ppapi { | 17 namespace ppapi { |
| 17 class StringVar; | 18 class StringVar; |
| 18 } | 19 class Var; |
| 19 | |
| 20 namespace WebKit { | |
| 21 class WebSocket; | |
| 22 } | 20 } |
| 23 | 21 |
| 24 namespace webkit { | 22 namespace webkit { |
| 25 namespace ppapi { | 23 namespace ppapi { |
| 26 | 24 |
| 27 // All implementation is in this class for now. We should move some common | 25 // All implementation is in this class for now. We should move some common |
| 28 // implementation to shared_impl when we implement proxy interfaces. | 26 // implementation to shared_impl when we implement proxy interfaces. |
| 29 class PPB_WebSocket_Impl : public ::ppapi::Resource, | 27 class PPB_WebSocket_Impl : public ::ppapi::Resource, |
| 30 public ::ppapi::thunk::PPB_WebSocket_API, | 28 public ::ppapi::thunk::PPB_WebSocket_API, |
| 31 public ::WebKit::WebSocketClient { | 29 public ::WebKit::WebSocketClient { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 57 virtual PP_Var GetProtocol() OVERRIDE; | 55 virtual PP_Var GetProtocol() OVERRIDE; |
| 58 virtual PP_WebSocketReadyState_Dev GetReadyState() OVERRIDE; | 56 virtual PP_WebSocketReadyState_Dev GetReadyState() OVERRIDE; |
| 59 virtual PP_Var GetURL() OVERRIDE; | 57 virtual PP_Var GetURL() OVERRIDE; |
| 60 virtual PP_Bool SetBinaryType( | 58 virtual PP_Bool SetBinaryType( |
| 61 PP_WebSocketBinaryType_Dev binary_type) OVERRIDE; | 59 PP_WebSocketBinaryType_Dev binary_type) OVERRIDE; |
| 62 virtual PP_WebSocketBinaryType_Dev GetBinaryType() OVERRIDE; | 60 virtual PP_WebSocketBinaryType_Dev GetBinaryType() OVERRIDE; |
| 63 | 61 |
| 64 // WebSocketClient implementation. | 62 // WebSocketClient implementation. |
| 65 virtual void didConnect(); | 63 virtual void didConnect(); |
| 66 virtual void didReceiveMessage(const WebKit::WebString& message); | 64 virtual void didReceiveMessage(const WebKit::WebString& message); |
| 67 virtual void didReceiveBinaryData(const WebKit::WebData& binaryData); | 65 virtual void didReceiveArrayBuffer(const WebKit::WebArrayBuffer& binaryData); |
| 68 virtual void didReceiveMessageError(); | 66 virtual void didReceiveMessageError(); |
| 69 virtual void didUpdateBufferedAmount(unsigned long buffered_amount); | 67 virtual void didUpdateBufferedAmount(unsigned long buffered_amount); |
| 70 virtual void didStartClosingHandshake(); | 68 virtual void didStartClosingHandshake(); |
| 71 virtual void didClose(unsigned long unhandled_buffered_amount, | 69 virtual void didClose(unsigned long unhandled_buffered_amount, |
| 72 ClosingHandshakeCompletionStatus status, | 70 ClosingHandshakeCompletionStatus status, |
| 73 unsigned short code, | 71 unsigned short code, |
| 74 const WebKit::WebString& reason); | 72 const WebKit::WebString& reason); |
| 75 private: | 73 private: |
| 76 int32_t DoReceive(); | 74 int32_t DoReceive(); |
| 77 | 75 |
| 78 scoped_ptr<WebKit::WebSocket> websocket_; | 76 scoped_ptr<WebKit::WebSocket> websocket_; |
| 79 PP_WebSocketReadyState_Dev state_; | 77 PP_WebSocketReadyState_Dev state_; |
| 80 PP_WebSocketBinaryType_Dev binary_type_; | 78 WebKit::WebSocket::BinaryType binary_type_; |
| 81 bool error_was_received_; | 79 bool error_was_received_; |
| 82 | 80 |
| 83 scoped_refptr< ::ppapi::TrackedCallback> connect_callback_; | 81 scoped_refptr< ::ppapi::TrackedCallback> connect_callback_; |
| 84 | 82 |
| 85 scoped_refptr< ::ppapi::TrackedCallback> receive_callback_; | 83 scoped_refptr< ::ppapi::TrackedCallback> receive_callback_; |
| 86 PP_Var* receive_callback_var_; | 84 PP_Var* receive_callback_var_; |
| 87 bool wait_for_receive_; | 85 bool wait_for_receive_; |
| 88 // TODO(toyoshim): Use std::queue<Var> when it supports binary. | 86 std::queue< scoped_refptr< ::ppapi::Var>*> received_messages_; |
|
dmichael (off chromium)
2012/01/17 22:14:28
You don't want the * there
Takashi Toyoshima
2012/01/18 12:10:43
Done.
| |
| 89 std::queue<PP_Var> received_messages_; | |
| 90 | 87 |
| 91 scoped_refptr< ::ppapi::TrackedCallback> close_callback_; | 88 scoped_refptr< ::ppapi::TrackedCallback> close_callback_; |
| 92 uint16_t close_code_; | 89 uint16_t close_code_; |
| 93 scoped_refptr< ::ppapi::StringVar> close_reason_; | 90 scoped_refptr< ::ppapi::StringVar> close_reason_; |
| 94 PP_Bool close_was_clean_; | 91 PP_Bool close_was_clean_; |
| 95 | 92 |
| 96 scoped_refptr< ::ppapi::StringVar> empty_string_; | 93 scoped_refptr< ::ppapi::StringVar> empty_string_; |
| 97 scoped_refptr< ::ppapi::StringVar> extensions_; | 94 scoped_refptr< ::ppapi::StringVar> extensions_; |
| 98 scoped_refptr< ::ppapi::StringVar> url_; | 95 scoped_refptr< ::ppapi::StringVar> url_; |
| 99 | 96 |
| 100 uint64_t buffered_amount_; | 97 uint64_t buffered_amount_; |
| 101 uint64_t buffered_amount_after_close_; | 98 uint64_t buffered_amount_after_close_; |
| 102 | 99 |
| 103 DISALLOW_COPY_AND_ASSIGN(PPB_WebSocket_Impl); | 100 DISALLOW_COPY_AND_ASSIGN(PPB_WebSocket_Impl); |
| 104 }; | 101 }; |
| 105 | 102 |
| 106 } // namespace ppapi | 103 } // namespace ppapi |
| 107 } // namespace webkit | 104 } // namespace webkit |
| 108 | 105 |
| 109 #endif // WEBKIT_PLUGINS_PPAPI_PPB_WEBSOCKET_IMPL_H_ | 106 #endif // WEBKIT_PLUGINS_PPAPI_PPB_WEBSOCKET_IMPL_H_ |
| OLD | NEW |