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

Unified Diff: remoting/host/signaling_connector.cc

Issue 10873050: [Chromoting] Hook up host talkgadget policy checks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
Index: remoting/host/signaling_connector.cc
diff --git a/remoting/host/signaling_connector.cc b/remoting/host/signaling_connector.cc
index 9e95219a39f1540e52bb31e66cab17985bc7ed01..dca5f3ca45626d52b5da98d91082b1f1c0d06357 100644
--- a/remoting/host/signaling_connector.cc
+++ b/remoting/host/signaling_connector.cc
@@ -6,7 +6,9 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "net/url_request/url_fetcher.h"
#include "remoting/host/chromoting_host_context.h"
+#include "remoting/host/constants.h"
#include "remoting/host/url_request_context.h"
namespace remoting {
@@ -33,15 +35,21 @@ SignalingConnector::OAuthCredentials::OAuthCredentials(
SignalingConnector::SignalingConnector(
XmppSignalStrategy* signal_strategy,
+ ChromotingHostContext* context,
+ std::string talkgadget_prefix,
const base::Closure& auth_failed_callback)
: signal_strategy_(signal_strategy),
+ context_(context),
auth_failed_callback_(auth_failed_callback),
+ talkgadget_prefix_(talkgadget_prefix),
+ found_talkgadget_(false),
reconnect_attempts_(0),
refreshing_oauth_token_(false) {
DCHECK(!auth_failed_callback_.is_null());
net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
net::NetworkChangeNotifier::AddIPAddressObserver(this);
signal_strategy_->AddListener(this);
+ LOG(INFO) << "Creating SignalingConnector";
ScheduleTryReconnect();
}
@@ -52,13 +60,14 @@ SignalingConnector::~SignalingConnector() {
}
void SignalingConnector::EnableOAuth(
- scoped_ptr<OAuthCredentials> oauth_credentials,
- net::URLRequestContextGetter* url_context) {
+ scoped_ptr<OAuthCredentials> oauth_credentials) {
+ LOG(INFO) << "Enabling OAuth";
oauth_credentials_ = oauth_credentials.Pass();
gaia_oauth_client_.reset(new GaiaOAuthClient(
- OAuthProviderInfo::GetDefault(), url_context));
+ OAuthProviderInfo::GetDefault(), context_->url_request_context_getter()));
}
+// SignalStrategy::Listener interface.
void SignalingConnector::OnSignalStrategyStateChange(
SignalStrategy::State state) {
DCHECK(CalledOnValidThread());
@@ -85,12 +94,22 @@ bool SignalingConnector::OnSignalStrategyIncomingStanza(
return false;
}
-void SignalingConnector::OnIPAddressChanged() {
- DCHECK(CalledOnValidThread());
- LOG(INFO) << "IP address has changed.";
- ResetAndTryReconnect();
+// net::URLFetcherDelegate interface.
+void SignalingConnector::OnURLFetchComplete(const net::URLFetcher* source) {
+ LOG(INFO) << "URLFetch returned " << source->GetResponseCode();
+ int response = source->GetResponseCode();
+ if (response == 200) {
+ found_talkgadget_ = true;
+ url_fetcher_.reset(NULL);
+ TryReconnect();
+ return;
+ }
+ LOG(INFO) << "Scheduling a reconnect";
+ reconnect_attempts_++;
+ ScheduleTryReconnect();
}
+// NetworkChangeNotifier::ConnectionTypeObserver interface.
void SignalingConnector::OnConnectionTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) {
DCHECK(CalledOnValidThread());
@@ -100,6 +119,14 @@ void SignalingConnector::OnConnectionTypeChanged(
}
}
+// NetworkChangeNotifier::IPAddressObserver interface.
+void SignalingConnector::OnIPAddressChanged() {
+ DCHECK(CalledOnValidThread());
+ LOG(INFO) << "IP address has changed.";
+ ResetAndTryReconnect();
+}
+
+// GaiaOAuthClient::Delegate interface.
void SignalingConnector::OnRefreshTokenResponse(const std::string& user_email,
const std::string& access_token,
int expires_seconds) {
@@ -163,7 +190,25 @@ void SignalingConnector::ResetAndTryReconnect() {
void SignalingConnector::TryReconnect() {
DCHECK(CalledOnValidThread());
+
+ if (!found_talkgadget_) {
+ std::string talkgadget_url("https://");
+ if (talkgadget_prefix_.empty()) {
+ talkgadget_url += kDefaultHostTalkGadgetPrefix;
+ } else {
+ talkgadget_url += talkgadget_prefix_;
+ }
+ talkgadget_url += kTalkGadgetURL;
+ LOG(INFO) << "Checking access 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();
+ return;
+ }
+
if (signal_strategy_->GetState() == SignalStrategy::DISCONNECTED) {
+
bool need_new_auth_token = oauth_credentials_.get() &&
(auth_token_expiry_time_.is_null() ||
base::Time::Now() >= auth_token_expiry_time_);
« remoting/host/remoting_me2me_host.cc ('K') | « remoting/host/signaling_connector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698