Index: chrome/browser/sync/glue/sync_backend_host.cc |
diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc |
index 0c8edf233c4fb836c37ccadde624dc5d2d8f92d5..bc6df6e767d2cf3995721b5bfade048c3c2d1a41 100644 |
--- a/chrome/browser/sync/glue/sync_backend_host.cc |
+++ b/chrome/browser/sync/glue/sync_backend_host.cc |
@@ -35,11 +35,16 @@ |
#include "chrome/browser/sync/sync_prefs.h" |
#include "chrome/browser/sync/util/nigori.h" |
#include "chrome/common/chrome_notification_types.h" |
+#include "chrome/common/chrome_switches.h" |
#include "chrome/common/chrome_version_info.h" |
#include "chrome/common/net/gaia/gaia_constants.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/common/content_client.h" |
+#include "jingle/notifier/base/notification_method.h" |
+#include "jingle/notifier/base/notifier_options.h" |
+#include "net/base/host_port_pair.h" |
+#include "net/url_request/url_request_context_getter.h" |
static const int kSaveChangesIntervalSeconds = 10; |
static const FilePath::CharType kSyncDataFolderName[] = |
@@ -224,6 +229,54 @@ class SyncBackendHost::Core |
DISALLOW_COPY_AND_ASSIGN(Core); |
}; |
+namespace { |
+ |
+// Parses the given command line for notifier options. |
+notifier::NotifierOptions ParseNotifierOptions( |
Nicolas Zea
2012/03/06 19:00:58
Can this be in it's own file within glue/ (so sync
akalin
2012/03/06 22:27:57
Ideally, sync_listen_notifications wouldn't depend
|
+ const CommandLine& command_line, |
+ const scoped_refptr<net::URLRequestContextGetter>& |
+ request_context_getter) { |
+ notifier::NotifierOptions notifier_options; |
+ notifier_options.request_context_getter = request_context_getter; |
+ |
+ if (command_line.HasSwitch(switches::kSyncNotificationHostPort)) { |
+ notifier_options.xmpp_host_port = |
+ net::HostPortPair::FromString( |
+ command_line.GetSwitchValueASCII( |
+ switches::kSyncNotificationHostPort)); |
+ DVLOG(1) << "Using " << notifier_options.xmpp_host_port.ToString() |
+ << " for test sync notification server."; |
+ } |
+ |
+ notifier_options.try_ssltcp_first = |
+ command_line.HasSwitch(switches::kSyncTrySsltcpFirstForXmpp); |
+ if (notifier_options.try_ssltcp_first) |
+ DVLOG(1) << "Trying SSL/TCP port before XMPP port for notifications."; |
Nicolas Zea
2012/03/06 19:00:58
dvlog_if (here and below)
akalin
2012/03/06 22:27:57
Done. Also fixed sync_listen_notifications to use
|
+ |
+ notifier_options.invalidate_xmpp_login = |
+ command_line.HasSwitch(switches::kSyncInvalidateXmppLogin); |
+ if (notifier_options.invalidate_xmpp_login) { |
+ DVLOG(1) << "Invalidating sync XMPP login."; |
+ } |
+ |
+ notifier_options.allow_insecure_connection = |
+ command_line.HasSwitch(switches::kSyncAllowInsecureXmppConnection); |
+ if (notifier_options.allow_insecure_connection) { |
+ DVLOG(1) << "Allowing insecure XMPP connections."; |
+ } |
+ |
+ 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); |
+ } |
+ |
+ return notifier_options; |
+} |
+ |
+} // namespace |
+ |
SyncBackendHost::SyncBackendHost(const std::string& name, |
Profile* profile, |
const base::WeakPtr<SyncPrefs>& sync_prefs) |
@@ -238,10 +291,10 @@ SyncBackendHost::SyncBackendHost(const std::string& name, |
sync_prefs_(sync_prefs), |
chrome_sync_notification_bridge_(profile_), |
sync_notifier_factory_( |
+ ParseNotifierOptions(*CommandLine::ForCurrentProcess(), |
+ profile_->GetRequestContext()), |
content::GetUserAgent(GURL()), |
- profile_->GetRequestContext(), |
- sync_prefs, |
- *CommandLine::ForCurrentProcess()), |
+ sync_prefs), |
frontend_(NULL), |
last_auth_error_(AuthError::None()) { |
} |
@@ -255,10 +308,10 @@ SyncBackendHost::SyncBackendHost(Profile* profile) |
initialization_state_(NOT_ATTEMPTED), |
chrome_sync_notification_bridge_(profile_), |
sync_notifier_factory_( |
+ ParseNotifierOptions(*CommandLine::ForCurrentProcess(), |
+ profile_->GetRequestContext()), |
content::GetUserAgent(GURL()), |
- NULL, |
- base::WeakPtr<sync_notifier::InvalidationVersionTracker>(), |
- *CommandLine::ForCurrentProcess()), |
+ base::WeakPtr<sync_notifier::InvalidationVersionTracker>()), |
frontend_(NULL), |
last_auth_error_(AuthError::None()) { |
} |