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

Unified 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: Change int to bool Created 8 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 | « remoting/host/dns_blackhole_checker.h ('k') | remoting/host/policy_hack/policy_watcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/dns_blackhole_checker.cc
diff --git a/remoting/host/dns_blackhole_checker.cc b/remoting/host/dns_blackhole_checker.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fb4ae03f2ed5723c916da6ef8a83f3dd4639ea31
--- /dev/null
+++ b/remoting/host/dns_blackhole_checker.cc
@@ -0,0 +1,70 @@
+// Copyright (c) 2012 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.
+
+#include "remoting/host/dns_blackhole_checker.h"
+
+#include "googleurl/src/gurl.h"
+#include "net/url_request/url_fetcher.h"
+#include "remoting/host/chromoting_host_context.h"
+#include "remoting/host/constants.h"
+
+namespace remoting {
+
+// Default prefix added to the base talkgadget URL.
+const char kDefaultHostTalkGadgetPrefix[] = "chromoting-host";
+
+// The base talkgadget URL.
+const char kTalkGadgetUrl[] = ".talkgadget.google.com/talkgadget/"
+ "oauth/chrome-remote-desktop-host";
+
+DnsBlackholeChecker::DnsBlackholeChecker(
+ ChromotingHostContext* context,
+ std::string talkgadget_prefix)
+ : context_(context),
+ talkgadget_prefix_(talkgadget_prefix) {
+}
+
+DnsBlackholeChecker::~DnsBlackholeChecker() {
+}
+
+// This is called in response to the TalkGadget http request initiated from
+// CheckStatus().
+void DnsBlackholeChecker::OnURLFetchComplete(const net::URLFetcher* source) {
+ int response = source->GetResponseCode();
+ bool allow = false;
+ if (source->GetResponseCode() == 200) {
+ LOG(INFO) << "Successfully connected to host talkgadget.";
+ allow = true;
+ } else {
+ LOG(INFO) << "Unable to connect to host talkgadget (" << response << ")";
+ }
+ url_fetcher_.reset(NULL);
+ callback_.Run(allow);
+ callback_.Reset();
+}
+
+void DnsBlackholeChecker::CheckForDnsBlackhole(
+ const base::Callback<void(bool)>& callback) {
+ // Make sure we're not currently in the middle of a connection check.
+ if (!url_fetcher_.get()) {
+ DCHECK(callback_.is_null());
+ callback_ = callback;
+ std::string talkgadget_url("https://");
+ if (talkgadget_prefix_.empty()) {
+ talkgadget_url += kDefaultHostTalkGadgetPrefix;
+ } else {
+ talkgadget_url += talkgadget_prefix_;
+ }
+ talkgadget_url += kTalkGadgetUrl;
+ LOG(INFO) << "Verifying connection to " << talkgadget_url;
+ url_fetcher_.reset(net::URLFetcher::Create(GURL(talkgadget_url),
+ net::URLFetcher::GET, this));
+ url_fetcher_->SetRequestContext(context_->url_request_context_getter());
+ url_fetcher_->Start();
+ } else {
+ LOG(INFO) << "Pending connection check";
+ }
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/host/dns_blackhole_checker.h ('k') | remoting/host/policy_hack/policy_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698