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

Unified 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: Fix tests 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/api/socket.idl
diff --git a/chrome/common/extensions/api/socket.idl b/chrome/common/extensions/api/socket.idl
index d417d9b227053fb5842ee4f622280976b5de8552..d33259241fa4b0feb2391b78bcc48557ce1b1b01 100644
--- a/chrome/common/extensions/api/socket.idl
+++ b/chrome/common/extensions/api/socket.idl
@@ -23,6 +23,16 @@ namespace socket {
callback BindCallback = void (long result);
+ callback ListenCallback = void (long result);
+
+ dictionary AcceptInfo {
+ long resultCode;
+ // The id of the accepted socket.
+ long? socketId;
+ };
+
+ callback AcceptCallback = void (AcceptInfo acceptInfo);
+
dictionary ReadInfo {
// The resultCode returned from the underlying read() call.
long resultCode;
@@ -187,6 +197,32 @@ namespace socket {
long port,
SendToCallback callback);
+ // This method is experimental and requires experimental API permission.
+ // This method applies to TCP sockets only.
+ // Listens for connections on the specified port and address. This
+ // effectively makes this a server socket, and client socket
+ // functions (connect, read, write) can no longer be used on this socket.
+ // |socketId| : The socketId.
+ // |address| : The address of the local machine.
+ // |port| : The port of the local machine.
+ // |backlog| : Length of the socket's listen queue.
+ static void listen(long socketId,
+ DOMString address,
+ long port,
+ optional long backlog,
+ ListenCallback callback);
+
+ // This method is experimental and requires experimental API permission.
+ // This method applies to TCP sockets only.
+ // Registers a callback function to be called when a connection is
+ // accepted on this listening server socket. Listen must be called first.
+ // If there is already an active accept callback, this callback will be
+ // invoked immediately with an error as the resultCode.
+ // |socketId| : The socketId.
+ // |callback| : The callback is invoked when a new socket is accepted.
+ static void accept(long socketId,
+ AcceptCallback callback);
+
// Enables or disables the keep-alive functionality for a TCP connection.
// |socketId| : The socketId.
// |enable| : If true, enable keep-alive functionality.

Powered by Google App Engine
This is Rietveld 408576698