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

Side by Side Diff: chrome/common/extensions/api/socket.idl

Issue 10827390: Implement chrome.socket.bind/listen/accept for TCP server socket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unrelated changes. Created 8 years, 3 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
OLDNEW
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 // File-level comment to appease parser. Eventually this will not be necessary. 5 // File-level comment to appease parser. Eventually this will not be necessary.
6 6
7 namespace socket { 7 namespace socket {
8 enum SocketType { 8 enum SocketType {
9 tcp, 9 tcp,
10 udp 10 udp
11 }; 11 };
12 12
13 // The socket options. 13 // The socket options.
14 dictionary CreateOptions { 14 dictionary CreateOptions {
15 }; 15 };
16 16
17 dictionary CreateInfo { 17 dictionary CreateInfo {
18 // The id of the newly created socket. 18 // The id of the newly created socket.
19 long socketId; 19 long socketId;
20 }; 20 };
21 21
22 dictionary AcceptInfo {
23 // The id of the accepted socket.
24 long socketId;
25 long resultCode;
26 };
27
22 callback CreateCallback = void (CreateInfo createInfo); 28 callback CreateCallback = void (CreateInfo createInfo);
23 29
24 callback ConnectCallback = void (long result); 30 callback ConnectCallback = void (long result);
25 31
26 callback BindCallback = void (long result); 32 callback BindCallback = void (long result);
27 33
34 callback ListenCallback = void (long result);
35
36 callback AcceptCallback = void (AcceptInfo acceptInfo);
37
28 dictionary ReadInfo { 38 dictionary ReadInfo {
29 // The resultCode returned from the underlying read() call. 39 // The resultCode returned from the underlying read() call.
30 long resultCode; 40 long resultCode;
31 41
32 ArrayBuffer data; 42 ArrayBuffer data;
33 }; 43 };
34 44
35 callback ReadCallback = void (ReadInfo readInfo); 45 callback ReadCallback = void (ReadInfo readInfo);
36 46
37 dictionary WriteInfo { 47 dictionary WriteInfo {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // and <code>write()</code> calls. 126 // and <code>write()</code> calls.
117 // |socketId| : The socketId. 127 // |socketId| : The socketId.
118 // |hostname| : The hostname or IP address of the remote machine. 128 // |hostname| : The hostname or IP address of the remote machine.
119 // |port| : The port of the remote machine. 129 // |port| : The port of the remote machine.
120 // |callback| : Called when the connection attempt is complete. 130 // |callback| : Called when the connection attempt is complete.
121 static void connect(long socketId, 131 static void connect(long socketId,
122 DOMString hostname, 132 DOMString hostname,
123 long port, 133 long port,
124 ConnectCallback callback); 134 ConnectCallback callback);
125 135
126 // Binds the local address for socket. Currently, it does not support 136 // Binds the local address for socket.
127 // TCP socket.
128 // |socketId| : The socketId. 137 // |socketId| : The socketId.
129 // |address| : The address of the local machine. 138 // |address| : The address of the local machine.
130 // |port| : The port of the local machine. 139 // |port| : The port of the local machine.
131 // |callback| : Called when the bind attempt is complete. 140 // |callback| : Called when the bind attempt is complete.
132 static void bind(long socketId, 141 static void bind(long socketId,
133 DOMString address, 142 DOMString address,
134 long port, 143 long port,
135 BindCallback callback); 144 BindCallback callback);
136 145
146 // This method applies to TCP sockets only.
147 // Listens on the specified port that this socket was bound to.
148 // This effectively makes this a server socket and client socket functions
149 // can no longer be used on this socket.
150 // |socketId| : The socketId.
151 // |backlog| : Length of the socket's listen queue.
152 static void listen(long socketId,
153 long backlog,
154 ListenCallback callback);
155
156 // This method applies to TCP sockets only.
157 // Start waiting for connections on the server socket. The listen function
158 // must be called first.
159 // |socketId| : The socketId.
160 // |callback| : The callback is invoked when a new socket is accepted. The
161 // parameters contain information about the newly accepted socket.
162 static void accept(long socketId,
163 AcceptCallback callback);
164
137 // Disconnects the socket. For UDP sockets, <code>disconnect</code> is a 165 // Disconnects the socket. For UDP sockets, <code>disconnect</code> is a
138 // non-operation but is safe to call. 166 // non-operation but is safe to call.
139 // |socketId| : The socketId. 167 // |socketId| : The socketId.
140 static void disconnect(long socketId); 168 static void disconnect(long socketId);
141 169
142 // Reads data from the given connected socket. 170 // Reads data from the given connected socket.
143 // |socketId| : The socketId. 171 // |socketId| : The socketId.
144 // |bufferSize| : The read buffer size. 172 // |bufferSize| : The read buffer size.
145 // |callback| : Delivers data that was available to be read without 173 // |callback| : Delivers data that was available to be read without
146 // blocking. 174 // blocking.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 SetNoDelayCallback callback); 227 SetNoDelayCallback callback);
200 228
201 // Retrieves the state of the given socket. 229 // Retrieves the state of the given socket.
202 // |socketId| : The socketId. 230 // |socketId| : The socketId.
203 // |callback| : Called when the state is available. 231 // |callback| : Called when the state is available.
204 static void getInfo(long socketId, 232 static void getInfo(long socketId,
205 GetInfoCallback callback); 233 GetInfoCallback callback);
206 }; 234 };
207 235
208 }; 236 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698