OLD | NEW |
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> | 8 #include <queue> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 virtual PP_WebSocketReadyState_Dev GetReadyState() OVERRIDE; | 59 virtual PP_WebSocketReadyState_Dev GetReadyState() OVERRIDE; |
60 virtual PP_Var GetURL() OVERRIDE; | 60 virtual PP_Var GetURL() OVERRIDE; |
61 | 61 |
62 // WebSocketClient implementation. | 62 // WebSocketClient implementation. |
63 virtual void didConnect() OVERRIDE; | 63 virtual void didConnect() OVERRIDE; |
64 virtual void didReceiveMessage(const WebKit::WebString& message) OVERRIDE; | 64 virtual void didReceiveMessage(const WebKit::WebString& message) OVERRIDE; |
65 virtual void didReceiveBinaryData( | 65 virtual void didReceiveBinaryData( |
66 const WebKit::WebData& binaryData) OVERRIDE; | 66 const WebKit::WebData& binaryData) OVERRIDE; |
67 virtual void didReceiveMessageError() OVERRIDE; | 67 virtual void didReceiveMessageError() OVERRIDE; |
68 // TODO(toyoshim): Add OVERRIDE after landing WebKit side change. | 68 // TODO(toyoshim): Add OVERRIDE after landing WebKit side change. |
69 virtual void didUpdateBufferedAmount(unsigned long bufferedAmount); | 69 virtual void didUpdateBufferedAmount(unsigned long buffered_amount); |
70 virtual void didStartClosingHandshake() OVERRIDE; | 70 virtual void didStartClosingHandshake() OVERRIDE; |
71 virtual void didClose(unsigned long bufferedAmount, | 71 virtual void didClose(unsigned long buffered_amount, |
72 ClosingHandshakeCompletionStatus status, | 72 ClosingHandshakeCompletionStatus status, |
73 unsigned short code, | 73 unsigned short code, |
74 const WebKit::WebString& reason) OVERRIDE; | 74 const WebKit::WebString& reason) OVERRIDE; |
75 private: | 75 private: |
76 int32_t DoReceive(); | 76 int32_t DoReceive(); |
| 77 uint64_t GetFrameSize(uint64_t payload_size); |
| 78 uint64_t SaturateAdd(uint64_t a, uint64_t b); |
77 | 79 |
78 scoped_ptr<WebKit::WebSocket> websocket_; | 80 scoped_ptr<WebKit::WebSocket> websocket_; |
79 PP_WebSocketReadyState_Dev state_; | 81 PP_WebSocketReadyState_Dev state_; |
80 | 82 |
81 PP_CompletionCallback connect_callback_; | 83 PP_CompletionCallback connect_callback_; |
82 | 84 |
83 PP_CompletionCallback receive_callback_; | 85 PP_CompletionCallback receive_callback_; |
84 PP_Var* receive_callback_var_; | 86 PP_Var* receive_callback_var_; |
85 bool wait_for_receive_; | 87 bool wait_for_receive_; |
86 // TODO(toyoshim): Use std::queue<Var> when it supports binary. | 88 // TODO(toyoshim): Use std::queue<Var> when it supports binary. |
87 std::queue<PP_Var> received_messages_; | 89 std::queue<PP_Var> received_messages_; |
88 | 90 |
89 PP_CompletionCallback close_callback_; | 91 PP_CompletionCallback close_callback_; |
90 uint16_t close_code_; | 92 uint16_t close_code_; |
91 scoped_refptr< ::ppapi::StringVar> close_reason_; | 93 scoped_refptr< ::ppapi::StringVar> close_reason_; |
92 PP_Bool close_was_clean_; | 94 PP_Bool close_was_clean_; |
93 | 95 |
94 scoped_refptr< ::ppapi::StringVar> empty_string_; | 96 scoped_refptr< ::ppapi::StringVar> empty_string_; |
95 scoped_refptr< ::ppapi::StringVar> extensions_; | 97 scoped_refptr< ::ppapi::StringVar> extensions_; |
96 scoped_refptr< ::ppapi::StringVar> protocol_; | 98 scoped_refptr< ::ppapi::StringVar> protocol_; |
97 scoped_refptr< ::ppapi::StringVar> url_; | 99 scoped_refptr< ::ppapi::StringVar> url_; |
98 | 100 |
| 101 uint64_t buffered_amount_; |
| 102 uint64_t buffered_amount_after_close_; |
| 103 |
99 DISALLOW_COPY_AND_ASSIGN(PPB_WebSocket_Impl); | 104 DISALLOW_COPY_AND_ASSIGN(PPB_WebSocket_Impl); |
100 }; | 105 }; |
101 | 106 |
102 } // namespace ppapi | 107 } // namespace ppapi |
103 } // namespace webkit | 108 } // namespace webkit |
104 | 109 |
105 #endif // WEBKIT_PLUGINS_PPAPI_PPB_WEBSOCKET_IMPL_H_ | 110 #endif // WEBKIT_PLUGINS_PPAPI_PPB_WEBSOCKET_IMPL_H_ |
OLD | NEW |