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

Unified Diff: content/renderer/p2p/host_address_request.h

Issue 7599003: Add IPC for DNS host address resolution. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 4 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
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/p2p/host_address_request.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/p2p/host_address_request.h
diff --git a/content/renderer/p2p/host_address_request.h b/content/renderer/p2p/host_address_request.h
new file mode 100644
index 0000000000000000000000000000000000000000..14a5ae0a6a7993f2f742b01fa5ace3b4989e8859
--- /dev/null
+++ b/content/renderer/p2p/host_address_request.h
@@ -0,0 +1,68 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_P2P_HOST_ADDRESS_REQUEST_H_
+#define CONTENT_RENDERER_P2P_HOST_ADDRESS_REQUEST_H_
+
+#include <string>
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "net/base/net_util.h"
+
+namespace base {
+class MessageLoopProxy;
+} // namespace base
+
+class P2PSocketDispatcher;
+
+class P2PHostAddressRequest :
+ public base::RefCountedThreadSafe<P2PHostAddressRequest> {
+ public:
+ typedef base::Callback<void(const net::IPAddressNumber&)> DoneCallback;
+
+ P2PHostAddressRequest(P2PSocketDispatcher* dispatcher);
+
+ // Sends host address request.
+ void Request(const std::string& host_name,
+ const DoneCallback& done_callback);
+
+ // Cancels the request. The callback passed to Request() will not be
+ // called after Cancel() is called.
+ void Cancel();
+
+ private:
+ enum State {
+ STATE_CREATED,
+ STATE_SENT,
+ STATE_FINISHED,
+ };
+
+ friend class P2PSocketDispatcher;
+
+ friend class base::RefCountedThreadSafe<P2PHostAddressRequest>;
+ virtual ~P2PHostAddressRequest();
+
+ void DoSendRequest(const std::string& host_name,
+ const DoneCallback& done_callback);
+ void DoUnregister();
+ void OnResponse(const net::IPAddressNumber& address);
+ void DeliverResponse(const net::IPAddressNumber& address);
+
+ P2PSocketDispatcher* dispatcher_;
+ scoped_refptr<base::MessageLoopProxy> ipc_message_loop_;
+ scoped_refptr<base::MessageLoopProxy> delegate_message_loop_;
+ DoneCallback done_callback_;
+
+ // State must be accessed from delegate thread only.
+ State state_;
+
+ // Accessed on the IPC thread only.
+ int32 request_id_;
+ bool registered_;
+
+ DISALLOW_COPY_AND_ASSIGN(P2PHostAddressRequest);
+};
+
+#endif // CONTENT_RENDERER_P2P_HOST_ADDRESS_REQUEST_H_
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/p2p/host_address_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698