diff options
author | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-07 22:43:05 +0000 |
---|---|---|
committer | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-07 22:43:05 +0000 |
commit | a1c62688a8dc650f9a564e9cd86d9f26ec890d8d (patch) | |
tree | 929798881f3d450fd7d4f0c689949500e64442d7 | |
parent | 4cbf13c20a9e18538515e2a83c2fbfd01659eaad (diff) | |
download | chromium_src-a1c62688a8dc650f9a564e9cd86d9f26ec890d8d.zip chromium_src-a1c62688a8dc650f9a564e9cd86d9f26ec890d8d.tar.gz chromium_src-a1c62688a8dc650f9a564e9cd86d9f26ec890d8d.tar.bz2 |
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
24 files changed, 141 insertions, 200 deletions
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<SyncManager::SyncInternal> 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/jingle/notifier/base/notification_method.cc b/chrome/browser/sync/notification_method.cc index 08feb4a..2c9896a 100644 --- a/jingle/notifier/base/notification_method.cc +++ b/chrome/browser/sync/notification_method.cc @@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "jingle/notifier/base/notification_method.h" +#include "chrome/browser/sync/notification_method.h" #include "base/logging.h" -namespace notifier { +namespace browser_sync { -const NotificationMethod kDefaultNotificationMethod = NOTIFICATION_SERVER; +const NotificationMethod kDefaultNotificationMethod = + NOTIFICATION_SERVER; std::string NotificationMethodToString( NotificationMethod notification_method) { @@ -49,4 +50,4 @@ NotificationMethod StringToNotificationMethod(const std::string& str) { return kDefaultNotificationMethod; } -} // namespace notifier +} // namespace browser_sync diff --git a/jingle/notifier/base/notification_method.h b/chrome/browser/sync/notification_method.h index aedc11d..416dbe9 100644 --- a/jingle/notifier/base/notification_method.h +++ b/chrome/browser/sync/notification_method.h @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef JINGLE_NOTIFIER_BASE_NOTIFICATION_METHOD_H_ -#define JINGLE_NOTIFIER_BASE_NOTIFICATION_METHOD_H_ +#ifndef CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_ +#define CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_ #pragma once #include <string> -namespace notifier { +namespace browser_sync { // This is the matrix for the interaction between clients with // different notification methods (except for NOTIFICATION_SERVER): @@ -62,7 +62,7 @@ std::string NotificationMethodToString( // or "server", returns kDefaultNotificationMethod. NotificationMethod StringToNotificationMethod(const std::string& str); -} // namespace notifier +} // namespace browser_sync -#endif // JINGLE_NOTIFIER_BASE_NOTIFICATION_METHOD_H_ +#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<tracked_objects::Location> 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<browser_sync::DataTypeManager> 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<std::string> 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() { diff --git a/jingle/jingle.gyp b/jingle/jingle.gyp index 2f01fff..dd76e04 100644 --- a/jingle/jingle.gyp +++ b/jingle/jingle.gyp @@ -22,9 +22,6 @@ 'notifier/base/ssl_adapter.cc', 'notifier/base/fake_ssl_client_socket.cc', 'notifier/base/fake_ssl_client_socket.h', - 'notifier/base/notification_method.h', - 'notifier/base/notification_method.cc', - 'notifier/base/notifier_options.h', 'notifier/base/static_assert.h', 'notifier/base/task_pump.cc', 'notifier/base/task_pump.h', diff --git a/jingle/notifier/base/notifier_options.h b/jingle/notifier/base/notifier_options.h deleted file mode 100644 index 32374cf..0000000 --- a/jingle/notifier/base/notifier_options.h +++ /dev/null @@ -1,47 +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_BASE_NOTIFIER_OPTIONS_H_ -#define JINGLE_NOTIFIER_BASE_NOTIFIER_OPTIONS_H_ - -#include "jingle/notifier/base/notification_method.h" -#include "net/base/host_port_pair.h" - -namespace notifier { - -struct NotifierOptions { - NotifierOptions() - : use_chrome_async_socket(true), - try_ssltcp_first(false), - notification_method(kDefaultNotificationMethod) {} - - NotifierOptions(const bool use_chrome_async_socket, - const bool try_ssltcp_first, - const net::HostPortPair& xmpp_host_port, - NotificationMethod notification_method) - : use_chrome_async_socket(use_chrome_async_socket), - try_ssltcp_first(try_ssltcp_first), - xmpp_host_port(xmpp_host_port), - notification_method(notification_method) {} - - // Indicates whether to use the chrome-socket-based buzz::AsyncSocket - // implementation for notifications. - bool use_chrome_async_socket; - - // 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. - net::HostPortPair xmpp_host_port; - - // Indicates the method used by sync clients while sending and listening to - // notifications. - NotificationMethod notification_method; -}; - -} // namespace notifier - -#endif // JINGLE_NOTIFIER_BASE_NOTIFIER_OPTIONS_H_ diff --git a/jingle/notifier/listener/mediator_thread_impl.cc b/jingle/notifier/listener/mediator_thread_impl.cc index 02d48fb1..63e404e 100644 --- a/jingle/notifier/listener/mediator_thread_impl.cc +++ b/jingle/notifier/listener/mediator_thread_impl.cc @@ -26,10 +26,12 @@ DISABLE_RUNNABLE_METHOD_REFCOUNT(notifier::MediatorThreadImpl); namespace notifier { -MediatorThreadImpl::MediatorThreadImpl(const NotifierOptions& notifier_options) +MediatorThreadImpl::MediatorThreadImpl(bool use_chrome_async_socket, + bool try_ssltcp_first) : delegate_(NULL), parent_message_loop_(MessageLoop::current()), - notifier_options_(notifier_options), + use_chrome_async_socket_(use_chrome_async_socket), + try_ssltcp_first_(try_ssltcp_first), worker_thread_("MediatorThread worker thread") { DCHECK(parent_message_loop_); } @@ -51,7 +53,7 @@ void MediatorThreadImpl::Start() { // TODO(akalin): Make this function return a bool and remove this // CHECK(). CHECK(worker_thread_.StartWithOptions(options)); - if (!notifier_options_.use_chrome_async_socket) { + if (!use_chrome_async_socket_) { worker_message_loop()->PostTask( FROM_HERE, NewRunnableMethod(this, &MediatorThreadImpl::StartLibjingleThread)); @@ -60,7 +62,7 @@ void MediatorThreadImpl::Start() { void MediatorThreadImpl::StartLibjingleThread() { DCHECK_EQ(MessageLoop::current(), worker_message_loop()); - DCHECK(!notifier_options_.use_chrome_async_socket); + DCHECK(!use_chrome_async_socket_); socket_server_.reset(new talk_base::PhysicalSocketServer()); libjingle_thread_.reset(new talk_base::Thread()); talk_base::ThreadManager::SetCurrent(libjingle_thread_.get()); @@ -71,7 +73,7 @@ void MediatorThreadImpl::StartLibjingleThread() { void MediatorThreadImpl::StopLibjingleThread() { DCHECK_EQ(MessageLoop::current(), worker_message_loop()); - DCHECK(!notifier_options_.use_chrome_async_socket); + DCHECK(!use_chrome_async_socket_); talk_base::ThreadManager::SetCurrent(NULL); libjingle_thread_.reset(); socket_server_.reset(); @@ -79,7 +81,7 @@ void MediatorThreadImpl::StopLibjingleThread() { void MediatorThreadImpl::PumpLibjingleLoop() { DCHECK_EQ(MessageLoop::current(), worker_message_loop()); - DCHECK(!notifier_options_.use_chrome_async_socket); + DCHECK(!use_chrome_async_socket_); // Pump the libjingle message loop 100ms at a time. if (!libjingle_thread_.get()) { // StopLibjingleThread() was called. @@ -103,7 +105,7 @@ void MediatorThreadImpl::Logout() { worker_message_loop()->PostTask( FROM_HERE, NewRunnableMethod(this, &MediatorThreadImpl::DoDisconnect)); - if (!notifier_options_.use_chrome_async_socket) { + if (!use_chrome_async_socket_) { worker_message_loop()->PostTask( FROM_HERE, NewRunnableMethod(this, &MediatorThreadImpl::StopLibjingleThread)); @@ -180,24 +182,15 @@ void MediatorThreadImpl::DoLogin( pump_.reset(new notifier::TaskPump()); notifier::ServerInformation server_list[2]; - int server_list_count = 0; - - // Override the default servers with a test notification server if one was - // provided. - if(!notifier_options_.xmpp_host_port.host().empty()) { - server_list[0].server = notifier_options_.xmpp_host_port; - server_list[0].special_port_magic = false; - server_list_count = 1; - } else { - // The default servers know how to serve over port 443 (that's the magic). - server_list[0].server = net::HostPortPair("talk.google.com", - notifier::kDefaultXmppPort); - server_list[0].special_port_magic = true; - server_list[1].server = net::HostPortPair("talkx.l.google.com", - notifier::kDefaultXmppPort); - server_list[1].special_port_magic = true; - server_list_count = 2; - } + int server_list_count = 2; + + // The default servers know how to serve over port 443 (that's the magic). + server_list[0].server = net::HostPortPair("talk.google.com", + notifier::kDefaultXmppPort); + server_list[0].special_port_magic = true; + server_list[1].server = net::HostPortPair("talkx.l.google.com", + notifier::kDefaultXmppPort); + server_list[1].special_port_magic = true; // Autodetect proxy is on by default. notifier::ConnectionOptions options; @@ -205,7 +198,7 @@ void MediatorThreadImpl::DoLogin( // Language is not used in the stanza so we default to |en|. std::string lang = "en"; login_.reset(new notifier::Login(pump_.get(), - notifier_options_.use_chrome_async_socket, + use_chrome_async_socket_, settings, options, lang, @@ -214,7 +207,7 @@ void MediatorThreadImpl::DoLogin( server_list_count, // talk_base::FirewallManager* is NULL. NULL, - notifier_options_.try_ssltcp_first, + try_ssltcp_first_, // Both the proxy and a non-proxy route // will be attempted. false)); diff --git a/jingle/notifier/listener/mediator_thread_impl.h b/jingle/notifier/listener/mediator_thread_impl.h index 755731e..39eca59 100644 --- a/jingle/notifier/listener/mediator_thread_impl.h +++ b/jingle/notifier/listener/mediator_thread_impl.h @@ -27,7 +27,6 @@ #include "base/ref_counted.h" #include "base/scoped_ptr.h" #include "base/thread.h" -#include "jingle/notifier/base/notifier_options.h" #include "jingle/notifier/communicator/login.h" #include "jingle/notifier/communicator/login_connection_state.h" #include "jingle/notifier/communicator/login_failure.h" @@ -60,7 +59,7 @@ class MediatorThreadImpl : public MediatorThread, public sigslot::has_slots<> { public: - explicit MediatorThreadImpl(const NotifierOptions& notifier_options); + MediatorThreadImpl(bool use_chrome_async_socket, bool try_ssltcp_first); virtual ~MediatorThreadImpl(); virtual void SetDelegate(Delegate* delegate); @@ -125,7 +124,8 @@ class MediatorThreadImpl void OnSubscriptionStateChangeOnParentThread( bool success); - const NotifierOptions notifier_options_; + const bool use_chrome_async_socket_; + const bool try_ssltcp_first_; base::Thread worker_thread_; scoped_refptr<net::HostResolver> host_resolver_; diff --git a/jingle/notifier/listener/talk_mediator_unittest.cc b/jingle/notifier/listener/talk_mediator_unittest.cc index 36bc94b..a138052 100644 --- a/jingle/notifier/listener/talk_mediator_unittest.cc +++ b/jingle/notifier/listener/talk_mediator_unittest.cc @@ -6,7 +6,6 @@ #include "base/basictypes.h" #include "base/message_loop.h" -#include "jingle/notifier/base/notifier_options.h" #include "jingle/notifier/listener/mediator_thread_mock.h" #include "jingle/notifier/listener/mediator_thread_impl.h" #include "jingle/notifier/listener/talk_mediator_impl.h" @@ -39,13 +38,14 @@ class TalkMediatorImplTest : public testing::Test { virtual ~TalkMediatorImplTest() {} TalkMediatorImpl* NewTalkMediator() { - const notifier::NotifierOptions kNotifierOptions; + const bool kUseChromeAsyncSocket = false; + const bool kTrySslTcpFirst = false; const bool kInitializeSsl = true; const bool kConnectImmediately = false; const bool kInvalidateXmppAuthToken = false; return new TalkMediatorImpl( - new MediatorThreadImpl(kNotifierOptions), kInitializeSsl, - kConnectImmediately, kInvalidateXmppAuthToken); + new MediatorThreadImpl(kUseChromeAsyncSocket, kTrySslTcpFirst), + kInitializeSsl, kConnectImmediately, kInvalidateXmppAuthToken); } TalkMediatorImpl* NewMockedTalkMediator( |