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

Unified Diff: jingle/notifier/communicator/login.cc

Issue 10545170: [Sync] Propagate XMPP auth errors to SyncNotifierObservers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix deps, win compile error Created 8 years, 6 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: jingle/notifier/communicator/login.cc
diff --git a/jingle/notifier/communicator/login.cc b/jingle/notifier/communicator/login.cc
index 886ea848c2ed125c00107c5797548034a19fe612..db4813b433b324ce37980abcf73122c7d3e2a4ab 100644
--- a/jingle/notifier/communicator/login.cc
+++ b/jingle/notifier/communicator/login.cc
@@ -27,6 +27,8 @@ namespace notifier {
// Redirect valid for 5 minutes.
static const int kRedirectTimeoutMinutes = 5;
+Login::Delegate::~Delegate() {}
+
Login::Login(Delegate* delegate,
const buzz::XmppClientSettings& user_settings,
const scoped_refptr<net::URLRequestContextGetter>&
@@ -57,19 +59,31 @@ void Login::UpdateXmppSettings(const buzz::XmppClientSettings& user_settings) {
login_settings_.set_user_settings(user_settings);
}
+// In the code below, we assume that calling a delegate method may end
+// up in ourselves being deleted, so we always call it last.
+//
+// TODO(akalin): Add unit tests to enforce the behavior above.
+
void Login::OnConnect(base::WeakPtr<buzz::XmppTaskParentInterface> base_task) {
ResetReconnectState();
delegate_->OnConnect(base_task);
}
-void Login::OnNeedReconnect() {
- TryReconnect();
-}
-
void Login::OnRedirect(const ServerInformation& redirect_server) {
login_settings_.SetRedirectServer(redirect_server);
// Drop the current connection, and start the login process again.
StartConnection();
+ delegate_->OnTransientDisconnection();
+}
+
+void Login::OnCredentialsRejected() {
+ TryReconnect();
+ delegate_->OnCredentialsRejected();
+}
+
+void Login::OnSettingsExhausted() {
+ TryReconnect();
+ delegate_->OnTransientDisconnection();
}
void Login::OnIPAddressChanged() {
@@ -78,6 +92,7 @@ void Login::OnIPAddressChanged() {
// avoid spikey behavior on network hiccups).
reconnect_interval_ = base::TimeDelta::FromSeconds(base::RandInt(1, 9));
TryReconnect();
+ delegate_->OnTransientDisconnection();
}
void Login::ResetReconnectState() {
@@ -94,7 +109,6 @@ void Login::TryReconnect() {
<< reconnect_interval_.InSeconds() << " seconds";
reconnect_timer_.Start(
FROM_HERE, reconnect_interval_, this, &Login::DoReconnect);
- delegate_->OnDisconnect();
}
void Login::DoReconnect() {

Powered by Google App Engine
This is Rietveld 408576698