summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/sync/engine/syncapi.cc58
-rw-r--r--chrome/browser/sync/engine/syncapi.h13
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.cc12
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.h31
-rw-r--r--chrome/browser/sync/notifier/server_notifier_thread.cc12
-rw-r--r--chrome/browser/sync/notifier/server_notifier_thread.h7
-rw-r--r--chrome/browser/sync/profile_sync_service.cc38
-rw-r--r--chrome/browser/sync/profile_sync_service.h11
-rw-r--r--chrome/browser/sync/profile_sync_service_unittest.cc1
-rw-r--r--chrome/browser/sync/profile_sync_test_util.h1
-rw-r--r--chrome/browser/sync/test_profile_sync_service.h3
-rw-r--r--chrome/browser/sync/tools/sync_listen_notifications.cc10
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/service/cloud_print/cloud_print_proxy_backend.cc6
-rw-r--r--chrome/test/live_sync/live_sync_test.cc5
-rw-r--r--jingle/jingle.gyp3
-rw-r--r--jingle/notifier/base/notification_method.cc (renamed from chrome/browser/sync/notification_method.cc)9
-rw-r--r--jingle/notifier/base/notification_method.h (renamed from chrome/browser/sync/notification_method.h)10
-rw-r--r--jingle/notifier/base/notifier_options.h47
-rw-r--r--jingle/notifier/listener/mediator_thread_impl.cc47
-rw-r--r--jingle/notifier/listener/mediator_thread_impl.h6
-rw-r--r--jingle/notifier/listener/talk_mediator_unittest.cc8
24 files changed, 200 insertions, 144 deletions
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc
index a0b5f29..c2d53c8 100644
--- a/chrome/browser/sync/engine/syncapi.cc
+++ b/chrome/browser/sync/engine/syncapi.cc
@@ -915,8 +915,6 @@ 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));
}
@@ -940,9 +938,7 @@ class SyncManager::SyncInternal
bool invalidate_xmpp_auth_token,
const char* user_agent,
const std::string& lsid,
- const bool use_chrome_async_socket,
- const bool try_ssltcp_first,
- browser_sync::NotificationMethod notification_method,
+ const notifier::NotifierOptions& notifier_options,
const std::string& restored_key_for_bootstrapping);
// Tell sync engine to submit credentials to GAIA for verification.
@@ -1246,8 +1242,7 @@ class SyncManager::SyncInternal
bool initialized_;
mutable Lock initialized_mutex_;
- bool use_chrome_async_socket_;
- browser_sync::NotificationMethod notification_method_;
+ notifier::NotifierOptions notifier_options_;
ScopedRunnableMethodFactory<SyncManager::SyncInternal> method_factory_;
};
@@ -1272,9 +1267,7 @@ bool SyncManager::Init(const FilePath& database_location,
bool invalidate_xmpp_auth_token,
const char* user_agent,
const char* lsid,
- bool use_chrome_async_socket,
- bool try_ssltcp_first,
- browser_sync::NotificationMethod notification_method,
+ const notifier::NotifierOptions& notifier_options,
const std::string& restored_key_for_bootstrapping) {
DCHECK(post_factory);
LOG(INFO) << "SyncManager starting Init...";
@@ -1293,9 +1286,7 @@ bool SyncManager::Init(const FilePath& database_location,
invalidate_xmpp_auth_token,
user_agent,
lsid,
- use_chrome_async_socket,
- try_ssltcp_first,
- notification_method,
+ notifier_options,
restored_key_for_bootstrapping);
}
@@ -1353,16 +1344,14 @@ bool SyncManager::SyncInternal::Init(
bool invalidate_xmpp_auth_token,
const char* user_agent,
const std::string& lsid,
- bool use_chrome_async_socket,
- bool try_ssltcp_first,
- browser_sync::NotificationMethod notification_method,
+ const notifier::NotifierOptions& notifier_options,
const std::string& restored_key_for_bootstrapping) {
LOG(INFO) << "Starting SyncInternal initialization.";
core_message_loop_ = MessageLoop::current();
DCHECK(core_message_loop_);
- notification_method_ = notification_method;
+ notifier_options_ = notifier_options;
// Set up UserSettings, creating the db if necessary. We need this to
// instantiate a URLFactory to give to the Syncer.
FilePath settings_db_file =
@@ -1400,18 +1389,17 @@ bool SyncManager::SyncInternal::Init(
// it has its own MediatorThread implementation. Everything else just uses
// MediatorThreadImpl.
notifier::MediatorThread* mediator_thread =
- (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);
+ (notifier_options_.notification_method == notifier::NOTIFICATION_SERVER) ?
+ new sync_notifier::ServerNotifierThread(notifier_options) :
+ new notifier::MediatorThreadImpl(notifier_options);
const bool kInitializeSsl = true;
const bool kConnectImmediately = false;
talk_mediator_.reset(new TalkMediatorImpl(mediator_thread, kInitializeSsl,
kConnectImmediately, invalidate_xmpp_auth_token));
- if (notification_method != browser_sync::NOTIFICATION_LEGACY &&
- notification_method != browser_sync::NOTIFICATION_SERVER) {
- if (notification_method == browser_sync::NOTIFICATION_TRANSITIONAL) {
+ if (notifier_options_.notification_method != notifier::NOTIFICATION_LEGACY &&
+ notifier_options_.notification_method != notifier::NOTIFICATION_SERVER) {
+ if (notifier_options_.notification_method ==
+ notifier::NOTIFICATION_TRANSITIONAL) {
talk_mediator_->AddSubscribedServiceUrl(
browser_sync::kSyncLegacyServiceUrl);
}
@@ -1500,7 +1488,8 @@ void SyncManager::SyncInternal::MarkAndNotifyInitializationComplete() {
void SyncManager::SyncInternal::SendPendingXMPPNotification(
bool new_pending_notification) {
DCHECK_EQ(MessageLoop::current(), core_message_loop_);
- DCHECK_NE(notification_method_, browser_sync::NOTIFICATION_SERVER);
+ DCHECK_NE(notifier_options_.notification_method,
+ notifier::NOTIFICATION_SERVER);
notification_pending_ = notification_pending_ || new_pending_notification;
if (!notification_pending_) {
LOG(INFO) << "Not sending notification: no pending notification";
@@ -1513,7 +1502,7 @@ void SyncManager::SyncInternal::SendPendingXMPPNotification(
}
LOG(INFO) << "Sending XMPP notification...";
OutgoingNotificationData notification_data;
- if (notification_method_ == browser_sync::NOTIFICATION_LEGACY) {
+ if (notifier_options_.notification_method == notifier::NOTIFICATION_LEGACY) {
notification_data.service_id = browser_sync::kSyncLegacyServiceId;
notification_data.service_url = browser_sync::kSyncLegacyServiceUrl;
notification_data.send_content = false;
@@ -1523,7 +1512,7 @@ void SyncManager::SyncInternal::SendPendingXMPPNotification(
notification_data.send_content = true;
notification_data.priority = browser_sync::kSyncPriority;
notification_data.write_to_cache_only = true;
- if (notification_method_ == browser_sync::NOTIFICATION_NEW) {
+ if (notifier_options_.notification_method == notifier::NOTIFICATION_NEW) {
notification_data.service_specific_data =
browser_sync::kSyncServiceSpecificData;
notification_data.require_subscription = true;
@@ -1957,7 +1946,8 @@ void SyncManager::SyncInternal::HandleChannelEvent(const SyncerEvent& event) {
observer_->OnSyncCycleCompleted(event.snapshot);
}
- if (notification_method_ != browser_sync::NOTIFICATION_SERVER) {
+ if (notifier_options_.notification_method !=
+ notifier::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 =
@@ -2104,8 +2094,8 @@ void SyncManager::SyncInternal::OnNotificationStateChange(
if (syncer_thread()) {
syncer_thread()->SetNotificationsEnabled(notifications_enabled);
}
- if ((notification_method_ != browser_sync::NOTIFICATION_SERVER) &&
- notifications_enabled) {
+ if ((notifier_options_.notification_method !=
+ notifier::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
@@ -2146,7 +2136,8 @@ 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 ((notification_method_ == browser_sync::NOTIFICATION_SERVER) ||
+ if ((notifier_options_.notification_method ==
+ notifier::NOTIFICATION_SERVER) ||
notification_data.service_url.empty() ||
(notification_data.service_url ==
browser_sync::kSyncLegacyServiceUrl) ||
@@ -2164,7 +2155,8 @@ void SyncManager::SyncInternal::OnIncomingNotification(
}
void SyncManager::SyncInternal::OnOutgoingNotification() {
- DCHECK_NE(notification_method_, browser_sync::NOTIFICATION_SERVER);
+ DCHECK_NE(notifier_options_.notification_method,
+ notifier::NOTIFICATION_SERVER);
allstatus_.IncrementNotificationsSent();
}
diff --git a/chrome/browser/sync/engine/syncapi.h b/chrome/browser/sync/engine/syncapi.h
index c49fc67..5a2c182 100644
--- a/chrome/browser/sync/engine/syncapi.h
+++ b/chrome/browser/sync/engine/syncapi.h
@@ -46,7 +46,6 @@
#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"
@@ -62,6 +61,10 @@ 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 {
@@ -749,9 +752,7 @@ class SyncManager {
// used to log into XMPP is invalidated. This is used for testing
// code paths related to authentication failures for XMPP only.
//
- // |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.
+ // |notifier_options| contains options specific to sync notifications.
bool Init(const FilePath& database_location,
const char* sync_server_and_path,
int sync_server_port,
@@ -766,9 +767,7 @@ class SyncManager {
bool invalidate_xmpp_auth_token,
const char* user_agent,
const char* lsid,
- bool use_chrome_async_socket,
- bool try_ssltcp_first,
- browser_sync::NotificationMethod notification_method,
+ const notifier::NotifierOptions& notifier_options,
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 4aa5ac6..444ca33 100644
--- a/chrome/browser/sync/glue/sync_backend_host.cc
+++ b/chrome/browser/sync/glue/sync_backend_host.cc
@@ -79,9 +79,7 @@ void SyncBackendHost::Initialize(
bool delete_sync_data_folder,
bool invalidate_sync_login,
bool invalidate_sync_xmpp_login,
- bool use_chrome_async_socket,
- bool try_ssltcp_first,
- NotificationMethod notification_method) {
+ const notifier::NotifierOptions& notifier_options) {
if (!core_thread_.Start())
return;
@@ -117,9 +115,7 @@ void SyncBackendHost::Initialize(
delete_sync_data_folder,
invalidate_sync_login,
invalidate_sync_xmpp_login,
- use_chrome_async_socket,
- try_ssltcp_first,
- notification_method,
+ notifier_options,
RestoreEncryptionBootstrapToken()));
}
@@ -463,9 +459,7 @@ void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) {
options.invalidate_sync_xmpp_login,
MakeUserAgentForSyncapi().c_str(),
options.lsid.c_str(),
- options.use_chrome_async_socket,
- options.try_ssltcp_first,
- options.notification_method,
+ options.notifier_options,
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 69759df..6379295 100644
--- a/chrome/browser/sync/glue/sync_backend_host.h
+++ b/chrome/browser/sync/glue/sync_backend_host.h
@@ -16,7 +16,6 @@
#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"
@@ -25,10 +24,15 @@
#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,9 +113,7 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar {
bool delete_sync_data_folder,
bool invalidate_sync_login,
bool invalidate_sync_xmpp_login,
- bool use_chrome_async_socket,
- bool try_ssltcp_first,
- NotificationMethod notification_method);
+ const notifier::NotifierOptions& notifier_options);
// Called on |frontend_loop_| to kick off asynchronous authentication.
void Authenticate(const std::string& username, const std::string& password,
@@ -228,9 +230,7 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar {
bool delete_sync_data_folder,
bool invalidate_sync_login,
bool invalidate_sync_xmpp_login,
- bool use_chrome_async_socket,
- bool try_ssltcp_first,
- NotificationMethod notification_method,
+ const notifier::NotifierOptions& notifier_options,
std::string restored_key_for_bootstrapping)
: service_url(service_url),
attempt_last_user_authentication(attempt_last_user_authentication),
@@ -240,9 +240,7 @@ 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),
- use_chrome_async_socket(use_chrome_async_socket),
- try_ssltcp_first(try_ssltcp_first),
- notification_method(notification_method),
+ notifier_options(notifier_options),
restored_key_for_bootstrapping(restored_key_for_bootstrapping) {}
GURL service_url;
@@ -253,9 +251,7 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar {
bool delete_sync_data_folder;
bool invalidate_sync_login;
bool invalidate_sync_xmpp_login;
- bool use_chrome_async_socket;
- bool try_ssltcp_first;
- NotificationMethod notification_method;
+ notifier::NotifierOptions notifier_options;
std::string restored_key_for_bootstrapping;
};
@@ -315,16 +311,15 @@ 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 useable state.
+ // setup to nudge the syncapi into a usable state.
void DoInitializeForTest(const std::wstring& test_user,
sync_api::HttpPostProviderFactory* factory,
sync_api::HttpPostProviderFactory* auth_factory,
- bool delete_sync_data_folder,
- NotificationMethod notification_method) {
+ bool delete_sync_data_folder) {
DoInitialize(DoInitializeOptions(GURL(), false, factory, auth_factory,
std::string(), delete_sync_data_folder,
- false, false, false, false,
- notification_method, ""));
+ false, false,
+ notifier::NotifierOptions(), ""));
syncapi_->SetupForTestMode(test_user);
}
#endif
diff --git a/chrome/browser/sync/notifier/server_notifier_thread.cc b/chrome/browser/sync/notifier/server_notifier_thread.cc
index 8b2aba3..c31f502 100644
--- a/chrome/browser/sync/notifier/server_notifier_thread.cc
+++ b/chrome/browser/sync/notifier/server_notifier_thread.cc
@@ -9,14 +9,18 @@
#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(bool use_chrome_async_socket,
- bool try_ssltcp_first)
- : notifier::MediatorThreadImpl(use_chrome_async_socket, try_ssltcp_first),
- state_(notifier::STATE_DISCONNECTED) {}
+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() {}
diff --git a/chrome/browser/sync/notifier/server_notifier_thread.h b/chrome/browser/sync/notifier/server_notifier_thread.h
index 9247bd4..bcd85b0 100644
--- a/chrome/browser/sync/notifier/server_notifier_thread.h
+++ b/chrome/browser/sync/notifier/server_notifier_thread.h
@@ -21,13 +21,18 @@
#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:
- ServerNotifierThread(bool use_chrome_async_socket, bool try_ssltcp_first);
+ explicit ServerNotifierThread(
+ const notifier::NotifierOptions& notifier_options);
virtual ~ServerNotifierThread();
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 226923e..64d41e6 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -38,6 +38,7 @@
#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;
@@ -66,8 +67,6 @@ 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);
@@ -116,8 +115,6 @@ 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) {
}
@@ -211,17 +208,35 @@ void ProfileSyncService::InitSettings() {
LOG(INFO) << "Using " << sync_service_url_ << " for sync server URL.";
- use_chrome_async_socket_ =
+ // 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 =
!command_line.HasSwitch(switches::kSyncDisableChromeAsyncSocket);
- if (use_chrome_async_socket_) {
+ if (notifier_options_.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));
- notification_method_ =
- browser_sync::StringToNotificationMethod(notification_method_str);
+ notifier_options_.notification_method =
+ notifier::StringToNotificationMethod(notification_method_str);
}
}
@@ -280,14 +295,11 @@ void ProfileSyncService::InitializeBackend(bool delete_sync_data_folder) {
bool invalidate_sync_login = false;
bool invalidate_sync_xmpp_login = false;
- bool try_ssltcp_first = false;
#if !defined(NDEBUG)
invalidate_sync_login = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kInvalidateSyncLogin);
invalidate_sync_xmpp_login = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kInvalidateSyncXmppLogin);
- try_ssltcp_first = CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kSyncUseSslTcp);
#endif
syncable::ModelTypeSet types;
@@ -303,9 +315,7 @@ void ProfileSyncService::InitializeBackend(bool delete_sync_data_folder) {
delete_sync_data_folder,
invalidate_sync_login,
invalidate_sync_xmpp_login,
- use_chrome_async_socket_,
- try_ssltcp_first,
- notification_method_);
+ notifier_options_);
}
void ProfileSyncService::CreateBackend() {
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index ac64c94..2a97a1c 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -19,7 +19,6 @@
#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"
@@ -28,6 +27,7 @@
#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;
@@ -433,12 +433,9 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
std::string unrecoverable_error_message_;
scoped_ptr<tracked_objects::Location> unrecoverable_error_location_;
- // 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_;
+ // Contains options specific to how sync clients send and listen to
+ // notifications.
+ notifier::NotifierOptions notifier_options_;
// 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 bb366c7..7cbc37c 100644
--- a/chrome/browser/sync/profile_sync_service_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_unittest.cc
@@ -26,7 +26,6 @@
#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 baaceb6..7482bcb 100644
--- a/chrome/browser/sync/profile_sync_test_util.h
+++ b/chrome/browser/sync/profile_sync_test_util.h
@@ -24,7 +24,6 @@
#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 aba7c42..8a00515 100644
--- a/chrome/browser/sync/test_profile_sync_service.h
+++ b/chrome/browser/sync/test_profile_sync_service.h
@@ -155,8 +155,7 @@ class SyncBackendHostForProfileSyncTest : public SyncBackendHost {
user,
options.http_bridge_factory,
options.auth_http_bridge_factory,
- options.delete_sync_data_folder,
- browser_sync::kDefaultNotificationMethod));
+ options.delete_sync_data_folder));
// 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 56c8eed..0a7751d 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";
- browser_sync::NotificationMethod notification_method =
- browser_sync::NOTIFICATION_TRANSITIONAL;
+ notifier::NotificationMethod notification_method =
+ notifier::NOTIFICATION_TRANSITIONAL;
std::vector<std::string> subscribed_services_list;
- if (notification_method != browser_sync::NOTIFICATION_LEGACY) {
- if (notification_method == browser_sync::NOTIFICATION_TRANSITIONAL) {
+ if (notification_method != notifier::NOTIFICATION_LEGACY) {
+ if (notification_method == notifier::NOTIFICATION_TRANSITIONAL) {
subscribed_services_list.push_back(
browser_sync::kSyncLegacyServiceUrl);
}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index cb5b6bb..83ad314 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2618,8 +2618,6 @@
'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 65b1d00..331a0bd 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -1012,6 +1012,9 @@ 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 f47a609..842adff 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -285,6 +285,7 @@ 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 b0e621f..865ec8e 100644
--- a/chrome/service/cloud_print/cloud_print_proxy_backend.cc
+++ b/chrome/service/cloud_print/cloud_print_proxy_backend.cc
@@ -14,6 +14,7 @@
#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"
@@ -301,13 +302,12 @@ void CloudPrintProxyBackend::Core::DoInitializeWithToken(
// TODO(sanjeevr): Validate the tokens.
auth_token_ = cloud_print_token;
- const bool kUseChromeAsyncSocket = true;
- const bool kTrySslTcpFirst = false;
+ const notifier::NotifierOptions kNotifierOptions;
const bool kInitializeSsl = true;
const bool kConnectImmediately = false;
const bool kInvalidateXmppAuthToken = false;
talk_mediator_.reset(new notifier::TalkMediatorImpl(
- new notifier::MediatorThreadImpl(kUseChromeAsyncSocket, kTrySslTcpFirst),
+ new notifier::MediatorThreadImpl(kNotifierOptions),
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 5ff3e74..5191855 100644
--- a/chrome/test/live_sync/live_sync_test.cc
+++ b/chrome/test/live_sync/live_sync_test.cc
@@ -123,6 +123,8 @@ 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
@@ -249,6 +251,9 @@ 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 dd76e04..2f01fff 100644
--- a/jingle/jingle.gyp
+++ b/jingle/jingle.gyp
@@ -22,6 +22,9 @@
'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/chrome/browser/sync/notification_method.cc b/jingle/notifier/base/notification_method.cc
index 2c9896a..08feb4a 100644
--- a/chrome/browser/sync/notification_method.cc
+++ b/jingle/notifier/base/notification_method.cc
@@ -2,14 +2,13 @@
// 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 "jingle/notifier/base/notification_method.h"
#include "base/logging.h"
-namespace browser_sync {
+namespace notifier {
-const NotificationMethod kDefaultNotificationMethod =
- NOTIFICATION_SERVER;
+const NotificationMethod kDefaultNotificationMethod = NOTIFICATION_SERVER;
std::string NotificationMethodToString(
NotificationMethod notification_method) {
@@ -50,4 +49,4 @@ NotificationMethod StringToNotificationMethod(const std::string& str) {
return kDefaultNotificationMethod;
}
-} // namespace browser_sync
+} // namespace notifier
diff --git a/chrome/browser/sync/notification_method.h b/jingle/notifier/base/notification_method.h
index 416dbe9..aedc11d 100644
--- a/chrome/browser/sync/notification_method.h
+++ b/jingle/notifier/base/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 CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_
-#define CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_
+#ifndef JINGLE_NOTIFIER_BASE_NOTIFICATION_METHOD_H_
+#define JINGLE_NOTIFIER_BASE_NOTIFICATION_METHOD_H_
#pragma once
#include <string>
-namespace browser_sync {
+namespace notifier {
// 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 browser_sync
+} // namespace notifier
-#endif // CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_
+#endif // JINGLE_NOTIFIER_BASE_NOTIFICATION_METHOD_H_
diff --git a/jingle/notifier/base/notifier_options.h b/jingle/notifier/base/notifier_options.h
new file mode 100644
index 0000000..32374cf
--- /dev/null
+++ b/jingle/notifier/base/notifier_options.h
@@ -0,0 +1,47 @@
+// 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 63e404e..02d48fb1 100644
--- a/jingle/notifier/listener/mediator_thread_impl.cc
+++ b/jingle/notifier/listener/mediator_thread_impl.cc
@@ -26,12 +26,10 @@ DISABLE_RUNNABLE_METHOD_REFCOUNT(notifier::MediatorThreadImpl);
namespace notifier {
-MediatorThreadImpl::MediatorThreadImpl(bool use_chrome_async_socket,
- bool try_ssltcp_first)
+MediatorThreadImpl::MediatorThreadImpl(const NotifierOptions& notifier_options)
: delegate_(NULL),
parent_message_loop_(MessageLoop::current()),
- use_chrome_async_socket_(use_chrome_async_socket),
- try_ssltcp_first_(try_ssltcp_first),
+ notifier_options_(notifier_options),
worker_thread_("MediatorThread worker thread") {
DCHECK(parent_message_loop_);
}
@@ -53,7 +51,7 @@ void MediatorThreadImpl::Start() {
// TODO(akalin): Make this function return a bool and remove this
// CHECK().
CHECK(worker_thread_.StartWithOptions(options));
- if (!use_chrome_async_socket_) {
+ if (!notifier_options_.use_chrome_async_socket) {
worker_message_loop()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &MediatorThreadImpl::StartLibjingleThread));
@@ -62,7 +60,7 @@ void MediatorThreadImpl::Start() {
void MediatorThreadImpl::StartLibjingleThread() {
DCHECK_EQ(MessageLoop::current(), worker_message_loop());
- DCHECK(!use_chrome_async_socket_);
+ DCHECK(!notifier_options_.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());
@@ -73,7 +71,7 @@ void MediatorThreadImpl::StartLibjingleThread() {
void MediatorThreadImpl::StopLibjingleThread() {
DCHECK_EQ(MessageLoop::current(), worker_message_loop());
- DCHECK(!use_chrome_async_socket_);
+ DCHECK(!notifier_options_.use_chrome_async_socket);
talk_base::ThreadManager::SetCurrent(NULL);
libjingle_thread_.reset();
socket_server_.reset();
@@ -81,7 +79,7 @@ void MediatorThreadImpl::StopLibjingleThread() {
void MediatorThreadImpl::PumpLibjingleLoop() {
DCHECK_EQ(MessageLoop::current(), worker_message_loop());
- DCHECK(!use_chrome_async_socket_);
+ DCHECK(!notifier_options_.use_chrome_async_socket);
// Pump the libjingle message loop 100ms at a time.
if (!libjingle_thread_.get()) {
// StopLibjingleThread() was called.
@@ -105,7 +103,7 @@ void MediatorThreadImpl::Logout() {
worker_message_loop()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &MediatorThreadImpl::DoDisconnect));
- if (!use_chrome_async_socket_) {
+ if (!notifier_options_.use_chrome_async_socket) {
worker_message_loop()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &MediatorThreadImpl::StopLibjingleThread));
@@ -182,15 +180,24 @@ void MediatorThreadImpl::DoLogin(
pump_.reset(new notifier::TaskPump());
notifier::ServerInformation server_list[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;
+ 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;
+ }
// Autodetect proxy is on by default.
notifier::ConnectionOptions options;
@@ -198,7 +205,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(),
- use_chrome_async_socket_,
+ notifier_options_.use_chrome_async_socket,
settings,
options,
lang,
@@ -207,7 +214,7 @@ void MediatorThreadImpl::DoLogin(
server_list_count,
// talk_base::FirewallManager* is NULL.
NULL,
- try_ssltcp_first_,
+ notifier_options_.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 39eca59..755731e 100644
--- a/jingle/notifier/listener/mediator_thread_impl.h
+++ b/jingle/notifier/listener/mediator_thread_impl.h
@@ -27,6 +27,7 @@
#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"
@@ -59,7 +60,7 @@ class MediatorThreadImpl
: public MediatorThread,
public sigslot::has_slots<> {
public:
- MediatorThreadImpl(bool use_chrome_async_socket, bool try_ssltcp_first);
+ explicit MediatorThreadImpl(const NotifierOptions& notifier_options);
virtual ~MediatorThreadImpl();
virtual void SetDelegate(Delegate* delegate);
@@ -124,8 +125,7 @@ class MediatorThreadImpl
void OnSubscriptionStateChangeOnParentThread(
bool success);
- const bool use_chrome_async_socket_;
- const bool try_ssltcp_first_;
+ const NotifierOptions notifier_options_;
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 a138052..36bc94b 100644
--- a/jingle/notifier/listener/talk_mediator_unittest.cc
+++ b/jingle/notifier/listener/talk_mediator_unittest.cc
@@ -6,6 +6,7 @@
#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"
@@ -38,14 +39,13 @@ class TalkMediatorImplTest : public testing::Test {
virtual ~TalkMediatorImplTest() {}
TalkMediatorImpl* NewTalkMediator() {
- const bool kUseChromeAsyncSocket = false;
- const bool kTrySslTcpFirst = false;
+ const notifier::NotifierOptions kNotifierOptions;
const bool kInitializeSsl = true;
const bool kConnectImmediately = false;
const bool kInvalidateXmppAuthToken = false;
return new TalkMediatorImpl(
- new MediatorThreadImpl(kUseChromeAsyncSocket, kTrySslTcpFirst),
- kInitializeSsl, kConnectImmediately, kInvalidateXmppAuthToken);
+ new MediatorThreadImpl(kNotifierOptions), kInitializeSsl,
+ kConnectImmediately, kInvalidateXmppAuthToken);
}
TalkMediatorImpl* NewMockedTalkMediator(