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

Side by Side Diff: remoting/host/dns_blackhole_checker.cc

Issue 10873050: [Chromoting] Hook up host talkgadget policy checks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move callback Created 8 years, 3 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) 2012 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 #include "remoting/host/dns_blackhole_checker.h"
6
7 #include "googleurl/src/gurl.h"
8 #include "net/url_request/url_fetcher.h"
9 #include "remoting/host/chromoting_host_context.h"
10 #include "remoting/host/constants.h"
11
12 namespace remoting {
13
14 // The base talkgadget URL.
15 const char kTalkGadgetUrl[] = ".talkgadget.google.com/talkgadget/"
16 "oauth/chrome-remote-desktop-host";
17
18 DnsBlackholeChecker::DnsBlackholeChecker(
19 ChromotingHostContext* context,
20 std::string talkgadget_prefix)
21 : context_(context),
22 talkgadget_prefix_(talkgadget_prefix) {
23 }
24
25 DnsBlackholeChecker::~DnsBlackholeChecker() {
26 }
27
28 // This is called in response to the TalkGadget http request initiated from
29 // CheckStatus().
30 void DnsBlackholeChecker::OnURLFetchComplete(const net::URLFetcher* source) {
31 int response = source->GetResponseCode();
32 int allow = false;
33 if (source->GetResponseCode() == 200) {
34 LOG(INFO) << "Successfully connected to host talkgadget.";
35 allow = true;
36 } else {
37 LOG(INFO) << "Unable to connect to host talkgadget (" << response << ")";
38 }
39 url_fetcher_.reset(NULL);
40 callback_.Run(allow);
41 callback_.Reset();
42 }
43
44 void DnsBlackholeChecker::CheckForDnsBlackhole(
45 const base::Callback<void(bool)>& callback) {
46 // Make sure we're not currently in the middle of a connection check.
47 if (!url_fetcher_.get()) {
48 DCHECK(callback_.is_null());
49 callback_ = callback;
50 std::string talkgadget_url("https://");
51 if (talkgadget_prefix_.empty()) {
52 talkgadget_url += kDefaultHostTalkGadgetPrefix;
53 } else {
54 talkgadget_url += talkgadget_prefix_;
55 }
56 talkgadget_url += kTalkGadgetUrl;
57 LOG(INFO) << "Verifying connection to " << talkgadget_url;
58 url_fetcher_.reset(net::URLFetcher::Create(GURL(talkgadget_url),
59 net::URLFetcher::GET, this));
60 url_fetcher_->SetRequestContext(context_->url_request_context_getter());
61 url_fetcher_->Start();
62 } else {
63 LOG(INFO) << "Pending connection check";
64 }
65 }
66
67 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698