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

Unified Diff: chrome/common/extensions/api/experimental.socket.idl

Issue 10134008: Add bind(), recvFrom(), sendTo() for UDP socket. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: wip Created 8 years, 8 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/experimental.socket.idl
diff --git a/chrome/common/extensions/api/experimental.socket.idl b/chrome/common/extensions/api/experimental.socket.idl
index b919b811005056ffac392e944d2d99d651a765c5..818409f10220aa0202a1e44762ad6885a3f1709f 100644
--- a/chrome/common/extensions/api/experimental.socket.idl
+++ b/chrome/common/extensions/api/experimental.socket.idl
@@ -51,6 +51,8 @@
callback ConnectCallback = void (long result);
+ callback BindCallback = void (long result);
+
dictionary ReadInfo {
// The data received. Warning: will probably become a blob or other
// appropriate binary-friendly type.
@@ -67,18 +69,27 @@
callback WriteCallback = void (WriteInfo writeInfo);
+ dictionary RecvFromInfo {
+ // The data received. Warning: will probably become a blob or other
+ // appropriate binary-friendly type.
+ // TODO(miket): [instanceOf=ArrayBuffer]object data;
+ long[] data;
+ DOMString address;
+ long port;
+ };
+
+ callback RecvFromCallback = void (RecvFromInfo recvFromInfo);
+
+ callback SendToCallback = void (long bytesWritten);
+
interface Functions {
// Creates a socket of the specified type that will connect to the specified
// remote machine.
// |type| : The type of socket to create. Must be <code>tcp</code> or
// <code>udp</code>.
- // |address| : The address of the remote machine.
- // |port| : The port of the remote machine.
// |options| : The socket options.
// |callback| : Called when the socket has been created.
static void create(DOMString type,
- DOMString address,
- long port,
optional CreateOptions options,
CreateCallback callback);
@@ -86,13 +97,26 @@
// |socketId| : The socketId.
static void destroy(long socketId);
- // Connects the socket to the remote machine. For UDP sockets,
- // <code>connect</code> is a non-operation but is safe to call.
+ // Connects the socket to the remote machine.
// |socketId| : The socketId.
+ // |address| : The address of the remote machine.
+ // |port| : The port of the remote machine.
// |callback| : Called when the connection attempt is complete.
static void connect(long socketId,
+ DOMString address,
+ long port,
ConnectCallback callback);
+ // Binds the local address.
+ // |socketId| : The socketId.
+ // |address| : The address of the remote machine.
+ // |port| : The port of the remote machine.
+ // |callback| : Called when the connection attempt is complete.
+ static void bind(long socketId,
+ DOMString address,
+ long port,
+ BindCallback callback);
+
// Disconnects the socket. For UDP sockets, <code>disconnect</code> is a
// non-operation but is safe to call.
// |socketId| : The socketId.
@@ -117,6 +141,29 @@
static void write(long socketId,
long[] data,
WriteCallback callback);
+
+ // Reads data from the given socket.
+ // |socketId| : The socketId.
+ // |callback| : Delivers data that was available to be read without
+ // blocking.
+ static void recvFrom(long socketId,
+ RecvFromCallback callback);
+
+ // Writes data on the given socket.
+ // |socketId| : The socketId.
+ // |data| : The data to write. Warning: will probably become a blob or other
+ // appropriate binary-friendly type.
+ // |address| : The address of the remote machine.
+ // |port| : The port of the remote machine.
+ // |callback| : Called when the first of any of the following happens: the
+ // write operation completes without blocking, the write operation blocked
+ // before completion (in which case onEvent() will eventually be called with
+ // a <code>writeComplete</code> event), or an error occurred.
+ static void sendTo(long socketId,
+ long[] data,
+ DOMString address,
+ long port,
+ SendToCallback callback);
};
interface Events {

Powered by Google App Engine
This is Rietveld 408576698