Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/invalidation/gcm_network_channel_delegate_impl.h" | 10 #include "chrome/browser/invalidation/gcm_invalidation_bridge.h" |
| 11 #include "chrome/browser/invalidation/invalidation_logger.h" | 11 #include "chrome/browser/invalidation/invalidation_logger.h" |
| 12 #include "chrome/browser/invalidation/invalidation_service_util.h" | 12 #include "chrome/browser/invalidation/invalidation_service_util.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/signin/about_signin_internals.h" | 14 #include "chrome/browser/signin/about_signin_internals.h" |
| 15 #include "chrome/browser/signin/about_signin_internals_factory.h" | 15 #include "chrome/browser/signin/about_signin_internals_factory.h" |
| 16 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 16 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 18 #include "chrome/browser/signin/signin_manager.h" | 18 #include "chrome/browser/signin/signin_manager.h" |
| 19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 20 #include "google_apis/gaia/gaia_constants.h" | 20 #include "google_apis/gaia/gaia_constants.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 notifier::NotifierOptions options = | 352 notifier::NotifierOptions options = |
| 353 ParseNotifierOptions(*CommandLine::ForCurrentProcess()); | 353 ParseNotifierOptions(*CommandLine::ForCurrentProcess()); |
| 354 options.request_context_getter = profile_->GetRequestContext(); | 354 options.request_context_getter = profile_->GetRequestContext(); |
| 355 options.auth_mechanism = "X-OAUTH2"; | 355 options.auth_mechanism = "X-OAUTH2"; |
| 356 DCHECK_EQ(notifier::NOTIFICATION_SERVER, options.notification_method); | 356 DCHECK_EQ(notifier::NOTIFICATION_SERVER, options.notification_method); |
| 357 network_channel_creator = | 357 network_channel_creator = |
| 358 syncer::NonBlockingInvalidator::MakePushClientChannelCreator(options); | 358 syncer::NonBlockingInvalidator::MakePushClientChannelCreator(options); |
| 359 break; | 359 break; |
| 360 } | 360 } |
| 361 case GCM_NETWORK_CHANNEL: { | 361 case GCM_NETWORK_CHANNEL: { |
| 362 scoped_ptr<syncer::GCMNetworkChannelDelegate> delegate; | 362 gcm_invalidation_bridge_.reset(new GCMInvalidationBridge(profile_)); |
| 363 delegate.reset(new GCMNetworkChannelDelegateImpl(profile_)); | |
| 364 network_channel_creator = | 363 network_channel_creator = |
| 365 syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator( | 364 syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator( |
| 366 profile_->GetRequestContext(), | 365 profile_->GetRequestContext(), |
| 367 delegate.Pass()); | 366 gcm_invalidation_bridge_->CreateDelegate().Pass()); |
| 368 break; | 367 break; |
| 369 } | 368 } |
| 370 default: { | 369 default: { |
| 371 NOTREACHED(); | 370 NOTREACHED(); |
| 372 return; | 371 return; |
| 373 } | 372 } |
| 374 } | 373 } |
| 375 invalidator_.reset(new syncer::NonBlockingInvalidator( | 374 invalidator_.reset(new syncer::NonBlockingInvalidator( |
| 376 network_channel_creator, | 375 network_channel_creator, |
| 377 invalidator_storage_->GetInvalidatorClientId(), | 376 invalidator_storage_->GetInvalidatorClientId(), |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 394 std::string email = signin_manager_->GetAuthenticatedUsername(); | 393 std::string email = signin_manager_->GetAuthenticatedUsername(); |
| 395 | 394 |
| 396 DCHECK(!email.empty()) << "Expected user to be signed in."; | 395 DCHECK(!email.empty()) << "Expected user to be signed in."; |
| 397 | 396 |
| 398 DVLOG(2) << "UpdateCredentials: " << email; | 397 DVLOG(2) << "UpdateCredentials: " << email; |
| 399 invalidator_->UpdateCredentials(email, access_token_); | 398 invalidator_->UpdateCredentials(email, access_token_); |
| 400 } | 399 } |
| 401 | 400 |
| 402 void TiclInvalidationService::StopInvalidator() { | 401 void TiclInvalidationService::StopInvalidator() { |
| 403 DCHECK(invalidator_); | 402 DCHECK(invalidator_); |
| 403 gcm_invalidation_bridge_.reset(); | |
|
rlarocque
2014/03/04 21:30:19
Should this be reset after the invalidator_? Does
pavely
2014/03/04 23:01:54
Doesn't really matter, they are independent object
| |
| 404 invalidator_->UnregisterHandler(this); | 404 invalidator_->UnregisterHandler(this); |
| 405 invalidator_.reset(); | 405 invalidator_.reset(); |
| 406 } | 406 } |
| 407 | 407 |
| 408 void TiclInvalidationService::Logout() { | 408 void TiclInvalidationService::Logout() { |
| 409 access_token_request_.reset(); | 409 access_token_request_.reset(); |
| 410 request_access_token_retry_timer_.Stop(); | 410 request_access_token_retry_timer_.Stop(); |
| 411 | 411 |
| 412 if (IsStarted()) { | 412 if (IsStarted()) { |
| 413 StopInvalidator(); | 413 StopInvalidator(); |
| 414 } | 414 } |
| 415 | 415 |
| 416 // This service always expects to have a valid invalidator storage. | 416 // This service always expects to have a valid invalidator storage. |
| 417 // So we must not only clear the old one, but also start a new one. | 417 // So we must not only clear the old one, but also start a new one. |
| 418 invalidator_storage_->Clear(); | 418 invalidator_storage_->Clear(); |
| 419 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); | 419 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); |
| 420 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); | 420 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); |
| 421 } | 421 } |
| 422 | 422 |
| 423 } // namespace invalidation | 423 } // namespace invalidation |
| OLD | NEW |