summaryrefslogtreecommitdiffstats
path: root/jingle/notifier/communicator
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-22 20:07:51 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-22 20:07:51 +0000
commit1eb35c3e087bd291fc9d10a6a9e2f3172998f23d (patch)
tree576da9a1a123c934394f9f33483b1e41d1c6453e /jingle/notifier/communicator
parent80d1a8c2443c3dc71de5f94f4ca5e7f3a9f6b052 (diff)
downloadchromium_src-1eb35c3e087bd291fc9d10a6a9e2f3172998f23d.zip
chromium_src-1eb35c3e087bd291fc9d10a6a9e2f3172998f23d.tar.gz
chromium_src-1eb35c3e087bd291fc9d10a6a9e2f3172998f23d.tar.bz2
[Jingle] Refactored some notifier-related structs/classes
Moved ServerInformation into its own header and added ServerList typedef. Added notifier_options_util.{h,cc}. BUG=None Review URL: http://codereview.chromium.org/6708076 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79026 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle/notifier/communicator')
-rw-r--r--jingle/notifier/communicator/const_communicator.h13
-rw-r--r--jingle/notifier/communicator/gaia_token_pre_xmpp_auth.cc115
-rw-r--r--jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h65
-rw-r--r--jingle/notifier/communicator/login.cc8
-rw-r--r--jingle/notifier/communicator/login.h7
-rw-r--r--jingle/notifier/communicator/login_settings.cc21
-rw-r--r--jingle/notifier/communicator/login_settings.h20
-rw-r--r--jingle/notifier/communicator/single_login_attempt.cc9
-rw-r--r--jingle/notifier/communicator/xmpp_connection_generator.cc35
-rw-r--r--jingle/notifier/communicator/xmpp_connection_generator.h22
-rw-r--r--jingle/notifier/communicator/xmpp_connection_generator_unittest.cc12
11 files changed, 54 insertions, 273 deletions
diff --git a/jingle/notifier/communicator/const_communicator.h b/jingle/notifier/communicator/const_communicator.h
deleted file mode 100644
index 5f49a62..0000000
--- a/jingle/notifier/communicator/const_communicator.h
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (c) 2009 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.
-
-#ifndef JINGLE_NOTIFIER_COMMUNICATOR_CONST_COMMUNICATOR_H_
-#define JINGLE_NOTIFIER_COMMUNICATOR_CONST_COMMUNICATOR_H_
-
-namespace notifier {
-// The default port for jabber/xmpp communications.
-const int kDefaultXmppPort = 5222;
-} // namespace notifier
-
-#endif // JINGLE_NOTIFIER_COMMUNICATOR_CONST_COMMUNICATOR_H_
diff --git a/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.cc b/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.cc
deleted file mode 100644
index eb42e6a..0000000
--- a/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (c) 2010 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 "jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h"
-
-#include <algorithm>
-
-#include "base/basictypes.h"
-#include "base/logging.h"
-#include "talk/base/socketaddress.h"
-#include "talk/xmpp/constants.h"
-#include "talk/xmpp/saslcookiemechanism.h"
-
-namespace notifier {
-
-namespace {
-
-class GaiaCookieMechanism : public buzz::SaslCookieMechanism {
- public:
- GaiaCookieMechanism(const std::string & mechanism,
- const std::string & username,
- const std::string & cookie,
- const std::string & token_service)
- : buzz::SaslCookieMechanism(
- mechanism, username, cookie, token_service) {}
-
- virtual ~GaiaCookieMechanism() {}
-
- virtual buzz::XmlElement* StartSaslAuth() {
- buzz::XmlElement* auth = buzz::SaslCookieMechanism::StartSaslAuth();
- // These attributes are necessary for working with non-gmail gaia
- // accounts.
- const std::string NS_GOOGLE_AUTH_PROTOCOL(
- "http://www.google.com/talk/protocol/auth");
- const buzz::QName QN_GOOGLE_ALLOW_GENERATED_JID_XMPP_LOGIN(
- true, NS_GOOGLE_AUTH_PROTOCOL, "allow-generated-jid");
- const buzz::QName QN_GOOGLE_AUTH_CLIENT_USES_FULL_BIND_RESULT(
- true, NS_GOOGLE_AUTH_PROTOCOL, "client-uses-full-bind-result");
- auth->SetAttr(QN_GOOGLE_ALLOW_GENERATED_JID_XMPP_LOGIN, "true");
- auth->SetAttr(QN_GOOGLE_AUTH_CLIENT_USES_FULL_BIND_RESULT, "true");
- return auth;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(GaiaCookieMechanism);
-};
-
-} // namespace
-
-// By default use a Google cookie auth mechanism.
-const char GaiaTokenPreXmppAuth::kDefaultAuthMechanism[] = "X-GOOGLE-TOKEN";
-
-GaiaTokenPreXmppAuth::GaiaTokenPreXmppAuth(
- const std::string& username,
- const std::string& token,
- const std::string& token_service,
- const std::string& auth_mechanism)
- : username_(username),
- token_(token),
- token_service_(token_service),
- auth_mechanism_(auth_mechanism) {
- DCHECK(!auth_mechanism_.empty());
-}
-
-GaiaTokenPreXmppAuth::~GaiaTokenPreXmppAuth() { }
-
-void GaiaTokenPreXmppAuth::StartPreXmppAuth(
- const buzz::Jid& jid,
- const talk_base::SocketAddress& server,
- const talk_base::CryptString& pass,
- const std::string& auth_cookie) {
- SignalAuthDone();
-}
-
-bool GaiaTokenPreXmppAuth::IsAuthDone() const {
- return true;
-}
-
-bool GaiaTokenPreXmppAuth::IsAuthorized() const {
- return true;
-}
-
-bool GaiaTokenPreXmppAuth::HadError() const {
- return false;
-}
-
-int GaiaTokenPreXmppAuth::GetError() const {
- return 0;
-}
-
-buzz::CaptchaChallenge GaiaTokenPreXmppAuth::GetCaptchaChallenge() const {
- return buzz::CaptchaChallenge();
-}
-
-std::string GaiaTokenPreXmppAuth::GetAuthCookie() const {
- return std::string();
-}
-
-std::string GaiaTokenPreXmppAuth::ChooseBestSaslMechanism(
- const std::vector<std::string> & mechanisms, bool encrypted) {
- return (std::find(mechanisms.begin(),
- mechanisms.end(), auth_mechanism_) !=
- mechanisms.end()) ? auth_mechanism_ : "";
-}
-
-buzz::SaslMechanism* GaiaTokenPreXmppAuth::CreateSaslMechanism(
- const std::string& mechanism) {
- if (mechanism == auth_mechanism_)
- return new GaiaCookieMechanism(
- mechanism, username_, token_, token_service_);
- return NULL;
-}
-
-} // namespace notifier
diff --git a/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h b/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h
deleted file mode 100644
index 9f7f035..0000000
--- a/jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2010 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.
-
-#ifndef JINGLE_NOTIFIER_COMMUNICATOR_GAIA_TOKEN_PRE_XMPP_AUTH_H_
-#define JINGLE_NOTIFIER_COMMUNICATOR_GAIA_TOKEN_PRE_XMPP_AUTH_H_
-
-#include <string>
-#include <vector>
-
-#include "talk/xmpp/prexmppauth.h"
-
-namespace notifier {
-
-// This class implements buzz::PreXmppAuth interface for token-based
-// authentication in GTalk. It looks for the X-GOOGLE-TOKEN auth mechanism
-// and uses that instead of the default auth mechanism (PLAIN).
-class GaiaTokenPreXmppAuth : public buzz::PreXmppAuth {
- public:
- GaiaTokenPreXmppAuth(const std::string& username, const std::string& token,
- const std::string& token_service,
- const std::string& auth_mechanism);
-
- virtual ~GaiaTokenPreXmppAuth();
-
- // buzz::PreXmppAuth (-buzz::SaslHandler) implementation. We stub
- // all the methods out as we don't actually do any authentication at
- // this point.
- virtual void StartPreXmppAuth(const buzz::Jid& jid,
- const talk_base::SocketAddress& server,
- const talk_base::CryptString& pass,
- const std::string& auth_cookie);
-
- virtual bool IsAuthDone() const;
-
- virtual bool IsAuthorized() const;
-
- virtual bool HadError() const;
-
- virtual int GetError() const;
-
- virtual buzz::CaptchaChallenge GetCaptchaChallenge() const;
-
- virtual std::string GetAuthCookie() const;
-
- // buzz::SaslHandler implementation.
-
- virtual std::string ChooseBestSaslMechanism(
- const std::vector<std::string>& mechanisms, bool encrypted);
-
- virtual buzz::SaslMechanism* CreateSaslMechanism(
- const std::string& mechanism);
-
- static const char kDefaultAuthMechanism[];
-
- private:
- std::string username_;
- std::string token_;
- std::string token_service_;
- std::string auth_mechanism_;
-};
-
-} // namespace notifier
-
-#endif // JINGLE_NOTIFIER_COMMUNICATOR_GAIA_TOKEN_PRE_XMPP_AUTH_H_
diff --git a/jingle/notifier/communicator/login.cc b/jingle/notifier/communicator/login.cc
index 98d644b..3e21db7 100644
--- a/jingle/notifier/communicator/login.cc
+++ b/jingle/notifier/communicator/login.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -35,8 +35,7 @@ Login::Login(Delegate* delegate,
const ConnectionOptions& options,
net::HostResolver* host_resolver,
net::CertVerifier* cert_verifier,
- ServerInformation* server_list,
- int server_count,
+ const ServerList& servers,
bool try_ssltcp_first,
const std::string& auth_mechanism)
: delegate_(delegate),
@@ -44,8 +43,7 @@ Login::Login(Delegate* delegate,
options,
host_resolver,
cert_verifier,
- server_list,
- server_count,
+ servers,
try_ssltcp_first,
auth_mechanism)),
redirect_port_(0) {
diff --git a/jingle/notifier/communicator/login.h b/jingle/notifier/communicator/login.h
index 7652bf1..0e5b11b 100644
--- a/jingle/notifier/communicator/login.h
+++ b/jingle/notifier/communicator/login.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -11,6 +11,7 @@
#include "base/time.h"
#include "base/timer.h"
#include "base/weak_ptr.h"
+#include "jingle/notifier/base/server_information.h"
#include "jingle/notifier/communicator/single_login_attempt.h"
#include "net/base/network_change_notifier.h"
#include "talk/xmpp/xmppengine.h"
@@ -35,7 +36,6 @@ namespace notifier {
class ConnectionOptions;
class LoginSettings;
-struct ServerInformation;
// Workaround for MSVS 2005 bug that fails to handle inheritance from a nested
// class properly if it comes directly on a base class list.
@@ -62,8 +62,7 @@ class Login : public net::NetworkChangeNotifier::IPAddressObserver,
const ConnectionOptions& options,
net::HostResolver* host_resolver,
net::CertVerifier* cert_verifier,
- ServerInformation* server_list,
- int server_count,
+ const ServerList& servers,
bool try_ssltcp_first,
const std::string& auth_mechanism);
virtual ~Login();
diff --git a/jingle/notifier/communicator/login_settings.cc b/jingle/notifier/communicator/login_settings.cc
index 6345810..6ed3a8c 100644
--- a/jingle/notifier/communicator/login_settings.cc
+++ b/jingle/notifier/communicator/login_settings.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -7,6 +7,7 @@
#include "jingle/notifier/communicator/login_settings.h"
#include "base/logging.h"
+#include "jingle/notifier/base/server_information.h"
#include "jingle/notifier/communicator/connection_options.h"
#include "jingle/notifier/communicator/xmpp_connection_generator.h"
#include "net/base/cert_verifier.h"
@@ -20,26 +21,19 @@ LoginSettings::LoginSettings(const buzz::XmppClientSettings& user_settings,
const ConnectionOptions& options,
net::HostResolver* host_resolver,
net::CertVerifier* cert_verifier,
- ServerInformation* server_list,
- int server_count,
+ const ServerList& servers,
bool try_ssltcp_first,
const std::string& auth_mechanism)
: try_ssltcp_first_(try_ssltcp_first),
host_resolver_(host_resolver),
cert_verifier_(cert_verifier),
- server_list_(new ServerInformation[server_count]),
- server_count_(server_count),
+ servers_(servers),
user_settings_(new buzz::XmppClientSettings(user_settings)),
connection_options_(new ConnectionOptions(options)),
auth_mechanism_(auth_mechanism) {
- // Note: firewall may be NULL.
- DCHECK(server_list);
DCHECK(host_resolver);
DCHECK(cert_verifier);
- DCHECK_GT(server_count, 0);
- for (int i = 0; i < server_count_; ++i) {
- server_list_[i] = server_list[i];
- }
+ DCHECK_GT(servers_.size(), 0u);
}
// Defined so that the destructors are executed here (and the corresponding
@@ -49,9 +43,8 @@ LoginSettings::~LoginSettings() {
void LoginSettings::set_server_override(
const net::HostPortPair& server) {
- server_override_.reset(new ServerInformation());
- server_override_->server = server;
- server_override_->special_port_magic = server_list_[0].special_port_magic;
+ server_override_.reset(
+ new ServerInformation(server, servers_[0].special_port_magic));
}
void LoginSettings::clear_server_override() {
diff --git a/jingle/notifier/communicator/login_settings.h b/jingle/notifier/communicator/login_settings.h
index 812022b..5bc8160 100644
--- a/jingle/notifier/communicator/login_settings.h
+++ b/jingle/notifier/communicator/login_settings.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -6,8 +6,8 @@
#define JINGLE_NOTIFIER_COMMUNICATOR_LOGIN_SETTINGS_H_
#include <string>
+#include "jingle/notifier/base/server_information.h"
#include "jingle/notifier/communicator/xmpp_connection_generator.h"
-#include "talk/base/scoped_ptr.h"
namespace buzz {
class XmppClientSettings;
@@ -25,7 +25,6 @@ class SocketAddress;
namespace notifier {
class ConnectionOptions;
-struct ServerInformation;
class LoginSettings {
public:
@@ -33,8 +32,7 @@ class LoginSettings {
const ConnectionOptions& options,
net::HostResolver* host_resolver,
net::CertVerifier* cert_verifier,
- ServerInformation* server_list,
- int server_count,
+ const ServerList& servers,
bool try_ssltcp_first,
const std::string& auth_mechanism);
@@ -52,12 +50,9 @@ class LoginSettings {
return cert_verifier_;
}
- const ServerInformation* server_list() const {
- return server_override_.get() ? server_override_.get() : server_list_.get();
- }
-
- int server_count() const {
- return server_override_.get() ? 1 : server_count_;
+ ServerList servers() const {
+ return
+ server_override_.get() ? ServerList(1, *server_override_) : servers_;
}
const buzz::XmppClientSettings& user_settings() const {
@@ -84,8 +79,7 @@ class LoginSettings {
net::HostResolver* const host_resolver_;
net::CertVerifier* const cert_verifier_;
- talk_base::scoped_array<ServerInformation> server_list_;
- int server_count_;
+ const ServerList servers_;
// Used to handle redirects
scoped_ptr<ServerInformation> server_override_;
diff --git a/jingle/notifier/communicator/single_login_attempt.cc b/jingle/notifier/communicator/single_login_attempt.cc
index 5bfe6e3..2cf99d3 100644
--- a/jingle/notifier/communicator/single_login_attempt.cc
+++ b/jingle/notifier/communicator/single_login_attempt.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -11,10 +11,10 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
+#include "jingle/notifier/base/const_communicator.h"
+#include "jingle/notifier/base/gaia_token_pre_xmpp_auth.h"
#include "jingle/notifier/communicator/connection_options.h"
#include "jingle/notifier/communicator/connection_settings.h"
-#include "jingle/notifier/communicator/const_communicator.h"
-#include "jingle/notifier/communicator/gaia_token_pre_xmpp_auth.h"
#include "jingle/notifier/communicator/login_settings.h"
#include "jingle/notifier/listener/xml_element_util.h"
#include "talk/xmllite/xmlelement.h"
@@ -37,8 +37,7 @@ SingleLoginAttempt::SingleLoginAttempt(LoginSettings* login_settings,
login_settings_->host_resolver(),
&login_settings_->connection_options(),
login_settings_->try_ssltcp_first(),
- login_settings_->server_list(),
- login_settings_->server_count()) {
+ login_settings_->servers()) {
connection_generator_.StartGenerating();
}
diff --git a/jingle/notifier/communicator/xmpp_connection_generator.cc b/jingle/notifier/communicator/xmpp_connection_generator.cc
index c1ca8d2..77282e7 100644
--- a/jingle/notifier/communicator/xmpp_connection_generator.cc
+++ b/jingle/notifier/communicator/xmpp_connection_generator.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
//
@@ -23,6 +23,7 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
+#include "jingle/notifier/base/server_information.h"
#include "jingle/notifier/communicator/connection_options.h"
#include "jingle/notifier/communicator/connection_settings.h"
#include "net/base/net_errors.h"
@@ -41,8 +42,7 @@ XmppConnectionGenerator::XmppConnectionGenerator(
net::HostResolver* host_resolver,
const ConnectionOptions* options,
bool try_ssltcp_first,
- const ServerInformation* server_list,
- int server_count)
+ const ServerList& servers)
: delegate_(delegate),
host_resolver_(host_resolver),
resolve_callback_(
@@ -51,9 +51,8 @@ XmppConnectionGenerator::XmppConnectionGenerator(
&XmppConnectionGenerator::OnServerDNSResolved))),
settings_list_(new ConnectionSettingsList()),
settings_index_(0),
- server_list_(new ServerInformation[server_count]),
- server_count_(server_count),
- server_index_(-1),
+ servers_(servers),
+ current_server_(servers_.end()),
try_ssltcp_first_(try_ssltcp_first),
successfully_resolved_dns_(false),
first_dns_error_(0),
@@ -61,10 +60,7 @@ XmppConnectionGenerator::XmppConnectionGenerator(
DCHECK(delegate_);
DCHECK(host_resolver);
DCHECK(options_);
- DCHECK_GT(server_count_, 0);
- for (int i = 0; i < server_count_; ++i) {
- server_list_[i] = server_list[i];
- }
+ DCHECK_GT(servers_.size(), 0u);
}
XmppConnectionGenerator::~XmppConnectionGenerator() {
@@ -109,8 +105,12 @@ void XmppConnectionGenerator::UseNextConnection() {
}
// Iterate to the next possible server.
- server_index_++;
- if (server_index_ >= server_count_) {
+ if (current_server_ == servers_.end()) {
+ current_server_ = servers_.begin();
+ } else {
+ ++current_server_;
+ }
+ if (current_server_ == servers_.end()) {
// All out of possibilities.
VLOG(1) << "(" << buzz::XmppEngine::ERROR_SOCKET
<< ", " << first_dns_error_ << ")";
@@ -120,8 +120,7 @@ void XmppConnectionGenerator::UseNextConnection() {
}
// Resolve the server.
- const net::HostPortPair& server =
- server_list_[server_index_].server;
+ const net::HostPortPair& server = current_server_->server;
net::HostResolver::RequestInfo request_info(server);
int status =
host_resolver_.Resolve(
@@ -146,7 +145,7 @@ void XmppConnectionGenerator::HandleServerDNSResolved(int status) {
DCHECK_NE(status, net::ERR_IO_PENDING);
VLOG(1) << "XmppConnectionGenerator::HandleServerDNSResolved";
// Print logging info.
- VLOG(1) << " server: " << server_list_[server_index_].server.ToString()
+ VLOG(1) << " server: " << current_server_->server.ToString()
<< ", error: " << status;
if (status != net::OK) {
if (first_dns_error_ == 0)
@@ -175,10 +174,10 @@ void XmppConnectionGenerator::HandleServerDNSResolved(int status) {
settings_index_ = -1;
settings_list_->ClearPermutations();
settings_list_->AddPermutations(
- server_list_[server_index_].server.host(),
+ current_server_->server.host(),
ip_list,
- server_list_[server_index_].server.port(),
- server_list_[server_index_].special_port_magic,
+ current_server_->server.port(),
+ current_server_->special_port_magic,
try_ssltcp_first_);
}
diff --git a/jingle/notifier/communicator/xmpp_connection_generator.h b/jingle/notifier/communicator/xmpp_connection_generator.h
index 0c3085c..176bd4f 100644
--- a/jingle/notifier/communicator/xmpp_connection_generator.h
+++ b/jingle/notifier/communicator/xmpp_connection_generator.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -7,13 +7,12 @@
#include <vector>
-#include "base/ref_counted.h"
+#include "base/scoped_ptr.h"
#include "net/base/address_list.h"
#include "net/base/completion_callback.h"
-#include "net/base/host_port_pair.h"
#include "net/base/host_resolver.h"
#include "net/base/net_log.h"
-#include "talk/base/scoped_ptr.h"
+#include "jingle/notifier/base/server_information.h"
namespace talk_base {
struct ProxyInfo;
@@ -26,11 +25,6 @@ class ConnectionOptions;
class ConnectionSettings;
class ConnectionSettingsList;
-struct ServerInformation {
- net::HostPortPair server;
- bool special_port_magic;
-};
-
// Resolves dns names and iterates through the various ip address and transport
// combinations.
class XmppConnectionGenerator {
@@ -54,8 +48,7 @@ class XmppConnectionGenerator {
net::HostResolver* host_resolver,
const ConnectionOptions* options,
bool try_ssltcp_first,
- const ServerInformation* server_list,
- int server_count);
+ const ServerList& servers);
~XmppConnectionGenerator();
// Only call this once. Create a new XmppConnectionGenerator and delete the
@@ -73,11 +66,10 @@ class XmppConnectionGenerator {
scoped_ptr<net::CompletionCallback> resolve_callback_;
net::AddressList address_list_;
net::BoundNetLog bound_net_log_;
- talk_base::scoped_ptr<ConnectionSettingsList> settings_list_;
+ scoped_ptr<ConnectionSettingsList> settings_list_;
int settings_index_; // The setting that is currently being used.
- talk_base::scoped_array<ServerInformation> server_list_;
- int server_count_;
- int server_index_; // The server that is current being used.
+ const ServerList servers_;
+ ServerList::const_iterator current_server_;
bool try_ssltcp_first_; // Used when sync tests are run on chromium builders.
bool successfully_resolved_dns_;
int first_dns_error_;
diff --git a/jingle/notifier/communicator/xmpp_connection_generator_unittest.cc b/jingle/notifier/communicator/xmpp_connection_generator_unittest.cc
index 70d24a0..daa421f 100644
--- a/jingle/notifier/communicator/xmpp_connection_generator_unittest.cc
+++ b/jingle/notifier/communicator/xmpp_connection_generator_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -27,9 +27,9 @@ class MockXmppConnectionGeneratorDelegate
};
const ServerInformation kXmppServers[] = {
- { net::HostPortPair("www.foo.com", 5222), true },
- { net::HostPortPair("www.bar.com", 8080), false },
- { net::HostPortPair("www.baz.com", 80), true },
+ ServerInformation(net::HostPortPair("www.foo.com", 5222), true),
+ ServerInformation(net::HostPortPair("www.bar.com", 8080), false),
+ ServerInformation(net::HostPortPair("www.baz.com", 80), true),
};
class XmppConnectionGeneratorTest : public testing::Test {
@@ -40,8 +40,8 @@ class XmppConnectionGeneratorTest : public testing::Test {
&mock_host_resolver_,
&connection_options_,
false /* try_ssltcp_first */,
- kXmppServers,
- arraysize(kXmppServers)) {}
+ ServerList(kXmppServers,
+ kXmppServers + arraysize(kXmppServers))) {}
virtual ~XmppConnectionGeneratorTest() {}