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

Side by Side Diff: chrome/browser/invalidation/ticl_invalidation_service.cc

Issue 186623006: Refactor GCMNetworkChannelDelegateImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another rebase to resolve conflict with recent change. Created 6 years, 9 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/invalidation/ticl_invalidation_service.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/invalidation/ticl_invalidation_service.h" 5 #include "chrome/browser/invalidation/ticl_invalidation_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "chrome/browser/invalidation/gcm_network_channel_delegate_impl.h" 9 #include "chrome/browser/invalidation/gcm_invalidation_bridge.h"
10 #include "chrome/browser/invalidation/invalidation_logger.h" 10 #include "chrome/browser/invalidation/invalidation_logger.h"
11 #include "chrome/browser/invalidation/invalidation_service_util.h" 11 #include "chrome/browser/invalidation/invalidation_service_util.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/signin/about_signin_internals.h" 13 #include "chrome/browser/signin/about_signin_internals.h"
14 #include "chrome/browser/signin/about_signin_internals_factory.h" 14 #include "chrome/browser/signin/about_signin_internals_factory.h"
15 #include "chrome/browser/signin/profile_oauth2_token_service.h" 15 #include "chrome/browser/signin/profile_oauth2_token_service.h"
16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
17 #include "google_apis/gaia/gaia_constants.h" 17 #include "google_apis/gaia/gaia_constants.h"
18 #include "sync/notifier/gcm_network_channel_delegate.h" 18 #include "sync/notifier/gcm_network_channel_delegate.h"
19 #include "sync/notifier/invalidation_util.h" 19 #include "sync/notifier/invalidation_util.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 notifier::NotifierOptions options = 349 notifier::NotifierOptions options =
350 ParseNotifierOptions(*CommandLine::ForCurrentProcess()); 350 ParseNotifierOptions(*CommandLine::ForCurrentProcess());
351 options.request_context_getter = profile_->GetRequestContext(); 351 options.request_context_getter = profile_->GetRequestContext();
352 options.auth_mechanism = "X-OAUTH2"; 352 options.auth_mechanism = "X-OAUTH2";
353 DCHECK_EQ(notifier::NOTIFICATION_SERVER, options.notification_method); 353 DCHECK_EQ(notifier::NOTIFICATION_SERVER, options.notification_method);
354 network_channel_creator = 354 network_channel_creator =
355 syncer::NonBlockingInvalidator::MakePushClientChannelCreator(options); 355 syncer::NonBlockingInvalidator::MakePushClientChannelCreator(options);
356 break; 356 break;
357 } 357 }
358 case GCM_NETWORK_CHANNEL: { 358 case GCM_NETWORK_CHANNEL: {
359 scoped_ptr<syncer::GCMNetworkChannelDelegate> delegate; 359 gcm_invalidation_bridge_.reset(new GCMInvalidationBridge(profile_));
360 delegate.reset(new GCMNetworkChannelDelegateImpl(profile_));
361 network_channel_creator = 360 network_channel_creator =
362 syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator( 361 syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator(
363 profile_->GetRequestContext(), 362 profile_->GetRequestContext(),
364 delegate.Pass()); 363 gcm_invalidation_bridge_->CreateDelegate().Pass());
365 break; 364 break;
366 } 365 }
367 default: { 366 default: {
368 NOTREACHED(); 367 NOTREACHED();
369 return; 368 return;
370 } 369 }
371 } 370 }
372 invalidator_.reset(new syncer::NonBlockingInvalidator( 371 invalidator_.reset(new syncer::NonBlockingInvalidator(
373 network_channel_creator, 372 network_channel_creator,
374 invalidator_storage_->GetInvalidatorClientId(), 373 invalidator_storage_->GetInvalidatorClientId(),
(...skipping 16 matching lines...) Expand all
391 std::string email = signin_manager_->GetAuthenticatedUsername(); 390 std::string email = signin_manager_->GetAuthenticatedUsername();
392 391
393 DCHECK(!email.empty()) << "Expected user to be signed in."; 392 DCHECK(!email.empty()) << "Expected user to be signed in.";
394 393
395 DVLOG(2) << "UpdateCredentials: " << email; 394 DVLOG(2) << "UpdateCredentials: " << email;
396 invalidator_->UpdateCredentials(email, access_token_); 395 invalidator_->UpdateCredentials(email, access_token_);
397 } 396 }
398 397
399 void TiclInvalidationService::StopInvalidator() { 398 void TiclInvalidationService::StopInvalidator() {
400 DCHECK(invalidator_); 399 DCHECK(invalidator_);
400 gcm_invalidation_bridge_.reset();
401 invalidator_->UnregisterHandler(this); 401 invalidator_->UnregisterHandler(this);
402 invalidator_.reset(); 402 invalidator_.reset();
403 } 403 }
404 404
405 void TiclInvalidationService::Logout() { 405 void TiclInvalidationService::Logout() {
406 access_token_request_.reset(); 406 access_token_request_.reset();
407 request_access_token_retry_timer_.Stop(); 407 request_access_token_retry_timer_.Stop();
408 408
409 if (IsStarted()) { 409 if (IsStarted()) {
410 StopInvalidator(); 410 StopInvalidator();
411 } 411 }
412 412
413 // This service always expects to have a valid invalidator storage. 413 // This service always expects to have a valid invalidator storage.
414 // So we must not only clear the old one, but also start a new one. 414 // So we must not only clear the old one, but also start a new one.
415 invalidator_storage_->Clear(); 415 invalidator_storage_->Clear();
416 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); 416 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs()));
417 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); 417 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId());
418 } 418 }
419 419
420 } // namespace invalidation 420 } // namespace invalidation
OLDNEW
« no previous file with comments | « chrome/browser/invalidation/ticl_invalidation_service.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698