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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_P2P_HOST_ADDRESS_REQUEST_H_
6 #define CONTENT_RENDERER_P2P_HOST_ADDRESS_REQUEST_H_
7
8 #include <string>
9
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "net/base/net_util.h"
13
14 namespace base {
15 class MessageLoopProxy;
16 } // namespace base
17
18 class P2PSocketDispatcher;
19
20 class P2PHostAddressRequest :
21 public base::RefCountedThreadSafe<P2PHostAddressRequest> {
22 public:
23 typedef base::Callback<void(const net::IPAddressNumber&)> DoneCallback;
24
25 P2PHostAddressRequest(P2PSocketDispatcher* dispatcher);
26
27 void Request(const std::string& host_name,
28 const DoneCallback& done_callback);
29 void Cancel();
30
31 private:
32 enum State {
33 STATE_CREATED,
34 STATE_SENT,
35 STATE_FINISHED,
36 };
37
38 friend class P2PSocketDispatcher;
39
40 friend class base::RefCountedThreadSafe<P2PHostAddressRequest>;
41 virtual ~P2PHostAddressRequest();
42
43 void DoSendRequest(const std::string& host_name,
44 const DoneCallback& done_callback);
45 void DoUnregister();
46 void OnResponse(const net::IPAddressNumber& address);
47 void DeliverResponse(const net::IPAddressNumber& address);
48
49 P2PSocketDispatcher* dispatcher_;
50 scoped_refptr<base::MessageLoopProxy> ipc_message_loop_;
51 scoped_refptr<base::MessageLoopProxy> delegate_message_loop_;
52 DoneCallback done_callback_;
53
54 // State must be accessed from delegate thread only.
55 State state_;
56
57 // Accessed on the IPC thread only.
58 int32 request_id_;
59 bool registered_;
60
61 DISALLOW_COPY_AND_ASSIGN(P2PHostAddressRequest);
62 };
63
64 #endif // CONTENT_RENDERER_P2P_HOST_ADDRESS_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698