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

Unified Diff: chrome/browser/invalidation/ticl_invalidation_service.cc

Issue 116533006: Control invalidations network channel from TiclInvalidationService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 12 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/invalidation/ticl_invalidation_service.h ('k') | sync/notifier/gcm_network_channel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/invalidation/ticl_invalidation_service.cc
diff --git a/chrome/browser/invalidation/ticl_invalidation_service.cc b/chrome/browser/invalidation/ticl_invalidation_service.cc
index 0935f7ef039beefd0c8690038c0d7fd11b643803..c32714d00ee36613844c939960fbeae9c5ff7999 100644
--- a/chrome/browser/invalidation/ticl_invalidation_service.cc
+++ b/chrome/browser/invalidation/ticl_invalidation_service.cc
@@ -81,7 +81,7 @@ void TiclInvalidationService::Init() {
}
if (IsReadyToStart()) {
- StartInvalidator();
+ StartInvalidator(PUSH_CLIENT_CHANNEL);
}
notification_registrar_.Add(this,
@@ -190,7 +190,7 @@ void TiclInvalidationService::OnGetTokenSuccess(
request_access_token_backoff_.Reset();
access_token_ = access_token;
if (!IsStarted() && IsReadyToStart()) {
- StartInvalidator();
+ StartInvalidator(PUSH_CLIENT_CHANNEL);
} else {
UpdateInvalidatorCredentials();
}
@@ -230,7 +230,7 @@ void TiclInvalidationService::OnRefreshTokenAvailable(
const std::string& account_id) {
if (oauth2_token_service_->GetPrimaryAccountId() == account_id) {
if (!IsStarted() && IsReadyToStart()) {
- StartInvalidator();
+ StartInvalidator(PUSH_CLIENT_CHANNEL);
}
}
}
@@ -313,7 +313,8 @@ bool TiclInvalidationService::IsStarted() {
return invalidator_.get() != NULL;
}
-void TiclInvalidationService::StartInvalidator() {
+void TiclInvalidationService::StartInvalidator(
+ InvalidationNetworkChannel network_channel) {
DCHECK(CalledOnValidThread());
DCHECK(!invalidator_);
DCHECK(invalidator_storage_);
@@ -327,18 +328,38 @@ void TiclInvalidationService::StartInvalidator() {
return;
}
- notifier::NotifierOptions options =
- ParseNotifierOptions(*CommandLine::ForCurrentProcess());
- options.request_context_getter = profile_->GetRequestContext();
- options.auth_mechanism = "X-OAUTH2";
+ syncer::NetworkChannelCreator network_channel_creator;
+
+ switch (network_channel) {
+ case PUSH_CLIENT_CHANNEL: {
+ notifier::NotifierOptions options =
+ ParseNotifierOptions(*CommandLine::ForCurrentProcess());
+ options.request_context_getter = profile_->GetRequestContext();
+ options.auth_mechanism = "X-OAUTH2";
+ DCHECK_EQ(notifier::NOTIFICATION_SERVER, options.notification_method);
+ network_channel_creator =
+ syncer::NonBlockingInvalidator::MakePushClientChannelCreator(options);
+ break;
+ }
+ case GCM_NETWORK_CHANNEL: {
+ network_channel_creator =
+ syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator();
+ break;
+ }
+ default: {
+ NOTREACHED();
+ return;
+ }
+ }
invalidator_.reset(new syncer::NonBlockingInvalidator(
- options,
+ network_channel_creator,
invalidator_storage_->GetInvalidatorClientId(),
invalidator_storage_->GetSavedInvalidations(),
invalidator_storage_->GetBootstrapData(),
syncer::WeakHandle<syncer::InvalidationStateTracker>(
invalidator_storage_->AsWeakPtr()),
- content::GetUserAgent(GURL())));
+ content::GetUserAgent(GURL()),
+ profile_->GetRequestContext()));
UpdateInvalidatorCredentials();
« no previous file with comments | « chrome/browser/invalidation/ticl_invalidation_service.h ('k') | sync/notifier/gcm_network_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698