diff options
author | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-19 20:36:30 +0000 |
---|---|---|
committer | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-19 20:36:30 +0000 |
commit | 49554f0311d696155188b34e890ef2dca0a07414 (patch) | |
tree | 9fb3796c58f6d6a256a3639b7118a91ef2f968c8 /jingle | |
parent | e18a19b149d4a88701a45873307e03d866a01565 (diff) | |
download | chromium_src-49554f0311d696155188b34e890ef2dca0a07414.zip chromium_src-49554f0311d696155188b34e890ef2dca0a07414.tar.gz chromium_src-49554f0311d696155188b34e890ef2dca0a07414.tar.bz2 |
Revert 62699 - [Sync] Added some switches for testing/debugging.
Added back in --sync-invalidate-xmpp-login (now, not only in debug mode!).
Added --sync-allow-insecure-xmpp-connection, which enables sync to
connect to insecure XMPP servers (e.g., a local one).
Removed obsolete --use-ssl-tcp switch.
Reason for revert: Broke sync_integration_tests.
BUG=None
TEST=Manual
Review URL: http://codereview.chromium.org/3766004
TBR=akalin@chromium.org
Review URL: http://codereview.chromium.org/3906001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63097 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'jingle')
-rw-r--r-- | jingle/notifier/base/notifier_options.h | 18 | ||||
-rw-r--r-- | jingle/notifier/communicator/connection_settings.cc | 16 | ||||
-rw-r--r-- | jingle/notifier/communicator/connection_settings.h | 4 | ||||
-rw-r--r-- | jingle/notifier/communicator/login.cc | 6 | ||||
-rw-r--r-- | jingle/notifier/communicator/login.h | 3 | ||||
-rw-r--r-- | jingle/notifier/communicator/login_settings.cc | 6 | ||||
-rw-r--r-- | jingle/notifier/communicator/login_settings.h | 9 | ||||
-rw-r--r-- | jingle/notifier/communicator/single_login_attempt.cc | 1 | ||||
-rw-r--r-- | jingle/notifier/communicator/xmpp_connection_generator.cc | 5 | ||||
-rw-r--r-- | jingle/notifier/communicator/xmpp_connection_generator.h | 3 | ||||
-rw-r--r-- | jingle/notifier/listener/mediator_thread_impl.cc | 3 | ||||
-rw-r--r-- | jingle/notifier/listener/talk_mediator_impl.cc | 10 | ||||
-rw-r--r-- | jingle/notifier/listener/talk_mediator_impl.h | 4 | ||||
-rw-r--r-- | jingle/notifier/listener/talk_mediator_unittest.cc | 4 |
14 files changed, 57 insertions, 35 deletions
diff --git a/jingle/notifier/base/notifier_options.h b/jingle/notifier/base/notifier_options.h index a7a8d25..289b7d8 100644 --- a/jingle/notifier/base/notifier_options.h +++ b/jingle/notifier/base/notifier_options.h @@ -12,17 +12,19 @@ namespace notifier { struct NotifierOptions { NotifierOptions() - : allow_insecure_connection(false), - invalidate_xmpp_login(false), + : try_ssltcp_first(false), notification_method(kDefaultNotificationMethod) {} - // Indicates that insecure connections (e.g., plain authentication, - // no TLS) are allowed. Only used for testing. - bool allow_insecure_connection; + NotifierOptions(const bool try_ssltcp_first, + const net::HostPortPair& xmpp_host_port, + NotificationMethod notification_method) + : try_ssltcp_first(try_ssltcp_first), + xmpp_host_port(xmpp_host_port), + notification_method(notification_method) {} - // Indicates that the login info passed to XMPP is invalidated so - // that login fails. - bool invalidate_xmpp_login; + // Indicates that the SSLTCP port (443) is to be tried before the the XMPP + // port (5222) during login. + bool try_ssltcp_first; // Contains a custom URL and port for the notification server, if one is to // be used. Empty otherwise. diff --git a/jingle/notifier/communicator/connection_settings.cc b/jingle/notifier/communicator/connection_settings.cc index 788a106..1648c4e 100644 --- a/jingle/notifier/communicator/connection_settings.cc +++ b/jingle/notifier/communicator/connection_settings.cc @@ -41,7 +41,8 @@ ConnectionSettingsList::~ConnectionSettingsList() {} void ConnectionSettingsList::AddPermutations(const std::string& hostname, const std::vector<uint32>& iplist, int16 port, - bool special_port_magic) { + bool special_port_magic, + bool try_ssltcp_first) { // randomize the list. This ensures the iplist isn't always // evaluated in the order returned by DNS std::vector<uint32> iplist_random = iplist; @@ -59,7 +60,8 @@ void ConnectionSettingsList::AddPermutations(const std::string& hostname, if (iplist_random.empty()) { // We couldn't pre-resolve the hostname, so let's hope it will resolve // further down the pipeline (by a proxy, for example). - PermuteForAddress(server, special_port_magic, &list_temp); + PermuteForAddress(server, special_port_magic, try_ssltcp_first, + &list_temp); } else { // Generate a set of possibilities for each server address. // Don't do permute duplicates. @@ -70,7 +72,8 @@ void ConnectionSettingsList::AddPermutations(const std::string& hostname, } iplist_seen_.push_back(iplist_random[index]); server.SetResolvedIP(iplist_random[index]); - PermuteForAddress(server, special_port_magic, &list_temp); + PermuteForAddress(server, special_port_magic, try_ssltcp_first, + &list_temp); } } @@ -85,6 +88,7 @@ void ConnectionSettingsList::AddPermutations(const std::string& hostname, void ConnectionSettingsList::PermuteForAddress( const talk_base::SocketAddress& server, bool special_port_magic, + bool try_ssltcp_first, std::deque<ConnectionSettings>* list_temp) { DCHECK(list_temp); *(template_.mutable_server()) = server; @@ -97,7 +101,11 @@ void ConnectionSettingsList::PermuteForAddress( ConnectionSettings settings(template_); settings.set_protocol(cricket::PROTO_SSLTCP); settings.mutable_server()->SetPort(443); - list_temp->push_back(settings); + if (try_ssltcp_first) { + list_temp->push_front(settings); + } else { + list_temp->push_back(settings); + } } } } // namespace notifier diff --git a/jingle/notifier/communicator/connection_settings.h b/jingle/notifier/communicator/connection_settings.h index b5a1ee9..b26f559 100644 --- a/jingle/notifier/communicator/connection_settings.h +++ b/jingle/notifier/communicator/connection_settings.h @@ -48,10 +48,12 @@ class ConnectionSettingsList { void AddPermutations(const std::string& hostname, const std::vector<uint32>& iplist, int16 port, - bool special_port_magic); + bool special_port_magic, + bool try_ssltcp_first); private: void PermuteForAddress(const talk_base::SocketAddress& server, bool special_port_magic, + bool try_ssltcp_first, std::deque<ConnectionSettings>* list_temp); ConnectionSettings template_; diff --git a/jingle/notifier/communicator/login.cc b/jingle/notifier/communicator/login.cc index 1d94bfd..251a813 100644 --- a/jingle/notifier/communicator/login.cc +++ b/jingle/notifier/communicator/login.cc @@ -34,12 +34,14 @@ Login::Login(const buzz::XmppClientSettings& user_settings, const ConnectionOptions& options, net::HostResolver* host_resolver, ServerInformation* server_list, - int server_count) + int server_count, + bool try_ssltcp_first) : login_settings_(new LoginSettings(user_settings, options, host_resolver, server_list, - server_count)), + server_count, + try_ssltcp_first)), redirect_port_(0) { net::NetworkChangeNotifier::AddObserver(this); ResetReconnectState(); diff --git a/jingle/notifier/communicator/login.h b/jingle/notifier/communicator/login.h index 3ae3164a..b66ee7b 100644 --- a/jingle/notifier/communicator/login.h +++ b/jingle/notifier/communicator/login.h @@ -49,7 +49,8 @@ class Login : public net::NetworkChangeNotifier::Observer, const ConnectionOptions& options, net::HostResolver* host_resolver, ServerInformation* server_list, - int server_count); + int server_count, + bool try_ssltcp_first); virtual ~Login(); void StartConnection(); diff --git a/jingle/notifier/communicator/login_settings.cc b/jingle/notifier/communicator/login_settings.cc index 01a67fa..01b47f6 100644 --- a/jingle/notifier/communicator/login_settings.cc +++ b/jingle/notifier/communicator/login_settings.cc @@ -19,8 +19,10 @@ LoginSettings::LoginSettings(const buzz::XmppClientSettings& user_settings, const ConnectionOptions& options, net::HostResolver* host_resolver, ServerInformation* server_list, - int server_count) - : host_resolver_(host_resolver), + int server_count, + bool try_ssltcp_first) + : try_ssltcp_first_(try_ssltcp_first), + host_resolver_(host_resolver), server_list_(new ServerInformation[server_count]), server_count_(server_count), user_settings_(new buzz::XmppClientSettings(user_settings)), diff --git a/jingle/notifier/communicator/login_settings.h b/jingle/notifier/communicator/login_settings.h index 5d1f654..d97e987 100644 --- a/jingle/notifier/communicator/login_settings.h +++ b/jingle/notifier/communicator/login_settings.h @@ -32,10 +32,15 @@ class LoginSettings { const ConnectionOptions& options, net::HostResolver* host_resolver, ServerInformation* server_list, - int server_count); + int server_count, + bool try_ssltcp_first); ~LoginSettings(); + bool try_ssltcp_first() const { + return try_ssltcp_first_; + } + net::HostResolver* host_resolver() { return host_resolver_; } @@ -64,6 +69,8 @@ class LoginSettings { void clear_server_override(); private: + bool try_ssltcp_first_; + net::HostResolver* host_resolver_; talk_base::scoped_array<ServerInformation> server_list_; int server_count_; diff --git a/jingle/notifier/communicator/single_login_attempt.cc b/jingle/notifier/communicator/single_login_attempt.cc index 487b4e4..83fd21f 100644 --- a/jingle/notifier/communicator/single_login_attempt.cc +++ b/jingle/notifier/communicator/single_login_attempt.cc @@ -32,6 +32,7 @@ SingleLoginAttempt::SingleLoginAttempt(LoginSettings* login_settings) connection_generator_( login_settings_->host_resolver(), &login_settings_->connection_options(), + login_settings_->try_ssltcp_first(), login_settings_->server_list(), login_settings_->server_count()) { connection_generator_.SignalExhaustedSettings.connect( diff --git a/jingle/notifier/communicator/xmpp_connection_generator.cc b/jingle/notifier/communicator/xmpp_connection_generator.cc index 88af171..469f3d4 100644 --- a/jingle/notifier/communicator/xmpp_connection_generator.cc +++ b/jingle/notifier/communicator/xmpp_connection_generator.cc @@ -39,6 +39,7 @@ namespace notifier { XmppConnectionGenerator::XmppConnectionGenerator( net::HostResolver* host_resolver, const ConnectionOptions* options, + bool try_ssltcp_first, const ServerInformation* server_list, int server_count) : host_resolver_(host_resolver), @@ -51,6 +52,7 @@ XmppConnectionGenerator::XmppConnectionGenerator( server_list_(new ServerInformation[server_count]), server_count_(server_count), server_index_(-1), + try_ssltcp_first_(try_ssltcp_first), successfully_resolved_dns_(false), first_dns_error_(0), options_(options) { @@ -160,7 +162,8 @@ void XmppConnectionGenerator::HandleServerDNSResolved(int status) { server_list_[server_index_].server.host(), ip_list, server_list_[server_index_].server.port(), - server_list_[server_index_].special_port_magic); + server_list_[server_index_].special_port_magic, + try_ssltcp_first_); } static const char* const PROTO_NAMES[cricket::PROTO_LAST + 1] = { diff --git a/jingle/notifier/communicator/xmpp_connection_generator.h b/jingle/notifier/communicator/xmpp_connection_generator.h index 7461c4b..0cb969c 100644 --- a/jingle/notifier/communicator/xmpp_connection_generator.h +++ b/jingle/notifier/communicator/xmpp_connection_generator.h @@ -36,11 +36,13 @@ struct ServerInformation { // combinations. class XmppConnectionGenerator : public sigslot::has_slots<> { public: + // try_ssltcp_first indicates that SSLTCP is tried before XMPP. Used by tests. // server_list is the list of connections to attempt in priority order. // server_count is the number of items in the server list. XmppConnectionGenerator( net::HostResolver* host_resolver, const ConnectionOptions* options, + bool try_ssltcp_first, const ServerInformation* server_list, int server_count); ~XmppConnectionGenerator(); @@ -72,6 +74,7 @@ class XmppConnectionGenerator : public sigslot::has_slots<> { talk_base::scoped_array<ServerInformation> server_list_; int server_count_; int server_index_; // The server that is current being used. + bool try_ssltcp_first_; // Used when sync tests are run on chromium builders. bool successfully_resolved_dns_; int first_dns_error_; const ConnectionOptions* options_; diff --git a/jingle/notifier/listener/mediator_thread_impl.cc b/jingle/notifier/listener/mediator_thread_impl.cc index 8432198..24ff3a34 100644 --- a/jingle/notifier/listener/mediator_thread_impl.cc +++ b/jingle/notifier/listener/mediator_thread_impl.cc @@ -154,7 +154,8 @@ void MediatorThreadImpl::DoLogin( options, host_resolver_.get(), server_list, - server_list_count)); + server_list_count, + notifier_options_.try_ssltcp_first)); login_->SignalConnect.connect( this, &MediatorThreadImpl::OnConnect); diff --git a/jingle/notifier/listener/talk_mediator_impl.cc b/jingle/notifier/listener/talk_mediator_impl.cc index 2221e04..bf86f91 100644 --- a/jingle/notifier/listener/talk_mediator_impl.cc +++ b/jingle/notifier/listener/talk_mediator_impl.cc @@ -13,12 +13,10 @@ namespace notifier { TalkMediatorImpl::TalkMediatorImpl( - MediatorThread* mediator_thread, bool invalidate_xmpp_auth_token, - bool allow_insecure_connection) + MediatorThread* mediator_thread, bool invalidate_xmpp_auth_token) : delegate_(NULL), mediator_thread_(mediator_thread), - invalidate_xmpp_auth_token_(invalidate_xmpp_auth_token), - allow_insecure_connection_(allow_insecure_connection) { + invalidate_xmpp_auth_token_(invalidate_xmpp_auth_token) { DCHECK(non_thread_safe_.CalledOnValidThread()); mediator_thread_->Start(); state_.started = 1; @@ -92,10 +90,6 @@ bool TalkMediatorImpl::SetAuthToken(const std::string& email, xmpp_settings_.set_auth_cookie(invalidate_xmpp_auth_token_ ? token + "bogus" : token); xmpp_settings_.set_token_service(token_service); - if (allow_insecure_connection_) { - xmpp_settings_.set_allow_plain(true); - xmpp_settings_.set_use_tls(false); - } state_.initialized = 1; return true; diff --git a/jingle/notifier/listener/talk_mediator_impl.h b/jingle/notifier/listener/talk_mediator_impl.h index d5b9d2f..34ecd8c 100644 --- a/jingle/notifier/listener/talk_mediator_impl.h +++ b/jingle/notifier/listener/talk_mediator_impl.h @@ -27,8 +27,7 @@ class TalkMediatorImpl public: // Takes ownership of |mediator_thread|. TalkMediatorImpl( - MediatorThread* mediator_thread, bool invalidate_xmpp_auth_token, - bool allow_insecure_connection); + MediatorThread* mediator_thread, bool invalidate_xmpp_auth_token); virtual ~TalkMediatorImpl(); // TalkMediator implementation. @@ -86,7 +85,6 @@ class TalkMediatorImpl scoped_ptr<MediatorThread> mediator_thread_; const bool invalidate_xmpp_auth_token_; - const bool allow_insecure_connection_; std::vector<std::string> subscribed_services_list_; diff --git a/jingle/notifier/listener/talk_mediator_unittest.cc b/jingle/notifier/listener/talk_mediator_unittest.cc index 0d0f9e3..e00539d 100644 --- a/jingle/notifier/listener/talk_mediator_unittest.cc +++ b/jingle/notifier/listener/talk_mediator_unittest.cc @@ -41,10 +41,8 @@ class TalkMediatorImplTest : public testing::Test { TalkMediatorImpl* NewMockedTalkMediator( MockMediatorThread* mock_mediator_thread) { const bool kInvalidateXmppAuthToken = false; - const bool kAllowInsecureConnection = false; return new TalkMediatorImpl(mock_mediator_thread, - kInvalidateXmppAuthToken, - kAllowInsecureConnection); + kInvalidateXmppAuthToken); } int last_message_; |