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

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

Issue 10537017: Allow hostnames in socket.connect(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Set 1 Created 8 years, 6 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 7f31f004e8c257e14125ef73b01bb4332d75886e..7f7f062b9ce05d80d785b4f0063fddef5c8bdca1 100644
--- a/chrome/browser/extensions/api/socket/socket_api.h
+++ b/chrome/browser/extensions/api/socket/socket_api.h
@@ -9,6 +9,8 @@
#include "base/memory/ref_counted.h"
#include "chrome/browser/extensions/api/api_function.h"
#include "chrome/common/extensions/api/experimental_socket.h"
+#include "net/base/address_list.h"
+#include "net/base/host_resolver.h"
#include <string>
@@ -16,6 +18,8 @@ namespace net {
class IOBuffer;
}
+class IOThread;
+
namespace extensions {
class APIResourceController;
@@ -80,18 +84,33 @@ class SocketConnectFunction : public SocketExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.connect")
+ SocketConnectFunction();
+
protected:
- virtual ~SocketConnectFunction() {}
+ virtual ~SocketConnectFunction();
// AsyncAPIFunction:
virtual bool Prepare() OVERRIDE;
virtual void AsyncWorkStart() OVERRIDE;
- void OnCompleted(int result);
private:
+ void StartDnsLookup();
+ void OnDnsLookup(int resolve_result);
+ void StartConnect();
+ void OnConnect(int result);
+
int socket_id_;
- std::string address_;
+ std::string hostname_;
+ std::string resolved_address_;
int port_;
+
+ // This instance is widely available through BrowserProcess, but we need to
+ // acquire it on the UI thread and then use it on the IO thread, so we keep a
+ // plain pointer to it here as we move from thread to thread.
+ IOThread* io_thread_;
+
+ scoped_ptr<net::HostResolver::RequestHandle> request_handle_;
+ scoped_ptr<net::AddressList> addresses_;
};
class SocketDisconnectFunction : public SocketExtensionFunction {

Powered by Google App Engine
This is Rietveld 408576698