From a1c62688a8dc650f9a564e9cd86d9f26ec890d8d Mon Sep 17 00:00:00 2001 From: "rsimha@chromium.org" Date: Tue, 7 Sep 2010 22:43:05 +0000 Subject: Revert 58768 - Adding the sync-notification-host command line parameter to the integration tests. The sync integration tests currently access the network to communicate with the notification server. We need to move to a model where all server accesses are stubbed out by local servers. This is the first step towards implementing a local notification server. BUG=53933,53931 TEST=sync_integration_tests Review URL: http://codereview.chromium.org/3326007 TBR=rsimha@chromium.org Review URL: http://codereview.chromium.org/3318016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58769 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/sync/engine/syncapi.cc | 58 ++++++++++-------- chrome/browser/sync/engine/syncapi.h | 13 +++-- chrome/browser/sync/glue/sync_backend_host.cc | 12 +++- chrome/browser/sync/glue/sync_backend_host.h | 31 +++++----- chrome/browser/sync/notification_method.cc | 53 +++++++++++++++++ chrome/browser/sync/notification_method.h | 68 ++++++++++++++++++++++ .../sync/notifier/server_notifier_thread.cc | 12 ++-- .../browser/sync/notifier/server_notifier_thread.h | 7 +-- chrome/browser/sync/profile_sync_service.cc | 35 ++++------- chrome/browser/sync/profile_sync_service.h | 11 ++-- .../browser/sync/profile_sync_service_unittest.cc | 1 + chrome/browser/sync/profile_sync_test_util.h | 1 + chrome/browser/sync/test_profile_sync_service.h | 3 +- .../sync/tools/sync_listen_notifications.cc | 10 ++-- chrome/chrome_browser.gypi | 2 + chrome/common/chrome_switches.cc | 3 - chrome/common/chrome_switches.h | 1 - .../cloud_print/cloud_print_proxy_backend.cc | 6 +- chrome/test/live_sync/live_sync_test.cc | 5 -- 19 files changed, 225 insertions(+), 107 deletions(-) create mode 100644 chrome/browser/sync/notification_method.cc create mode 100644 chrome/browser/sync/notification_method.h (limited to 'chrome') diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc index f10d414..00d1c4f 100644 --- a/chrome/browser/sync/engine/syncapi.cc +++ b/chrome/browser/sync/engine/syncapi.cc @@ -915,6 +915,8 @@ class SyncManager::SyncInternal registrar_(NULL), notification_pending_(false), initialized_(false), + use_chrome_async_socket_(false), + notification_method_(browser_sync::kDefaultNotificationMethod), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); } @@ -938,7 +940,9 @@ class SyncManager::SyncInternal bool invalidate_xmpp_auth_token, const char* user_agent, const std::string& lsid, - const notifier::NotifierOptions& notifier_options, + const bool use_chrome_async_socket, + const bool try_ssltcp_first, + browser_sync::NotificationMethod notification_method, const std::string& restored_key_for_bootstrapping); // Tell sync engine to submit credentials to GAIA for verification. @@ -1242,7 +1246,8 @@ class SyncManager::SyncInternal bool initialized_; mutable Lock initialized_mutex_; - notifier::NotifierOptions notifier_options_; + bool use_chrome_async_socket_; + browser_sync::NotificationMethod notification_method_; ScopedRunnableMethodFactory method_factory_; }; @@ -1267,7 +1272,9 @@ bool SyncManager::Init(const FilePath& database_location, bool invalidate_xmpp_auth_token, const char* user_agent, const char* lsid, - const notifier::NotifierOptions& notifier_options, + bool use_chrome_async_socket, + bool try_ssltcp_first, + browser_sync::NotificationMethod notification_method, const std::string& restored_key_for_bootstrapping) { DCHECK(post_factory); LOG(INFO) << "SyncManager starting Init..."; @@ -1286,7 +1293,9 @@ bool SyncManager::Init(const FilePath& database_location, invalidate_xmpp_auth_token, user_agent, lsid, - notifier_options, + use_chrome_async_socket, + try_ssltcp_first, + notification_method, restored_key_for_bootstrapping); } @@ -1340,14 +1349,16 @@ bool SyncManager::SyncInternal::Init( bool invalidate_xmpp_auth_token, const char* user_agent, const std::string& lsid, - const notifier::NotifierOptions& notifier_options, + bool use_chrome_async_socket, + bool try_ssltcp_first, + browser_sync::NotificationMethod notification_method, const std::string& restored_key_for_bootstrapping) { LOG(INFO) << "Starting SyncInternal initialization."; core_message_loop_ = MessageLoop::current(); DCHECK(core_message_loop_); - notifier_options_ = notifier_options; + notification_method_ = notification_method; // Set up UserSettings, creating the db if necessary. We need this to // instantiate a URLFactory to give to the Syncer. FilePath settings_db_file = @@ -1385,17 +1396,18 @@ bool SyncManager::SyncInternal::Init( // it has its own MediatorThread implementation. Everything else just uses // MediatorThreadImpl. notifier::MediatorThread* mediator_thread = - (notifier_options_.notification_method == notifier::NOTIFICATION_SERVER) ? - new sync_notifier::ServerNotifierThread(notifier_options) : - new notifier::MediatorThreadImpl(notifier_options); + (notification_method == browser_sync::NOTIFICATION_SERVER) ? + new sync_notifier::ServerNotifierThread(use_chrome_async_socket, + try_ssltcp_first) : + new notifier::MediatorThreadImpl(use_chrome_async_socket, + try_ssltcp_first); const bool kInitializeSsl = true; const bool kConnectImmediately = false; talk_mediator_.reset(new TalkMediatorImpl(mediator_thread, kInitializeSsl, kConnectImmediately, invalidate_xmpp_auth_token)); - if (notifier_options_.notification_method != notifier::NOTIFICATION_LEGACY && - notifier_options_.notification_method != notifier::NOTIFICATION_SERVER) { - if (notifier_options_.notification_method == - notifier::NOTIFICATION_TRANSITIONAL) { + if (notification_method != browser_sync::NOTIFICATION_LEGACY && + notification_method != browser_sync::NOTIFICATION_SERVER) { + if (notification_method == browser_sync::NOTIFICATION_TRANSITIONAL) { talk_mediator_->AddSubscribedServiceUrl( browser_sync::kSyncLegacyServiceUrl); } @@ -1484,8 +1496,7 @@ void SyncManager::SyncInternal::MarkAndNotifyInitializationComplete() { void SyncManager::SyncInternal::SendPendingXMPPNotification( bool new_pending_notification) { DCHECK_EQ(MessageLoop::current(), core_message_loop_); - DCHECK_NE(notifier_options_.notification_method, - notifier::NOTIFICATION_SERVER); + DCHECK_NE(notification_method_, browser_sync::NOTIFICATION_SERVER); notification_pending_ = notification_pending_ || new_pending_notification; if (!notification_pending_) { LOG(INFO) << "Not sending notification: no pending notification"; @@ -1498,7 +1509,7 @@ void SyncManager::SyncInternal::SendPendingXMPPNotification( } LOG(INFO) << "Sending XMPP notification..."; OutgoingNotificationData notification_data; - if (notifier_options_.notification_method == notifier::NOTIFICATION_LEGACY) { + if (notification_method_ == browser_sync::NOTIFICATION_LEGACY) { notification_data.service_id = browser_sync::kSyncLegacyServiceId; notification_data.service_url = browser_sync::kSyncLegacyServiceUrl; notification_data.send_content = false; @@ -1508,7 +1519,7 @@ void SyncManager::SyncInternal::SendPendingXMPPNotification( notification_data.send_content = true; notification_data.priority = browser_sync::kSyncPriority; notification_data.write_to_cache_only = true; - if (notifier_options_.notification_method == notifier::NOTIFICATION_NEW) { + if (notification_method_ == browser_sync::NOTIFICATION_NEW) { notification_data.service_specific_data = browser_sync::kSyncServiceSpecificData; notification_data.require_subscription = true; @@ -1942,8 +1953,7 @@ void SyncManager::SyncInternal::HandleChannelEvent(const SyncerEvent& event) { observer_->OnSyncCycleCompleted(event.snapshot); } - if (notifier_options_.notification_method != - notifier::NOTIFICATION_SERVER) { + if (notification_method_ != browser_sync::NOTIFICATION_SERVER) { // TODO(chron): Consider changing this back to track has_more_to_sync // only notify peers if a successful commit has occurred. bool new_pending_notification = @@ -2080,8 +2090,8 @@ void SyncManager::SyncInternal::OnNotificationStateChange( if (syncer_thread()) { syncer_thread()->SetNotificationsEnabled(notifications_enabled); } - if ((notifier_options_.notification_method != - notifier::NOTIFICATION_SERVER) && notifications_enabled) { + if ((notification_method_ != browser_sync::NOTIFICATION_SERVER) && + notifications_enabled) { // Nudge the syncer thread when notifications are enabled, in case there is // any data that has not yet been synced. If we are listening to // server-issued notifications, we are already guaranteed to receive a @@ -2122,8 +2132,7 @@ void SyncManager::SyncInternal::OnIncomingNotification( // Check if the service url is a sync URL. An empty service URL is // treated as a legacy sync notification. If we're listening to // server-issued notifications, no need to check the service_url. - if ((notifier_options_.notification_method == - notifier::NOTIFICATION_SERVER) || + if ((notification_method_ == browser_sync::NOTIFICATION_SERVER) || notification_data.service_url.empty() || (notification_data.service_url == browser_sync::kSyncLegacyServiceUrl) || @@ -2141,8 +2150,7 @@ void SyncManager::SyncInternal::OnIncomingNotification( } void SyncManager::SyncInternal::OnOutgoingNotification() { - DCHECK_NE(notifier_options_.notification_method, - notifier::NOTIFICATION_SERVER); + DCHECK_NE(notification_method_, browser_sync::NOTIFICATION_SERVER); allstatus_.IncrementNotificationsSent(); } diff --git a/chrome/browser/sync/engine/syncapi.h b/chrome/browser/sync/engine/syncapi.h index 8a03759..e4e8510 100644 --- a/chrome/browser/sync/engine/syncapi.h +++ b/chrome/browser/sync/engine/syncapi.h @@ -46,6 +46,7 @@ #include "base/gtest_prod_util.h" #include "base/scoped_ptr.h" #include "build/build_config.h" +#include "chrome/browser/sync/notification_method.h" #include "chrome/browser/sync/syncable/model_type.h" #include "chrome/browser/sync/util/cryptographer.h" #include "chrome/common/net/gaia/google_service_auth_error.h" @@ -61,10 +62,6 @@ struct SyncSessionSnapshot; } } -namespace notifier { -struct NotifierOptions; -} - // Forward declarations of internal class types so that sync API objects // may have opaque pointers to these types. namespace syncable { @@ -747,7 +744,9 @@ class SyncManager { // used to log into XMPP is invalidated. This is used for testing // code paths related to authentication failures for XMPP only. // - // |notifier_options| contains options specific to sync notifications. + // |try_ssltcp_first| indicates that the SSLTCP port (443) is tried before the + // the XMPP port (5222) during login. It is used by the sync tests that are + // run on the chromium builders because port 5222 is blocked. bool Init(const FilePath& database_location, const char* sync_server_and_path, int sync_server_port, @@ -762,7 +761,9 @@ class SyncManager { bool invalidate_xmpp_auth_token, const char* user_agent, const char* lsid, - const notifier::NotifierOptions& notifier_options, + bool use_chrome_async_socket, + bool try_ssltcp_first, + browser_sync::NotificationMethod notification_method, const std::string& restored_key_for_bootstrapping); // Returns the username last used for a successful authentication. diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc index a8cd2ae..b570c4f 100644 --- a/chrome/browser/sync/glue/sync_backend_host.cc +++ b/chrome/browser/sync/glue/sync_backend_host.cc @@ -79,7 +79,9 @@ void SyncBackendHost::Initialize( bool delete_sync_data_folder, bool invalidate_sync_login, bool invalidate_sync_xmpp_login, - const notifier::NotifierOptions& notifier_options) { + bool use_chrome_async_socket, + bool try_ssltcp_first, + NotificationMethod notification_method) { if (!core_thread_.Start()) return; @@ -115,7 +117,9 @@ void SyncBackendHost::Initialize( delete_sync_data_folder, invalidate_sync_login, invalidate_sync_xmpp_login, - notifier_options, + use_chrome_async_socket, + try_ssltcp_first, + notification_method, RestoreEncryptionBootstrapToken())); } @@ -452,7 +456,9 @@ void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) { options.invalidate_sync_xmpp_login, MakeUserAgentForSyncapi().c_str(), options.lsid.c_str(), - options.notifier_options, + options.use_chrome_async_socket, + options.try_ssltcp_first, + options.notification_method, options.restored_key_for_bootstrapping); DCHECK(success) << "Syncapi initialization failed!"; } diff --git a/chrome/browser/sync/glue/sync_backend_host.h b/chrome/browser/sync/glue/sync_backend_host.h index 5147539..2b8680d 100644 --- a/chrome/browser/sync/glue/sync_backend_host.h +++ b/chrome/browser/sync/glue/sync_backend_host.h @@ -16,6 +16,7 @@ #include "base/ref_counted.h" #include "base/thread.h" #include "base/timer.h" +#include "chrome/browser/sync/notification_method.h" #include "chrome/browser/sync/engine/syncapi.h" #include "chrome/browser/sync/engine/model_safe_worker.h" #include "chrome/browser/sync/glue/data_type_controller.h" @@ -24,15 +25,10 @@ #include "chrome/common/net/gaia/google_service_auth_error.h" #include "chrome/common/net/url_request_context_getter.h" #include "googleurl/src/gurl.h" -#include "jingle/notifier/base/notifier_options.h" class CancelableTask; class Profile; -namespace notifier { -struct NotifierOptions; -} - namespace browser_sync { namespace sessions { @@ -109,7 +105,9 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { bool delete_sync_data_folder, bool invalidate_sync_login, bool invalidate_sync_xmpp_login, - const notifier::NotifierOptions& notifier_options); + bool use_chrome_async_socket, + bool try_ssltcp_first, + NotificationMethod notification_method); // Called on |frontend_loop_| to kick off asynchronous authentication. void Authenticate(const std::string& username, const std::string& password, @@ -221,7 +219,9 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { bool delete_sync_data_folder, bool invalidate_sync_login, bool invalidate_sync_xmpp_login, - const notifier::NotifierOptions& notifier_options, + bool use_chrome_async_socket, + bool try_ssltcp_first, + NotificationMethod notification_method, std::string restored_key_for_bootstrapping) : service_url(service_url), attempt_last_user_authentication(attempt_last_user_authentication), @@ -231,7 +231,9 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { delete_sync_data_folder(delete_sync_data_folder), invalidate_sync_login(invalidate_sync_login), invalidate_sync_xmpp_login(invalidate_sync_xmpp_login), - notifier_options(notifier_options), + use_chrome_async_socket(use_chrome_async_socket), + try_ssltcp_first(try_ssltcp_first), + notification_method(notification_method), restored_key_for_bootstrapping(restored_key_for_bootstrapping) {} GURL service_url; @@ -242,7 +244,9 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { bool delete_sync_data_folder; bool invalidate_sync_login; bool invalidate_sync_xmpp_login; - notifier::NotifierOptions notifier_options; + bool use_chrome_async_socket; + bool try_ssltcp_first; + NotificationMethod notification_method; std::string restored_key_for_bootstrapping; }; @@ -301,15 +305,16 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar { #if defined(UNIT_TEST) // Special form of initialization that does not try and authenticate the // last known user (since it will fail in test mode) and does some extra - // setup to nudge the syncapi into a usable state. + // setup to nudge the syncapi into a useable state. void DoInitializeForTest(const std::wstring& test_user, sync_api::HttpPostProviderFactory* factory, sync_api::HttpPostProviderFactory* auth_factory, - bool delete_sync_data_folder) { + bool delete_sync_data_folder, + NotificationMethod notification_method) { DoInitialize(DoInitializeOptions(GURL(), false, factory, auth_factory, std::string(), delete_sync_data_folder, - false, false, - notifier::NotifierOptions(), "")); + false, false, false, false, + notification_method, "")); syncapi_->SetupForTestMode(test_user); } #endif diff --git a/chrome/browser/sync/notification_method.cc b/chrome/browser/sync/notification_method.cc new file mode 100644 index 0000000..2c9896a --- /dev/null +++ b/chrome/browser/sync/notification_method.cc @@ -0,0 +1,53 @@ +// 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 "chrome/browser/sync/notification_method.h" + +#include "base/logging.h" + +namespace browser_sync { + +const NotificationMethod kDefaultNotificationMethod = + NOTIFICATION_SERVER; + +std::string NotificationMethodToString( + NotificationMethod notification_method) { + switch (notification_method) { + case NOTIFICATION_LEGACY: + return "NOTIFICATION_LEGACY"; + break; + case NOTIFICATION_TRANSITIONAL: + return "NOTIFICATION_TRANSITIONAL"; + break; + case NOTIFICATION_NEW: + return "NOTIFICATION_NEW"; + break; + case NOTIFICATION_SERVER: + return "NOTIFICATION_SERVER"; + break; + default: + LOG(WARNING) << "Unknown value for notification method: " + << notification_method; + break; + } + return ""; +} + +NotificationMethod StringToNotificationMethod(const std::string& str) { + if (str == "legacy") { + return NOTIFICATION_LEGACY; + } else if (str == "transitional") { + return NOTIFICATION_TRANSITIONAL; + } else if (str == "new") { + return NOTIFICATION_NEW; + } else if (str == "server") { + return NOTIFICATION_SERVER; + } + LOG(WARNING) << "Unknown notification method \"" << str + << "\"; using method " + << NotificationMethodToString(kDefaultNotificationMethod); + return kDefaultNotificationMethod; +} + +} // namespace browser_sync diff --git a/chrome/browser/sync/notification_method.h b/chrome/browser/sync/notification_method.h new file mode 100644 index 0000000..416dbe9 --- /dev/null +++ b/chrome/browser/sync/notification_method.h @@ -0,0 +1,68 @@ +// 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 CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_ +#define CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_ +#pragma once + +#include + +namespace browser_sync { + +// This is the matrix for the interaction between clients with +// different notification methods (except for NOTIFICATION_SERVER): +// +// Listen +// L T N +// +-------+ +// L | E E E | +// Send T | Y Y Y | +// N | E Y Y | +// +-------+ +// +// 'Y' means a client listening with the column notification method +// will receive notifications from a client sending with the row +// notification method. 'E' means means that the notification will be +// an empty one, which may be dropped by the server in the future. +// +// As for NOTIFICATION_SERVER, server-issued notifications will also +// simulate a peer-issued notification, so that any client with +// NOTIFICATION_TRANSITIONAL or NOTIFICATION_NEW will be able to +// receive those, too. This support will be removed once everyone is +// on NOTIFICATION_SERVER. + +enum NotificationMethod { + // Old, broken notification method. Works only if notification + // servers don't drop empty notifications. + NOTIFICATION_LEGACY, + // Compatible with new notifications. Also compatible with legacy + // notifications if the notification servers don't drop empty + // notifications. + NOTIFICATION_TRANSITIONAL, + // New notification method. Compatible only with transitional + // notifications. + // + // NOTE: "New" is kind of a misnomer, as it refers only to + // peer-issued notifications; the plan is to migrate everyone to + // using NOTIFICATION_SERVER. + NOTIFICATION_NEW, + + // Server-issued notifications. Compatible only with transitional + // notifications. + NOTIFICATION_SERVER, +}; + +extern const NotificationMethod kDefaultNotificationMethod; + +std::string NotificationMethodToString( + NotificationMethod notification_method); + +// If the given string is not one of "legacy", "transitional", "new", +// or "server", returns kDefaultNotificationMethod. +NotificationMethod StringToNotificationMethod(const std::string& str); + +} // namespace browser_sync + +#endif // CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_ + diff --git a/chrome/browser/sync/notifier/server_notifier_thread.cc b/chrome/browser/sync/notifier/server_notifier_thread.cc index c31f502..8b2aba3 100644 --- a/chrome/browser/sync/notifier/server_notifier_thread.cc +++ b/chrome/browser/sync/notifier/server_notifier_thread.cc @@ -9,18 +9,14 @@ #include "base/logging.h" #include "chrome/browser/sync/notifier/chrome_invalidation_client.h" -#include "jingle/notifier/base/notifier_options.h" #include "jingle/notifier/listener/notification_defines.h" namespace sync_notifier { -ServerNotifierThread::ServerNotifierThread( - const notifier::NotifierOptions& notifier_options) - : notifier::MediatorThreadImpl(notifier_options), - state_(notifier::STATE_DISCONNECTED) { - DCHECK_EQ(notifier::NOTIFICATION_SERVER, - notifier_options.notification_method); -} +ServerNotifierThread::ServerNotifierThread(bool use_chrome_async_socket, + bool try_ssltcp_first) + : notifier::MediatorThreadImpl(use_chrome_async_socket, try_ssltcp_first), + state_(notifier::STATE_DISCONNECTED) {} ServerNotifierThread::~ServerNotifierThread() {} diff --git a/chrome/browser/sync/notifier/server_notifier_thread.h b/chrome/browser/sync/notifier/server_notifier_thread.h index bcd85b0..9247bd4 100644 --- a/chrome/browser/sync/notifier/server_notifier_thread.h +++ b/chrome/browser/sync/notifier/server_notifier_thread.h @@ -21,18 +21,13 @@ #include "chrome/browser/sync/syncable/model_type.h" #include "jingle/notifier/listener/mediator_thread_impl.h" -namespace notifier { -struct NotifierOptions; -} - namespace sync_notifier { class ServerNotifierThread : public notifier::MediatorThreadImpl, public ChromeInvalidationClient::Listener { public: - explicit ServerNotifierThread( - const notifier::NotifierOptions& notifier_options); + ServerNotifierThread(bool use_chrome_async_socket, bool try_ssltcp_first); virtual ~ServerNotifierThread(); diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index b743be1..5732ebf 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -38,7 +38,6 @@ #include "chrome/common/pref_names.h" #include "chrome/common/time_format.h" #include "grit/generated_resources.h" -#include "jingle/notifier/communicator/const_communicator.h" #include "net/base/cookie_monster.h" using browser_sync::ChangeProcessor; @@ -67,6 +66,8 @@ ProfileSyncService::ProfileSyncService(ProfileSyncFactory* factory, is_auth_in_progress_(false), ALLOW_THIS_IN_INITIALIZER_LIST(wizard_(this)), unrecoverable_error_detected_(false), + use_chrome_async_socket_(false), + notification_method_(browser_sync::kDefaultNotificationMethod), ALLOW_THIS_IN_INITIALIZER_LIST(scoped_runnable_method_factory_(this)) { DCHECK(factory); DCHECK(profile); @@ -115,6 +116,8 @@ ProfileSyncService::ProfileSyncService() is_auth_in_progress_(false), ALLOW_THIS_IN_INITIALIZER_LIST(wizard_(this)), unrecoverable_error_detected_(false), + use_chrome_async_socket_(false), + notification_method_(browser_sync::kDefaultNotificationMethod), ALLOW_THIS_IN_INITIALIZER_LIST(scoped_runnable_method_factory_(this)), expect_sync_configuration_aborted_(false) { } @@ -208,35 +211,17 @@ void ProfileSyncService::InitSettings() { LOG(INFO) << "Using " << sync_service_url_ << " for sync server URL."; - // Override the notification server host from the command-line, if provided. - if (command_line.HasSwitch(switches::kSyncNotificationHost)) { - std::string value(command_line.GetSwitchValueASCII( - switches::kSyncNotificationHost)); - if (!value.empty()) { - notifier_options_.xmpp_host_port.set_host(value); - notifier_options_.xmpp_host_port.set_port(notifier::kDefaultXmppPort); - } - LOG(INFO) << "Using " << notifier_options_.xmpp_host_port.ToString() - << " for test sync notification server."; - } - - notifier_options_.use_chrome_async_socket = + use_chrome_async_socket_ = !command_line.HasSwitch(switches::kSyncDisableChromeAsyncSocket); - if (notifier_options_.use_chrome_async_socket) { + if (use_chrome_async_socket_) { LOG(INFO) << "Using ChromeAsyncSocket"; } - 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)) { const std::string notification_method_str( command_line.GetSwitchValueASCII(switches::kSyncNotificationMethod)); - notifier_options_.notification_method = - notifier::StringToNotificationMethod(notification_method_str); + notification_method_ = + browser_sync::StringToNotificationMethod(notification_method_str); } } @@ -318,7 +303,9 @@ void ProfileSyncService::InitializeBackend(bool delete_sync_data_folder) { delete_sync_data_folder, invalidate_sync_login, invalidate_sync_xmpp_login, - notifier_options_); + use_chrome_async_socket_, + try_ssltcp_first, + notification_method_); } void ProfileSyncService::CreateBackend() { diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h index 7c36f4e..c0f023f 100644 --- a/chrome/browser/sync/profile_sync_service.h +++ b/chrome/browser/sync/profile_sync_service.h @@ -19,6 +19,7 @@ #include "chrome/browser/sync/glue/data_type_manager.h" #include "chrome/browser/sync/glue/session_model_associator.h" #include "chrome/browser/sync/glue/sync_backend_host.h" +#include "chrome/browser/sync/notification_method.h" #include "chrome/browser/sync/profile_sync_service_observer.h" #include "chrome/browser/sync/sync_setup_wizard.h" #include "chrome/browser/sync/syncable/model_type.h" @@ -27,7 +28,6 @@ #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" #include "googleurl/src/gurl.h" -#include "jingle/notifier/base/notifier_options.h" class NotificationDetails; class NotificationSource; @@ -428,9 +428,12 @@ class ProfileSyncService : public browser_sync::SyncFrontend, std::string unrecoverable_error_message_; scoped_ptr unrecoverable_error_location_; - // Contains options specific to how sync clients send and listen to - // notifications. - notifier::NotifierOptions notifier_options_; + // Whether to use the (new, untested) Chrome-socket-based + // buzz::AsyncSocket implementation for notifications. + bool use_chrome_async_socket_; + + // Which peer-to-peer notification method to use. + browser_sync::NotificationMethod notification_method_; // Manages the start and stop of the various data types. scoped_ptr data_type_manager_; diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc index 7cbc37c..bb366c7 100644 --- a/chrome/browser/sync/profile_sync_service_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_unittest.cc @@ -26,6 +26,7 @@ #include "chrome/browser/sync/glue/model_associator.h" #include "chrome/browser/sync/glue/sync_backend_host.h" #include "chrome/browser/sync/glue/sync_backend_host_mock.h" +#include "chrome/browser/sync/notification_method.h" #include "chrome/browser/sync/profile_sync_factory.h" #include "chrome/browser/sync/profile_sync_factory_mock.h" #include "chrome/browser/sync/test_profile_sync_service.h" diff --git a/chrome/browser/sync/profile_sync_test_util.h b/chrome/browser/sync/profile_sync_test_util.h index 7482bcb..baaceb6 100644 --- a/chrome/browser/sync/profile_sync_test_util.h +++ b/chrome/browser/sync/profile_sync_test_util.h @@ -24,6 +24,7 @@ #include "chrome/browser/sync/glue/bookmark_model_associator.h" #include "chrome/browser/sync/glue/change_processor.h" #include "chrome/browser/sync/glue/data_type_manager_impl.h" +#include "chrome/browser/sync/notification_method.h" #include "chrome/browser/sync/profile_sync_factory.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/unrecoverable_error_handler.h" diff --git a/chrome/browser/sync/test_profile_sync_service.h b/chrome/browser/sync/test_profile_sync_service.h index 8a00515..aba7c42 100644 --- a/chrome/browser/sync/test_profile_sync_service.h +++ b/chrome/browser/sync/test_profile_sync_service.h @@ -155,7 +155,8 @@ class SyncBackendHostForProfileSyncTest : public SyncBackendHost { user, options.http_bridge_factory, options.auth_http_bridge_factory, - options.delete_sync_data_folder)); + options.delete_sync_data_folder, + browser_sync::kDefaultNotificationMethod)); // TODO(akalin): Figure out a better way to do this. if (synchronous_init_) { diff --git a/chrome/browser/sync/tools/sync_listen_notifications.cc b/chrome/browser/sync/tools/sync_listen_notifications.cc index 0a7751d..56c8eed 100644 --- a/chrome/browser/sync/tools/sync_listen_notifications.cc +++ b/chrome/browser/sync/tools/sync_listen_notifications.cc @@ -12,13 +12,13 @@ #include "base/platform_thread.h" #include "base/string_util.h" #include "base/task.h" +#include "chrome/browser/sync/notification_method.h" #include "chrome/browser/sync/notifier/cache_invalidation_packet_handler.h" #include "chrome/browser/sync/notifier/chrome_invalidation_client.h" #include "chrome/browser/sync/notifier/chrome_system_resources.h" #include "chrome/browser/sync/sync_constants.h" #include "chrome/common/chrome_switches.h" #include "jingle/notifier/base/chrome_async_socket.h" -#include "jingle/notifier/base/notification_method.h" #include "jingle/notifier/base/task_pump.h" #include "jingle/notifier/base/xmpp_client_socket_factory.h" #include "jingle/notifier/communicator/xmpp_socket_adapter.h" @@ -178,11 +178,11 @@ class LegacyNotifierDelegate : public XmppNotificationClient::Delegate { const buzz::XmppClientSettings& xmpp_client_settings, buzz::XmppClient* xmpp_client) { LOG(INFO) << "Logged in"; - notifier::NotificationMethod notification_method = - notifier::NOTIFICATION_TRANSITIONAL; + browser_sync::NotificationMethod notification_method = + browser_sync::NOTIFICATION_TRANSITIONAL; std::vector subscribed_services_list; - if (notification_method != notifier::NOTIFICATION_LEGACY) { - if (notification_method == notifier::NOTIFICATION_TRANSITIONAL) { + if (notification_method != browser_sync::NOTIFICATION_LEGACY) { + if (notification_method == browser_sync::NOTIFICATION_TRANSITIONAL) { subscribed_services_list.push_back( browser_sync::kSyncLegacyServiceUrl); } diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 4d9b657..257b1e0 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2616,6 +2616,8 @@ 'browser/sync/glue/typed_url_model_associator.h', 'browser/sync/glue/ui_model_worker.cc', 'browser/sync/glue/ui_model_worker.h', + 'browser/sync/notification_method.h', + 'browser/sync/notification_method.cc', 'browser/sync/profile_sync_service.cc', 'browser/sync/profile_sync_service.h', 'browser/sync/profile_sync_factory.h', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index cbc2e5f..4c916d3 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -1006,9 +1006,6 @@ const char kSyncerThreadTimedStop[] = "syncer-thread-timed-stop"; // Override the default notification method for sync. const char kSyncNotificationMethod[] = "sync-notification-method"; -// Override the default host used for sync notifications. -const char kSyncNotificationHost[] = "sync-notification-host"; - // Password used for sync. const char kSyncPassword[] = "password"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index af20098..74bec36 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -284,7 +284,6 @@ extern const char kSyncDisableTls[]; extern const char kSyncEmail[]; extern const char kSyncerThreadTimedStop[]; extern const char kSyncNotificationMethod[]; -extern const char kSyncNotificationHost[]; extern const char kSyncPassword[]; extern const char kSyncPort[]; extern const char kSyncServer[]; diff --git a/chrome/service/cloud_print/cloud_print_proxy_backend.cc b/chrome/service/cloud_print/cloud_print_proxy_backend.cc index 865ec8e..b0e621f 100644 --- a/chrome/service/cloud_print/cloud_print_proxy_backend.cc +++ b/chrome/service/cloud_print/cloud_print_proxy_backend.cc @@ -14,7 +14,6 @@ #include "chrome/service/cloud_print/printer_job_handler.h" #include "chrome/service/gaia/service_gaia_authenticator.h" #include "chrome/service/service_process.h" -#include "jingle/notifier/base/notifier_options.h" #include "jingle/notifier/listener/mediator_thread_impl.h" #include "jingle/notifier/listener/talk_mediator_impl.h" @@ -302,12 +301,13 @@ void CloudPrintProxyBackend::Core::DoInitializeWithToken( // TODO(sanjeevr): Validate the tokens. auth_token_ = cloud_print_token; - const notifier::NotifierOptions kNotifierOptions; + const bool kUseChromeAsyncSocket = true; + const bool kTrySslTcpFirst = false; const bool kInitializeSsl = true; const bool kConnectImmediately = false; const bool kInvalidateXmppAuthToken = false; talk_mediator_.reset(new notifier::TalkMediatorImpl( - new notifier::MediatorThreadImpl(kNotifierOptions), + new notifier::MediatorThreadImpl(kUseChromeAsyncSocket, kTrySslTcpFirst), kInitializeSsl, kConnectImmediately, kInvalidateXmppAuthToken)); talk_mediator_->AddSubscribedServiceUrl(kCloudPrintTalkServiceUrl); talk_mediator_->SetDelegate(this); diff --git a/chrome/test/live_sync/live_sync_test.cc b/chrome/test/live_sync/live_sync_test.cc index 5191855..5ff3e74 100644 --- a/chrome/test/live_sync/live_sync_test.cc +++ b/chrome/test/live_sync/live_sync_test.cc @@ -123,8 +123,6 @@ void LiveSyncTest::SetUp() { "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 @@ -251,9 +249,6 @@ void LiveSyncTest::SetUpLocalTestServer() { StringPrintf("http://%s:%d/chromiumsync", test_server_.host_port_pair().host().c_str(), test_server_.host_port_pair().port())); - - // TODO(akalin): Set the kSyncNotificationHost switch here once a local python - // notification server is implemented. } void LiveSyncTest::TearDownLocalTestServer() { -- cgit v1.1