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

Side by Side Diff: jingle/notifier/communicator/single_login_attempt.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "jingle/notifier/communicator/single_login_attempt.h" 7 #include "jingle/notifier/communicator/single_login_attempt.h"
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 21 matching lines...) Expand all
32 current_settings_(settings_list_.begin()) { 32 current_settings_(settings_list_.begin()) {
33 if (settings_list_.empty()) { 33 if (settings_list_.empty()) {
34 NOTREACHED(); 34 NOTREACHED();
35 return; 35 return;
36 } 36 }
37 TryConnect(*current_settings_); 37 TryConnect(*current_settings_);
38 } 38 }
39 39
40 SingleLoginAttempt::~SingleLoginAttempt() {} 40 SingleLoginAttempt::~SingleLoginAttempt() {}
41 41
42 // In the code below, we assume that calling a delegate method may end
43 // up in ourselves being deleted, so we always call it last.
44 //
45 // TODO(akalin): Add unit tests to enforce the behavior above.
46
42 void SingleLoginAttempt::OnConnect( 47 void SingleLoginAttempt::OnConnect(
43 base::WeakPtr<buzz::XmppTaskParentInterface> base_task) { 48 base::WeakPtr<buzz::XmppTaskParentInterface> base_task) {
44 DVLOG(1) << "Connected to " << current_settings_->ToString(); 49 DVLOG(1) << "Connected to " << current_settings_->ToString();
45 delegate_->OnConnect(base_task); 50 delegate_->OnConnect(base_task);
46 } 51 }
47 52
48 namespace { 53 namespace {
49 54
50 // This function is more permissive than 55 // This function is more permissive than
51 // net::HostPortPair::FromString(). If the port is missing or 56 // net::HostPortPair::FromString(). If the port is missing or
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 ServerInformation( 129 ServerInformation(
125 redirect_server, 130 redirect_server,
126 current_settings_->ssltcp_support)); 131 current_settings_->ssltcp_support));
127 // May be deleted at this point. 132 // May be deleted at this point.
128 return; 133 return;
129 } 134 }
130 } 135 }
131 } 136 }
132 } 137 }
133 138
139 if (error == buzz::XmppEngine::ERROR_UNAUTHORIZED) {
140 delegate_->OnCredentialsRejected();
141 return;
142 }
143
134 if (current_settings_ == settings_list_.end()) { 144 if (current_settings_ == settings_list_.end()) {
135 NOTREACHED(); 145 NOTREACHED();
136 return; 146 return;
137 } 147 }
138 148
139 ++current_settings_; 149 ++current_settings_;
140 if (current_settings_ == settings_list_.end()) { 150 if (current_settings_ == settings_list_.end()) {
141 VLOG(1) << "Could not connect to any XMPP server"; 151 VLOG(1) << "Could not connect to any XMPP server";
142 delegate_->OnNeedReconnect(); 152 delegate_->OnSettingsExhausted();
143 return; 153 return;
144 } 154 }
145 155
146 TryConnect(*current_settings_); 156 TryConnect(*current_settings_);
147 } 157 }
148 158
149 void SingleLoginAttempt::TryConnect( 159 void SingleLoginAttempt::TryConnect(
150 const ConnectionSettings& connection_settings) { 160 const ConnectionSettings& connection_settings) {
151 DVLOG(1) << "Trying to connect to " << connection_settings.ToString(); 161 DVLOG(1) << "Trying to connect to " << connection_settings.ToString();
152 // Copy the user settings and fill in the connection parameters from 162 // Copy the user settings and fill in the connection parameters from
153 // |connection_settings|. 163 // |connection_settings|.
154 buzz::XmppClientSettings client_settings = login_settings_.user_settings(); 164 buzz::XmppClientSettings client_settings = login_settings_.user_settings();
155 connection_settings.FillXmppClientSettings(&client_settings); 165 connection_settings.FillXmppClientSettings(&client_settings);
156 166
157 buzz::Jid jid(client_settings.user(), client_settings.host(), 167 buzz::Jid jid(client_settings.user(), client_settings.host(),
158 buzz::STR_EMPTY); 168 buzz::STR_EMPTY);
159 buzz::PreXmppAuth* pre_xmpp_auth = 169 buzz::PreXmppAuth* pre_xmpp_auth =
160 new GaiaTokenPreXmppAuth( 170 new GaiaTokenPreXmppAuth(
161 jid.Str(), client_settings.auth_token(), 171 jid.Str(), client_settings.auth_token(),
162 client_settings.token_service(), 172 client_settings.token_service(),
163 login_settings_.auth_mechanism()); 173 login_settings_.auth_mechanism());
164 xmpp_connection_.reset( 174 xmpp_connection_.reset(
165 new XmppConnection(client_settings, 175 new XmppConnection(client_settings,
166 login_settings_.request_context_getter(), 176 login_settings_.request_context_getter(),
167 this, 177 this,
168 pre_xmpp_auth)); 178 pre_xmpp_auth));
169 } 179 }
170 180
171 } // namespace notifier 181 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698