Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(593)

Side by Side Diff: ppapi/api/dev/ppb_websocket_dev.idl

Issue 9192009: WebSocket Pepper API: make the API out of dev (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for land Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/api/ppb_websocket.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 * found in the LICENSE file.
4 */
5
6 /**
7 * This file defines the <code>PPB_WebSocket_Dev</code> interface.
8 */
9 label Chrome {
10 M17 = 0.1
11 };
12
13
14 /**
15 * This enumeration contains the types representing the WebSocket ready state
16 * and these states are based on the JavaScript WebSocket API specification.
17 * GetReadyState() returns one of these states.
18 */
19 [assert_size(4)]
20 enum PP_WebSocketReadyState_Dev {
21 /**
22 * Ready state is queried on an invalid resource.
23 */
24 PP_WEBSOCKETREADYSTATE_INVALID_DEV = -1,
25 /**
26 * Ready state that the connection has not yet been established.
27 */
28 PP_WEBSOCKETREADYSTATE_CONNECTING_DEV = 0,
29
30 /**
31 * Ready state that the WebSocket connection is established and communication
32 * is possible.
33 */
34 PP_WEBSOCKETREADYSTATE_OPEN_DEV = 1,
35
36 /**
37 * Ready state that the connection is going through the closing handshake.
38 */
39 PP_WEBSOCKETREADYSTATE_CLOSING_DEV = 2,
40
41 /**
42 * Ready state that the connection has been closed or could not be opened.
43 */
44 PP_WEBSOCKETREADYSTATE_CLOSED_DEV = 3
45 };
46
47 interface PPB_WebSocket_Dev {
48 /**
49 * Create() creates a WebSocket instance.
50 *
51 * @param[in] instance A <code>PP_Instance</code> identifying the instance
52 * with the WebSocket.
53 *
54 * @return A <code>PP_Resource</code> corresponding to a WebSocket if
55 * successful.
56 */
57 PP_Resource Create([in] PP_Instance instance);
58
59 /**
60 * IsWebSocket() determines if the provided <code>resource</code> is a
61 * WebSocket instance.
62 *
63 * @param[in] resource A <code>PP_Resource</code> corresponding to a
64 * WebSocket.
65 *
66 * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a
67 * <code>PPB_WebSocket_Dev</code>, <code>PP_FALSE</code> if the
68 * <code>resource</code> is invalid or some type other than
69 * <code>PPB_WebSocket_Dev</code>.
70 */
71 PP_Bool IsWebSocket([in] PP_Resource resource);
72
73 /**
74 * Connect() connects to the specified WebSocket server. Caller can call this
75 * method at most once for a <code>web_socket</code>.
76 *
77 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
78 * WebSocket.
79 *
80 * @param[in] url A <code>PP_Var</code> representing a WebSocket server URL.
81 * The <code>PP_VarType</code> must be <code>PP_VARTYPE_STRING</code>.
82 *
83 * @param[in] protocols A pointer to an array of <code>PP_Var</code>
84 * specifying sub-protocols. Each <code>PP_Var</code> represents one
85 * sub-protocol and its <code>PP_VarType</code> must be
86 * <code>PP_VARTYPE_STRING</code>. This argument can be null only if
87 * <code>protocol_count</code> is 0.
88 *
89 * @param[in] protocol_count The number of sub-protocols in
90 * <code>protocols</code>.
91 *
92 * @param[in] callback A <code>PP_CompletionCallback</code> which is called
93 * when a connection is established or an error occurs in establishing
94 * connection.
95 *
96 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
97 * Returns <code>PP_ERROR_BADARGUMENT</code> if specified <code>url</code>,
98 * or <code>protocols</code> contains invalid string as
99 * <code>The WebSocket API specification</code> defines. It corresponds to
100 * SyntaxError of the specification.
101 * Returns <code>PP_ERROR_NOACCESS</code> if the protocol specified in the
102 * <code>url</code> is not a secure protocol, but the origin of the caller
103 * has a secure scheme. Also returns it if the port specified in the
104 * <code>url</code> is a port to which the user agent is configured to block
105 * access because the port is a well-known port like SMTP. It corresponds to
106 * SecurityError of the specification.
107 * Returns <code>PP_ERROR_INPROGRESS</code> if the call is not the first
108 * time.
109 */
110 int32_t Connect([in] PP_Resource web_socket,
111 [in] PP_Var url,
112 [in, size_as=protocol_count] PP_Var[] protocols,
113 [in] uint32_t protocol_count,
114 [in] PP_CompletionCallback callback);
115
116 /**
117 * Close() closes the specified WebSocket connection by specifying
118 * <code>code</code> and <code>reason</code>.
119 *
120 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
121 * WebSocket.
122 *
123 * @param[in] code The WebSocket close code. Ignored if it is 0.
124 *
125 * @param[in] reason A <code>PP_Var</code> which represents the WebSocket
126 * close reason. Ignored if it is <code>PP_VARTYPE_UNDEFINED</code>.
127 * Otherwise, its <code>PP_VarType</code> must be
128 * <code>PP_VARTYPE_STRING</code>.
129 *
130 * @param[in] callback A <code>PP_CompletionCallback</code> which is called
131 * when the connection is closed or an error occurs in closing the
132 * connection.
133 *
134 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
135 * Returns <code>PP_ERROR_BADARGUMENT</code> if <code>reason</code> contains
136 * an invalid character as a UTF-8 string, or longer than 123 bytes. It
137 * corresponds to JavaScript SyntaxError of the specification.
138 * Returns <code>PP_ERROR_NOACCESS</code> if the code is not an integer
139 * equal to 1000 or in the range 3000 to 4999. It corresponds to
140 * InvalidAccessError of the specification. Returns
141 * <code>PP_ERROR_INPROGRESS</code> if the call is not the first time.
142 */
143 int32_t Close([in] PP_Resource web_socket,
144 [in] uint16_t code,
145 [in] PP_Var reason,
146 [in] PP_CompletionCallback callback);
147
148 /**
149 * ReceiveMessage() receives a message from the WebSocket server.
150 * This interface only returns a single message. That is, this interface must
151 * be called at least N times to receive N messages, no matter how small each
152 * message is.
153 *
154 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
155 * WebSocket.
156 *
157 * @param[out] message The received message is copied to provided
158 * <code>message</code>. The <code>message</code> must remain valid until
159 * the ReceiveMessage operation completes. Its <code>PP_VarType</code>
160 * will be <code>PP_VARTYPE_STRING</code> or
161 * <code>PP_VARTYPE_ARRAY_BYFFER</code> on receiving.
162 *
163 * @param[in] callback A <code>PP_CompletionCallback</code> which is called
164 * when the receiving message is completed. It is ignored if ReceiveMessage
165 * completes synchronously and returns <code>PP_OK</code>.
166 *
167 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
168 * If an error is detected or connection is closed, returns
169 * <code>PP_ERROR_FAILED</code> after all buffered messages are received.
170 * Until buffered message become empty, continues to returns
171 * <code>PP_OK</code> as if connection is still established without errors.
172 */
173 int32_t ReceiveMessage([in] PP_Resource web_socket,
174 [out] PP_Var message,
175 [in] PP_CompletionCallback callback);
176
177 /**
178 * SendMessage() sends a message to the WebSocket server.
179 *
180 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
181 * WebSocket.
182 *
183 * @param[in] message A message to send. The message is copied to internal
184 * buffer. So caller can free <code>message</code> safely after returning
185 * from the function. Its <code>PP_VarType</code> must be
186 * <code>PP_VARTYPE_STRING</code> or <code>PP_VARTYPE_ARRAY_BUFFER</code>.
187 *
188 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
189 * Returns <code>PP_ERROR_FAILED</code> if the ReadyState is
190 * <code>PP_WEBSOCKETREADYSTATE_CONNECTING_DEV</code>. It corresponds
191 * JavaScript InvalidStateError of the specification.
192 * Returns <code>PP_ERROR_BADARGUMENT</code> if provided <code>message</code>
193 * of string type contains an invalid character as a UTF-8 string. It
194 * corresponds to JavaScript SyntaxError of the specification.
195 * Otherwise, returns <code>PP_OK</code>, but it doesn't necessarily mean
196 * that the server received the message.
197 */
198 int32_t SendMessage([in] PP_Resource web_socket,
199 [in] PP_Var message);
200
201 /**
202 * GetBufferedAmount() returns the number of bytes of text and binary
203 * messages that have been queued for the WebSocket connection to send but
204 * have not been transmitted to the network yet.
205 *
206 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
207 * WebSocket.
208 *
209 * @return Returns the number of bytes.
210 */
211 uint64_t GetBufferedAmount([in] PP_Resource web_socket);
212
213 /**
214 * GetCloseCode() returns the connection close code for the WebSocket
215 * connection.
216 *
217 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
218 * WebSocket.
219 *
220 * @return Returns 0 if called before the close code is set.
221 */
222 uint16_t GetCloseCode([in] PP_Resource web_socket);
223
224 /**
225 * GetCloseReason() returns the connection close reason for the WebSocket
226 * connection.
227 *
228 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
229 * WebSocket.
230 *
231 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the
232 * close reason is set, it contains an empty string. Returns a
233 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource.
234 */
235 PP_Var GetCloseReason([in] PP_Resource web_socket);
236
237 /**
238 * GetCloseWasClean() returns if the connection was closed cleanly for the
239 * specified WebSocket connection.
240 *
241 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
242 * WebSocket.
243 *
244 * @return Returns <code>PP_FALSE</code> if called before the connection is
245 * closed, or called on an invalid resource. Otherwise, returns
246 * <code>PP_TRUE</code> if the connection was closed cleanly, or returns
247 * <code>PP_FALSE</code> if the connection was closed for abnormal reasons.
248 */
249 PP_Bool GetCloseWasClean([in] PP_Resource web_socket);
250
251 /**
252 * GetExtensions() returns the extensions selected by the server for the
253 * specified WebSocket connection.
254 *
255 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
256 * WebSocket.
257 *
258 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the
259 * connection is established, its data is an empty string. Returns a
260 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource.
261 * Currently its data for valid resources are always an empty string.
262 */
263 PP_Var GetExtensions([in] PP_Resource web_socket);
264
265 /**
266 * GetProtocol() returns the sub-protocol chosen by the server for the
267 * specified WebSocket connection.
268 *
269 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
270 * WebSocket.
271 *
272 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the
273 * connection is established, it contains the empty string. Returns a
274 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource.
275 */
276 PP_Var GetProtocol([in] PP_Resource web_socket);
277
278 /**
279 * GetReadyState() returns the ready state of the specified WebSocket
280 * connection.
281 *
282 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
283 * WebSocket.
284 *
285 * @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID_DEV</code> if called
286 * before connect() is called, or called on an invalid resource.
287 */
288 PP_WebSocketReadyState_Dev GetReadyState([in] PP_Resource web_socket);
289
290 /**
291 * GetURL() returns the URL associated with specified WebSocket connection.
292 *
293 * @param[in] web_socket A <code>PP_Resource</code> corresponding to a
294 * WebSocket.
295 *
296 * @return Returns a <code>PP_VARTYPE_STRING</code> var. If called before the
297 * connection is established, it contains the empty string. Return a
298 * <code>PP_VARTYPE_UNDEFINED</code> if called on an invalid resource.
299 */
300 PP_Var GetURL([in] PP_Resource web_socket);
301 };
OLDNEW
« no previous file with comments | « no previous file | ppapi/api/ppb_websocket.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698