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_THUNK_WEBSOCKET_API_H_ | 5 #ifndef PPAPI_THUNK_WEBSOCKET_API_H_ |
6 #define PPAPI_THUNK_WEBSOCKET_API_H_ | 6 #define PPAPI_THUNK_WEBSOCKET_API_H_ |
7 | 7 |
| 8 #include "base/memory/ref_counted.h" |
8 #include "ppapi/c/pp_completion_callback.h" | 9 #include "ppapi/c/pp_completion_callback.h" |
9 #include "ppapi/c/ppb_websocket.h" | 10 #include "ppapi/c/ppb_websocket.h" |
10 | 11 |
11 namespace ppapi { | 12 namespace ppapi { |
| 13 |
| 14 class TrackedCallback; |
| 15 |
12 namespace thunk { | 16 namespace thunk { |
13 | 17 |
14 // Some arguments and attributes are based on The WebSocket Protocol and The | 18 // Some arguments and attributes are based on The WebSocket Protocol and The |
15 // WebSocket API. See also following official specifications. | 19 // WebSocket API. See also following official specifications. |
16 // - The WebSocket Protocol http://tools.ietf.org/html/rfc6455 | 20 // - The WebSocket Protocol http://tools.ietf.org/html/rfc6455 |
17 // - The WebSocket API http://dev.w3.org/html5/websockets/ | 21 // - The WebSocket API http://dev.w3.org/html5/websockets/ |
18 class PPB_WebSocket_API { | 22 class PPB_WebSocket_API { |
19 public: | 23 public: |
20 virtual ~PPB_WebSocket_API() {} | 24 virtual ~PPB_WebSocket_API() {} |
21 | 25 |
22 // Connects to the specified WebSocket server with |protocols| argument | 26 // Connects to the specified WebSocket server with |protocols| argument |
23 // defined by the WebSocket API. Returns an int32_t error code from | 27 // defined by the WebSocket API. Returns an int32_t error code from |
24 // pp_errors.h. | 28 // pp_errors.h. |
25 virtual int32_t Connect(PP_Var url, | 29 virtual int32_t Connect(PP_Var url, |
26 const PP_Var protocols[], | 30 const PP_Var protocols[], |
27 uint32_t protocol_count, | 31 uint32_t protocol_count, |
28 PP_CompletionCallback callback) = 0; | 32 scoped_refptr<TrackedCallback> callback) = 0; |
29 | 33 |
30 // Closes the established connection with specified |code| and |reason|. | 34 // Closes the established connection with specified |code| and |reason|. |
31 // Returns an int32_t error code from pp_errors.h. | 35 // Returns an int32_t error code from pp_errors.h. |
32 virtual int32_t Close(uint16_t code, | 36 virtual int32_t Close(uint16_t code, |
33 PP_Var reason, | 37 PP_Var reason, |
34 PP_CompletionCallback callback) = 0; | 38 scoped_refptr<TrackedCallback> callback) = 0; |
35 | 39 |
36 // Receives a message from the WebSocket server. Caller must keep specified | 40 // Receives a message from the WebSocket server. Caller must keep specified |
37 // |message| object as valid until completion callback is invoked. Returns an | 41 // |message| object as valid until completion callback is invoked. Returns an |
38 // int32_t error code from pp_errors.h. | 42 // int32_t error code from pp_errors.h. |
39 virtual int32_t ReceiveMessage(PP_Var* message, | 43 virtual int32_t ReceiveMessage(PP_Var* message, |
40 PP_CompletionCallback callback) = 0; | 44 scoped_refptr<TrackedCallback> callback) = 0; |
41 | 45 |
42 // Sends a message to the WebSocket server. Returns an int32_t error code | 46 // Sends a message to the WebSocket server. Returns an int32_t error code |
43 // from pp_errors.h. | 47 // from pp_errors.h. |
44 virtual int32_t SendMessage(PP_Var message) = 0; | 48 virtual int32_t SendMessage(PP_Var message) = 0; |
45 | 49 |
46 // Returns the bufferedAmount attribute of The WebSocket API. | 50 // Returns the bufferedAmount attribute of The WebSocket API. |
47 virtual uint64_t GetBufferedAmount() = 0; | 51 virtual uint64_t GetBufferedAmount() = 0; |
48 | 52 |
49 // Returns the CloseEvent code attribute of The WebSocket API. Returned code | 53 // Returns the CloseEvent code attribute of The WebSocket API. Returned code |
50 // is valid if the connection is already closed and wasClean attribute is | 54 // is valid if the connection is already closed and wasClean attribute is |
(...skipping 19 matching lines...) Expand all Loading... |
70 virtual PP_WebSocketReadyState GetReadyState() = 0; | 74 virtual PP_WebSocketReadyState GetReadyState() = 0; |
71 | 75 |
72 // Returns the url attribute of The WebSocket API. | 76 // Returns the url attribute of The WebSocket API. |
73 virtual PP_Var GetURL() = 0; | 77 virtual PP_Var GetURL() = 0; |
74 }; | 78 }; |
75 | 79 |
76 } // namespace thunk | 80 } // namespace thunk |
77 } // namespace ppapi | 81 } // namespace ppapi |
78 | 82 |
79 #endif // PPAPI_THUNK_WEBSOCKET_API_H_ | 83 #endif // PPAPI_THUNK_WEBSOCKET_API_H_ |
OLD | NEW |