OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_HOST_DNS_BLACKHOLE_CHECKER_H_ | 5 #ifndef REMOTING_HOST_DNS_BLACKHOLE_CHECKER_H_ |
6 #define REMOTING_HOST_DNS_BLACKHOLE_CHECKER_H_ | 6 #define REMOTING_HOST_DNS_BLACKHOLE_CHECKER_H_ |
7 | 7 |
8 #include "net/url_request/url_fetcher_delegate.h" | 8 #include "net/url_request/url_fetcher_delegate.h" |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 | 11 |
| 12 namespace net { |
| 13 class URLRequestContextGetter; |
| 14 } // namespace net |
| 15 |
12 namespace remoting { | 16 namespace remoting { |
13 | 17 |
14 // This is the default prefix that is prepended to the kTalkGadgetUrl to form | 18 // This is the default prefix that is prepended to the kTalkGadgetUrl to form |
15 // the complete talkgadget URL used by the host. Policy settings allow admins | 19 // the complete talkgadget URL used by the host. Policy settings allow admins |
16 // to change the prefix that is used. | 20 // to change the prefix that is used. |
17 extern const char kDefaultHostTalkGadgetPrefix[]; | 21 extern const char kDefaultHostTalkGadgetPrefix[]; |
18 | 22 |
19 class ChromotingHostContext; | |
20 | |
21 class DnsBlackholeChecker : public net::URLFetcherDelegate { | 23 class DnsBlackholeChecker : public net::URLFetcherDelegate { |
22 public: | 24 public: |
23 DnsBlackholeChecker(ChromotingHostContext* context, | 25 DnsBlackholeChecker( |
24 std::string talkgadget_prefix); | 26 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, |
| 27 std::string talkgadget_prefix); |
25 virtual ~DnsBlackholeChecker(); | 28 virtual ~DnsBlackholeChecker(); |
26 | 29 |
27 // net::URLFetcherDelegate interface. | 30 // net::URLFetcherDelegate interface. |
28 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 31 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
29 | 32 |
30 // Initiates a check the verify that the host talkgadget has not been "DNS | 33 // Initiates a check the verify that the host talkgadget has not been "DNS |
31 // blackholed" to prevent connections. If this is called again before the | 34 // blackholed" to prevent connections. If this is called again before the |
32 // callback has been called, then the second call is ignored. | 35 // callback has been called, then the second call is ignored. |
33 void CheckForDnsBlackhole(const base::Callback<void(bool)>& callback); | 36 void CheckForDnsBlackhole(const base::Callback<void(bool)>& callback); |
34 | 37 |
35 private: | 38 private: |
36 ChromotingHostContext* context_; | 39 // URL request context getter to use to create the URL fetcher. |
| 40 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
37 | 41 |
38 // URL fetcher used to verify access to the host talkgadget. | 42 // URL fetcher used to verify access to the host talkgadget. |
39 scoped_ptr<net::URLFetcher> url_fetcher_; | 43 scoped_ptr<net::URLFetcher> url_fetcher_; |
40 | 44 |
41 // The string pre-pended to '.talkgadget.google.com' to create the full | 45 // The string pre-pended to '.talkgadget.google.com' to create the full |
42 // talkgadget domain name for the host. | 46 // talkgadget domain name for the host. |
43 std::string talkgadget_prefix_; | 47 std::string talkgadget_prefix_; |
44 | 48 |
45 // Called with the results of the connection check. | 49 // Called with the results of the connection check. |
46 base::Callback<void(bool)> callback_; | 50 base::Callback<void(bool)> callback_; |
47 | 51 |
48 DISALLOW_COPY_AND_ASSIGN(DnsBlackholeChecker); | 52 DISALLOW_COPY_AND_ASSIGN(DnsBlackholeChecker); |
49 }; | 53 }; |
50 | 54 |
51 } // namespace remoting | 55 } // namespace remoting |
52 | 56 |
53 #endif // REMOTING_HOST_DNS_BLACKHOLE_CHECKER_H_ | 57 #endif // REMOTING_HOST_DNS_BLACKHOLE_CHECKER_H_ |
OLD | NEW |