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

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

Issue 8743017: Real (but naive) UDP socket sending. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial. Created 9 years, 1 month 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/socket_api.h
diff --git a/chrome/browser/extensions/socket_api.h b/chrome/browser/extensions/socket_api.h
index 4c22e01e19ac9963167f4e49055b945c09b19a80..c61a3971e635c8fcd99f2bac547f925eb105e576 100644
--- a/chrome/browser/extensions/socket_api.h
+++ b/chrome/browser/extensions/socket_api.h
@@ -8,12 +8,20 @@
#include "chrome/browser/extensions/extension_function.h"
+#include <string>
+
namespace extensions {
+// Many of these socket functions are synchronous in the sense that
+// they don't involve blocking operations, but we've made them all
+// AsyncExtensionFunctions because the underlying UDPClientSocket
+// library wants all operations to happen on the same thread as the
+// one that created the socket. Too bad.
+
class SocketCreateFunction : public AsyncExtensionFunction {
public:
- SocketCreateFunction();
- virtual ~SocketCreateFunction();
+ SocketCreateFunction() {}
Mihai Parparita -not on Chrome 2011/12/01 23:39:32 The style guide strongly discourages inline constr
miket_OOO 2011/12/02 21:06:36 Fixed.
+ virtual ~SocketCreateFunction() {}
virtual bool RunImpl() OVERRIDE;
protected:
@@ -23,43 +31,70 @@ class SocketCreateFunction : public AsyncExtensionFunction {
DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.create")
};
+class SocketDestroyFunction : public AsyncExtensionFunction {
+ public:
+ SocketDestroyFunction() {}
+ virtual ~SocketDestroyFunction() {}
+ virtual bool RunImpl() OVERRIDE;
+
+ protected:
+ void WorkOnIOThread();
+ void RespondOnUIThread();
+
+ private:
+ int socket_id_;
+
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.destroy")
+};
+
class SocketConnectFunction : public AsyncExtensionFunction {
public:
- SocketConnectFunction();
- virtual ~SocketConnectFunction();
+ SocketConnectFunction() {}
+ virtual ~SocketConnectFunction() {}
virtual bool RunImpl() OVERRIDE;
protected:
void WorkOnIOThread();
void RespondOnUIThread();
+ private:
+ int socket_id_;
+ std::string address_;
+ int port_;
+
DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.connect")
};
-class SocketDisconnectFunction : public AsyncExtensionFunction {
+class SocketCloseFunction : public AsyncExtensionFunction {
public:
- SocketDisconnectFunction();
- virtual ~SocketDisconnectFunction();
+ SocketCloseFunction() {}
+ virtual ~SocketCloseFunction() {}
virtual bool RunImpl() OVERRIDE;
protected:
void WorkOnIOThread();
void RespondOnUIThread();
- DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.disconnect")
+ private:
+ int socket_id_;
+
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.close")
};
-class SocketSendFunction : public AsyncExtensionFunction {
+class SocketWriteFunction : public AsyncExtensionFunction {
public:
- SocketSendFunction();
- virtual ~SocketSendFunction();
+ SocketWriteFunction() {}
+ virtual ~SocketWriteFunction() {}
virtual bool RunImpl() OVERRIDE;
protected:
void WorkOnIOThread();
void RespondOnUIThread();
- DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.send")
+ int socket_id_;
+ std::string message_;
+
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.write")
};
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698