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 PPAPI_CPP_DEV_WEBSOCKET_DEV_H_ | 5 #ifndef PPAPI_CPP_DEV_WEBSOCKET_DEV_H_ |
6 #define PPAPI_CPP_DEV_WEBSOCKET_DEV_H_ | 6 #define PPAPI_CPP_DEV_WEBSOCKET_DEV_H_ |
7 | 7 |
8 #include "ppapi/c/dev/ppb_websocket_dev.h" | 8 #include "ppapi/c/dev/ppb_websocket_dev.h" |
9 #include "ppapi/cpp/resource.h" | |
9 | 10 |
10 /// @file | 11 /// @file |
11 /// This file defines the WebSocket_Dev interface. | 12 /// This file defines the WebSocket_Dev interface. |
12 | 13 |
13 namespace pp { | 14 namespace pp { |
14 | 15 |
16 class CompletionCallback; | |
17 class Instance; | |
15 class Var; | 18 class Var; |
16 | 19 |
17 /// The <code>WebSocket_Dev</code> class | 20 /// The <code>WebSocket_Dev</code> class |
18 /// A version that use virtual functions | 21 /// A version that use virtual functions |
19 class WebSocket_Dev : public Resource { | 22 class WebSocket_Dev : public Resource { |
20 public: | 23 public: |
21 /// Constructs a WebSocket_Dev object. | 24 /// Constructs a WebSocket_Dev object. |
22 WebSocket_Dev(); | 25 WebSocket_Dev(Instance* instance); |
23 | 26 |
24 /// Destructs a WebSocket_Dev object. | 27 /// Destructs a WebSocket_Dev object. |
25 virtual ~WebSocket_Dev(); | 28 virtual ~WebSocket_Dev(); |
26 | 29 |
27 /// Connect() connects to the specified WebSocket server. Caller can call | 30 /// Connect() connects to the specified WebSocket server. Caller can call |
28 /// this method at most once. | 31 /// this method at most once. |
29 /// | 32 /// |
30 /// @param[in] url A <code>PP_Var</code> representing a WebSocket server URL. | 33 /// @param[in] url A <code>PP_Var</code> representing a WebSocket server URL. |
31 /// The <code>PP_VarType</code> must be <code>PP_VARTYPE_STRING</code>. | 34 /// The <code>PP_VarType</code> must be <code>PP_VARTYPE_STRING</code>. |
32 /// @param[in] protocols A pointer to an array of <code>PP_Var</code> | 35 /// @param[in] protocols A pointer to an array of <code>PP_Var</code> |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 /// GetURL() returns the URL associated with specified WebSocket connection. | 115 /// GetURL() returns the URL associated with specified WebSocket connection. |
113 /// | 116 /// |
114 /// @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before | 117 /// @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before |
115 /// the connection is established, its data is empty string. | 118 /// the connection is established, its data is empty string. |
116 Var GetURL(); | 119 Var GetURL(); |
117 | 120 |
118 /// OnOpen() is invoked when the connection is established by Connect(). | 121 /// OnOpen() is invoked when the connection is established by Connect(). |
119 virtual void OnOpen() = 0; | 122 virtual void OnOpen() = 0; |
120 | 123 |
121 /// OnMessage() is invoked when a message is received. | 124 /// OnMessage() is invoked when a message is received. |
122 virtual void OnMessage(Var message) = 0; | 125 virtual void OnMessage(const Var& message) = 0; |
123 | 126 |
124 /// OnError() is invoked if the user agent was required to fail the WebSocket | 127 /// OnError() is invoked if the user agent was required to fail the WebSocket |
125 /// connection or the WebSocket connection is closed with prejudice. | 128 /// connection or the WebSocket connection is closed with prejudice. |
126 /// OnClose() always follows OnError(). | 129 /// OnClose() always follows OnError(). |
127 virtual void OnError() = 0; | 130 virtual void OnError() = 0; |
128 | 131 |
129 /// OnClose() is invoked when the connection is closed by errors or Close(). | 132 /// OnClose() is invoked when the connection is closed by errors or Close(). |
130 virtual void OnClose(bool wasClean, uint16_t code, const Var& reason) = 0; | 133 virtual void OnClose(bool wasClean, uint16_t code, const Var& reason) = 0; |
134 | |
135 private: | |
136 class WebSocketPrivate; | |
137 WebSocketPrivate* impl; | |
dmichael (off chromium)
2011/12/07 23:31:28
nit: impl->impl_
Takashi Toyoshima
2011/12/08 14:40:10
Done.
| |
131 }; | 138 }; |
132 | 139 |
133 } // namespace pp | 140 } // namespace pp |
134 | 141 |
135 #endif // PPAPI_CPP_DEV_WEBSOCKET_DEV_H_ | 142 #endif // PPAPI_CPP_DEV_WEBSOCKET_DEV_H_ |
OLD | NEW |