Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Unified Diff: chrome/browser/sync/glue/sync_backend_host.cc

Issue 9550009: [Sync] Move dependency on Chrome switches from SyncNotifierFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.h ('k') | chrome/browser/sync/notifier/sync_notifier_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()) {
}
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.h ('k') | chrome/browser/sync/notifier/sync_notifier_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698