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

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: Cleanup logging 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..48bb0c7eacdefc288d7f09b1b121089c292fb6de 100644
--- a/remoting/host/signaling_connector.cc
+++ b/remoting/host/signaling_connector.cc
@@ -6,7 +6,10 @@
#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/connection_block_checker.h"
+#include "remoting/host/constants.h"
#include "remoting/host/url_request_context.h"
namespace remoting {
@@ -33,8 +36,11 @@ 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),
reconnect_attempts_(0),
refreshing_oauth_token_(false) {
@@ -42,6 +48,10 @@ SignalingConnector::SignalingConnector(
net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
net::NetworkChangeNotifier::AddIPAddressObserver(this);
signal_strategy_->AddListener(this);
+ connection_block_checker_.reset(
+ new ConnectionBlockChecker(context_, talkgadget_prefix,
+ base::Bind(&SignalingConnector::OnConnectionBlockCheckerDone,
+ base::Unretained(this))));
ScheduleTryReconnect();
}
@@ -52,11 +62,10 @@ SignalingConnector::~SignalingConnector() {
}
void SignalingConnector::EnableOAuth(
- scoped_ptr<OAuthCredentials> oauth_credentials,
- net::URLRequestContextGetter* url_context) {
+ scoped_ptr<OAuthCredentials> oauth_credentials) {
oauth_credentials_ = oauth_credentials.Pass();
gaia_oauth_client_.reset(new GaiaOAuthClient(
- OAuthProviderInfo::GetDefault(), url_context));
+ OAuthProviderInfo::GetDefault(), context_->url_request_context_getter()));
}
void SignalingConnector::OnSignalStrategyStateChange(
@@ -85,12 +94,6 @@ bool SignalingConnector::OnSignalStrategyIncomingStanza(
return false;
}
-void SignalingConnector::OnIPAddressChanged() {
- DCHECK(CalledOnValidThread());
- LOG(INFO) << "IP address has changed.";
- ResetAndTryReconnect();
-}
-
void SignalingConnector::OnConnectionTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) {
DCHECK(CalledOnValidThread());
@@ -100,6 +103,12 @@ void SignalingConnector::OnConnectionTypeChanged(
}
}
+void SignalingConnector::OnIPAddressChanged() {
+ DCHECK(CalledOnValidThread());
+ LOG(INFO) << "IP address has changed.";
+ ResetAndTryReconnect();
+}
+
void SignalingConnector::OnRefreshTokenResponse(const std::string& user_email,
const std::string& access_token,
int expires_seconds) {
@@ -147,7 +156,7 @@ void SignalingConnector::ScheduleTryReconnect() {
DCHECK(CalledOnValidThread());
if (timer_.IsRunning() || net::NetworkChangeNotifier::IsOffline())
return;
- int delay_s = std::min(1 << (reconnect_attempts_ * 2),
+ int delay_s = std::min(1 << reconnect_attempts_,
kMaxReconnectDelaySeconds);
timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(delay_s),
this, &SignalingConnector::TryReconnect);
@@ -163,6 +172,26 @@ void SignalingConnector::ResetAndTryReconnect() {
void SignalingConnector::TryReconnect() {
DCHECK(CalledOnValidThread());
+ DCHECK(connection_block_checker_.get());
+
+ // This will check if this machine is allowed to access the chromoting
+ // host talkgadget. OnConnectionBlockCheckerDone will be called with the
Sergey Ulanov 2012/08/29 20:10:29 You would need this comment if callback was passed
garykac 2012/08/29 22:30:51 Done.
+ // result of this check.
+ connection_block_checker_->CheckStatus();
+}
+
+void SignalingConnector::OnConnectionBlockCheckerDone(bool allow) {
+ DCHECK(CalledOnValidThread());
+
+ // Access to the host talkgadget is blocked. Don't allow the connection, but
+ // schedule a reconnect in case this is a transient problem.
+ if (!allow) {
+ reconnect_attempts_++;
+ LOG(INFO) << "Scheduling reconnect. Attempt " << reconnect_attempts_;
+ ScheduleTryReconnect();
+ return;
+ }
+
if (signal_strategy_->GetState() == SignalStrategy::DISCONNECTED) {
bool need_new_auth_token = oauth_credentials_.get() &&
(auth_token_expiry_time_.is_null() ||

Powered by Google App Engine
This is Rietveld 408576698