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

Unified Diff: chrome/browser/extensions/api/socket/socket_api.h

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/browser/extensions/api/socket/socket_api.h
diff --git a/chrome/browser/extensions/api/socket/socket_api.h b/chrome/browser/extensions/api/socket/socket_api.h
index a9efeaa55a48e383625f2f0d1ca4cde4b1800314..04f30381c3bfdc1347ff6cfdef4c9a7b66324599 100644
--- a/chrome/browser/extensions/api/socket/socket_api.h
+++ b/chrome/browser/extensions/api/socket/socket_api.h
@@ -9,6 +9,7 @@
#include "base/memory/ref_counted.h"
#include "chrome/browser/extensions/api/api_function.h"
#include "net/base/io_buffer.h"
+#include "net/base/ip_endpoint.h"
#include <string>
@@ -43,10 +44,8 @@ class SocketCreateFunction : public AsyncIOAPIFunction {
kSocketTypeUDP
};
- int src_id_;
SocketType socket_type_;
- std::string address_;
- int port_;
+ int src_id_;
APIResourceEventNotifier* event_notifier_;
DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.create")
@@ -72,6 +71,8 @@ class SocketConnectFunction : public AsyncIOAPIFunction {
private:
int socket_id_;
+ std::string address_;
+ int port_;
DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.connect")
};
@@ -88,6 +89,20 @@ class SocketDisconnectFunction : public AsyncIOAPIFunction {
DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.disconnect")
};
+class SocketBindFunction : public AsyncIOAPIFunction {
+ protected:
+ virtual bool Prepare() OVERRIDE;
+ virtual void Work() OVERRIDE;
+ virtual bool Respond() OVERRIDE;
+
+ private:
+ int socket_id_;
+ std::string address_;
+ int port_;
+
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.bind")
+};
+
class SocketReadFunction : public AsyncIOAPIFunction {
protected:
virtual bool Prepare() OVERRIDE;
@@ -117,6 +132,38 @@ class SocketWriteFunction : public AsyncIOAPIFunction {
DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.write")
};
+class SocketRecvFromFunction : public AsyncIOAPIFunction {
+ protected:
+ virtual bool Prepare() OVERRIDE;
+ virtual void Work() OVERRIDE;
+ virtual bool Respond() OVERRIDE;
+
+ private:
+ int socket_id_;
+ net::IPEndPoint address_;
+
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.recvFrom")
+};
+
+class SocketSendToFunction : public AsyncIOAPIFunction {
+ public:
+ SocketSendToFunction();
+ virtual ~SocketSendToFunction();
+
+ protected:
+ virtual bool Prepare() OVERRIDE;
+ virtual void Work() OVERRIDE;
+ virtual bool Respond() OVERRIDE;
+
+ private:
+ int socket_id_;
+ scoped_refptr<net::IOBufferWithSize> io_buffer_;
+ std::string address_;
+ int port_;
+
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.sendTo")
+};
+
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_

Powered by Google App Engine
This is Rietveld 408576698