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 "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "chrome/browser/invalidation/gcm_invalidation_bridge.h" | 10 #include "chrome/browser/invalidation/gcm_invalidation_bridge.h" |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 UpdateInvalidatorCredentials(); | 421 UpdateInvalidatorCredentials(); |
422 | 422 |
423 invalidator_->RegisterHandler(this); | 423 invalidator_->RegisterHandler(this); |
424 invalidator_->UpdateRegisteredIds( | 424 invalidator_->UpdateRegisteredIds( |
425 this, | 425 this, |
426 invalidator_registrar_->GetAllRegisteredIds()); | 426 invalidator_registrar_->GetAllRegisteredIds()); |
427 } | 427 } |
428 | 428 |
429 void TiclInvalidationService::UpdateInvalidationNetworkChannel() { | 429 void TiclInvalidationService::UpdateInvalidationNetworkChannel() { |
430 InvalidationNetworkChannel network_channel_type = PUSH_CLIENT_CHANNEL; | 430 InvalidationNetworkChannel network_channel_type = PUSH_CLIENT_CHANNEL; |
431 // For now don't use GCM on iOS. | |
432 #if !defined(OS_IOS) | |
433 if (profile_->GetPrefs()->GetBoolean( | 431 if (profile_->GetPrefs()->GetBoolean( |
434 prefs::kInvalidationServiceUseGCMChannel) && | 432 prefs::kInvalidationServiceUseGCMChannel) && |
435 gcm::GCMProfileService::GetGCMEnabledState(profile_) == | 433 gcm::GCMProfileService::GetGCMEnabledState(profile_) == |
436 gcm::GCMProfileService::ALWAYS_ENABLED) { | 434 gcm::GCMProfileService::ALWAYS_ENABLED) { |
437 network_channel_type = GCM_NETWORK_CHANNEL; | 435 network_channel_type = GCM_NETWORK_CHANNEL; |
438 } | 436 } |
439 #endif | |
440 if (network_channel_type_ == network_channel_type) | 437 if (network_channel_type_ == network_channel_type) |
441 return; | 438 return; |
442 network_channel_type_ = network_channel_type; | 439 network_channel_type_ = network_channel_type; |
443 if (IsStarted()) { | 440 if (IsStarted()) { |
444 StopInvalidator(); | 441 StopInvalidator(); |
445 StartInvalidator(network_channel_type_); | 442 StartInvalidator(network_channel_type_); |
446 } | 443 } |
447 } | 444 } |
448 | 445 |
449 void TiclInvalidationService::UpdateInvalidatorCredentials() { | 446 void TiclInvalidationService::UpdateInvalidatorCredentials() { |
450 std::string email = auth_provider_->GetAccountId(); | 447 std::string email = auth_provider_->GetAccountId(); |
451 | 448 |
452 DCHECK(!email.empty()) << "Expected user to be signed in."; | 449 DCHECK(!email.empty()) << "Expected user to be signed in."; |
453 | 450 |
454 DVLOG(2) << "UpdateCredentials: " << email; | 451 DVLOG(2) << "UpdateCredentials: " << email; |
455 invalidator_->UpdateCredentials(email, access_token_); | 452 invalidator_->UpdateCredentials(email, access_token_); |
456 } | 453 } |
457 | 454 |
458 void TiclInvalidationService::StopInvalidator() { | 455 void TiclInvalidationService::StopInvalidator() { |
459 DCHECK(invalidator_); | 456 DCHECK(invalidator_); |
460 gcm_invalidation_bridge_.reset(); | 457 gcm_invalidation_bridge_.reset(); |
461 invalidator_->UnregisterHandler(this); | 458 invalidator_->UnregisterHandler(this); |
462 invalidator_.reset(); | 459 invalidator_.reset(); |
463 } | 460 } |
464 | 461 |
465 } // namespace invalidation | 462 } // namespace invalidation |
OLD | NEW |