summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync
diff options
context:
space:
mode:
authorrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-08 19:25:28 +0000
committerrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-08 19:25:28 +0000
commit33cd0041d46c0593dfb90a87e861ca47976fab49 (patch)
tree2f3328ddf8d1044211943564e12348b7224afd72 /chrome/browser/sync
parent1ce52aae084f6a0201c64141e35772fc70bab1f0 (diff)
downloadchromium_src-33cd0041d46c0593dfb90a87e861ca47976fab49.zip
chromium_src-33cd0041d46c0593dfb90a87e861ca47976fab49.tar.gz
chromium_src-33cd0041d46c0593dfb90a87e861ca47976fab49.tar.bz2
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 First time committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=58768 Review URL: http://codereview.chromium.org/3326007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58860 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
-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/notification_method.cc53
-rw-r--r--chrome/browser/sync/notification_method.h68
-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
14 files changed, 95 insertions, 223 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/notification_method.cc b/chrome/browser/sync/notification_method.cc
deleted file mode 100644
index 2c9896a..0000000
--- a/chrome/browser/sync/notification_method.cc
+++ /dev/null
@@ -1,53 +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.
-
-#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 "<unknown notification method>";
-}
-
-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
deleted file mode 100644
index 416dbe9..0000000
--- a/chrome/browser/sync/notification_method.h
+++ /dev/null
@@ -1,68 +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 CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_
-#define CHROME_BROWSER_SYNC_NOTIFICATION_METHOD_H_
-#pragma once
-
-#include <string>
-
-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 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);
}