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 | |
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
21 files changed, 83 insertions, 67 deletions
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc index f9e9059..a712291 100644 --- a/chrome/browser/sync/engine/syncapi.cc +++ b/chrome/browser/sync/engine/syncapi.cc @@ -1509,16 +1509,11 @@ void SyncManager::SyncInternal::InitializeTalkMediator() { new sync_notifier::ServerNotifierThread( notifier_options_, state, this); talk_mediator_.reset( - new TalkMediatorImpl(server_notifier_thread, - notifier_options_.invalidate_xmpp_login, - notifier_options_.allow_insecure_connection)); + new TalkMediatorImpl(server_notifier_thread, false)); } else { notifier::MediatorThread* mediator_thread = new notifier::MediatorThreadImpl(notifier_options_); - talk_mediator_.reset( - new TalkMediatorImpl(mediator_thread, - notifier_options_.invalidate_xmpp_login, - notifier_options_.allow_insecure_connection)); + talk_mediator_.reset(new TalkMediatorImpl(mediator_thread, false)); if (notifier_options_.notification_method != notifier::NOTIFICATION_LEGACY) { if (notifier_options_.notification_method == diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index c9b2b58..5b92998 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -275,19 +275,14 @@ void ProfileSyncService::InitSettings() { notifier_options_.xmpp_host_port.set_host(value); notifier_options_.xmpp_host_port.set_port(notifier::kDefaultXmppPort); } - VLOG(1) << "Using " << notifier_options_.xmpp_host_port.ToString() + LOG(INFO) << "Using " << notifier_options_.xmpp_host_port.ToString() << " for test sync notification server."; } - notifier_options_.invalidate_xmpp_login = - command_line.HasSwitch(switches::kSyncInvalidateXmppLogin); - if (notifier_options_.invalidate_xmpp_login) { - VLOG(1) << "Invalidating sync XMPP login."; - } - notifier_options_.allow_insecure_connection = - command_line.HasSwitch(switches::kSyncAllowInsecureXmppConnection); - if (notifier_options_.allow_insecure_connection) { - VLOG(1) << "Allowing insecure XMPP connections."; + notifier_options_.try_ssltcp_first = + command_line.HasSwitch(switches::kSyncUseSslTcp); + if (notifier_options_.try_ssltcp_first) { + LOG(INFO) << "Trying SSL/TCP port before XMPP port for notifications."; } if (command_line.HasSwitch(switches::kSyncNotificationMethod)) { @@ -394,7 +389,7 @@ void ProfileSyncService::CreateBackend() { void ProfileSyncService::StartUp() { // Don't start up multiple times. if (backend_.get()) { - VLOG(1) << "Skipping bringing up backend host."; + LOG(INFO) << "Skipping bringing up backend host."; return; } diff --git a/chrome/browser/sync/tools/sync_listen_notifications.cc b/chrome/browser/sync/tools/sync_listen_notifications.cc index 8fc498b..c619e14 100644 --- a/chrome/browser/sync/tools/sync_listen_notifications.cc +++ b/chrome/browser/sync/tools/sync_listen_notifications.cc @@ -240,9 +240,9 @@ int main(int argc, char* argv[]) { } bool allow_plain = command_line.HasSwitch(switches::kSyncAllowPlain); bool disable_tls = command_line.HasSwitch(switches::kSyncDisableTls); - bool use_ssl_tcp = command_line.HasSwitch("use-ssl-tcp"); + bool use_ssl_tcp = command_line.HasSwitch(switches::kSyncUseSslTcp); if (use_ssl_tcp && (port != 443)) { - LOG(WARNING) << "--use-ssl-tcp is set but port is " << port + LOG(WARNING) << switches::kSyncUseSslTcp << " is set but port is " << port << " instead of 443"; } std::string cache_invalidation_state; diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index daaf549..4d1dd44 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -975,10 +975,6 @@ const char kSingleProcess[] = "single-process"; // Start the browser maximized, regardless of any previous settings. const char kStartMaximized[] = "start-maximized"; -// Allow insecure XMPP connections for sync (for testing). -const char kSyncAllowInsecureXmppConnection[] = - "sync-allow-insecure-xmpp-connection"; - // Control Sync XMPP client settings. const char kSyncAllowPlain[] = "allow-plain"; @@ -988,9 +984,6 @@ const char kSyncDisableTls[] = "disable-tls"; // Email used for sync. const char kSyncEmail[] = "email"; -// Invalidate any login info passed into sync's XMPP connection. -const char kSyncInvalidateXmppLogin[] = "sync-invalidate-xmpp-login"; - // Use the SyncerThread implementation that matches up with the old pthread // impl semantics, but using Chrome synchronization primitives. The only // difference between this and the default is that we now have no timeout on @@ -1016,6 +1009,9 @@ const char kSyncServer[] = "server"; const char kSyncServiceURL[] = "sync-url"; // Control Sync XMPP client settings. +const char kSyncUseSslTcp[] = "use-ssl-tcp"; + +// Control Sync XMPP client settings. const char kSyncUseCacheInvalidation[] = "use-cache-invalidation"; // Pass the name of the current running automated test to Chrome. diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 793a37f..6b52cc3 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -273,11 +273,9 @@ extern const char kSilentDumpOnDCHECK[]; extern const char kSimpleDataSource[]; extern const char kSingleProcess[]; extern const char kStartMaximized[]; -extern const char kSyncAllowInsecureXmppConnection[]; extern const char kSyncAllowPlain[]; extern const char kSyncDisableTls[]; extern const char kSyncEmail[]; -extern const char kSyncInvalidateXmppLogin[]; extern const char kSyncerThreadTimedStop[]; extern const char kSyncNotificationMethod[]; extern const char kSyncNotificationHost[]; @@ -285,6 +283,7 @@ extern const char kSyncPassword[]; extern const char kSyncPort[]; extern const char kSyncServer[]; extern const char kSyncServiceURL[]; +extern const char kSyncUseSslTcp[]; extern const char kSyncUseCacheInvalidation[]; extern const char kTestNaClSandbox[]; extern const char kTestName[]; diff --git a/chrome/service/cloud_print/cloud_print_proxy_backend.cc b/chrome/service/cloud_print/cloud_print_proxy_backend.cc index 33c1a55..2d0a46f 100644 --- a/chrome/service/cloud_print/cloud_print_proxy_backend.cc +++ b/chrome/service/cloud_print/cloud_print_proxy_backend.cc @@ -321,12 +321,10 @@ void CloudPrintProxyBackend::Core::DoInitializeWithToken( const notifier::NotifierOptions kNotifierOptions; const bool kInvalidateXmppAuthToken = false; - const bool kAllowInsecureXmppConnection = false; talk_mediator_.reset(new notifier::TalkMediatorImpl( new notifier::PushNotificationsThread(kNotifierOptions, kCloudPrintPushNotificationsSource), - kInvalidateXmppAuthToken, - kAllowInsecureXmppConnection)); + kInvalidateXmppAuthToken)); push_notifications_channel_ = kCloudPrintPushNotificationsSource; push_notifications_channel_.append("/proxy/"); push_notifications_channel_.append(proxy_id); diff --git a/chrome/test/live_sync/live_sync_test.cc b/chrome/test/live_sync/live_sync_test.cc index 44b0d7b..6fd16cb 100644 --- a/chrome/test/live_sync/live_sync_test.cc +++ b/chrome/test/live_sync/live_sync_test.cc @@ -107,6 +107,17 @@ void LiveSyncTest::SetUp() { if (!cl->HasSwitch(switches::kSyncNotificationMethod)) cl->AppendSwitchASCII(switches::kSyncNotificationMethod, "transitional"); + // TODO(akalin): Delete this block of code once a local python notification + // server is implemented. + // The chrome sync builders are behind a firewall that blocks port 5222, the + // default port for XMPP notifications. This causes the tests to spend up to a + // minute waiting for a connection on port 5222 before they fail over to port + // 443, the default SSL/TCP port. This switch causes the tests to use port 443 + // by default, without having to try port 5222. + if (!cl->HasSwitch(switches::kSyncUseSslTcp)) { + cl->AppendSwitch(switches::kSyncUseSslTcp); + } + // TODO(sync): Remove this once passwords sync is enabled by default. if (!cl->HasSwitch(switches::kEnableSyncPasswords)) { cl->AppendSwitch(switches::kEnableSyncPasswords); 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_; |