| Index: chrome/browser/invalidation/gcm_invalidation_bridge.cc
|
| diff --git a/chrome/browser/invalidation/gcm_invalidation_bridge.cc b/chrome/browser/invalidation/gcm_invalidation_bridge.cc
|
| index 36747124110c4139c14b9a150594e0c319e05c13..d7c89efd50e809c96a16f7fac8e31d21df704ce9 100644
|
| --- a/chrome/browser/invalidation/gcm_invalidation_bridge.cc
|
| +++ b/chrome/browser/invalidation/gcm_invalidation_bridge.cc
|
| @@ -7,8 +7,8 @@
|
| #include "base/single_thread_task_runner.h"
|
| #include "base/thread_task_runner_handle.h"
|
| #include "chrome/browser/invalidation/gcm_invalidation_bridge.h"
|
| +#include "chrome/browser/invalidation/invalidation_auth_provider.h"
|
| #include "chrome/browser/services/gcm/gcm_profile_service.h"
|
| -#include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
|
| #include "chrome/browser/signin/profile_oauth2_token_service.h"
|
| #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
|
| #include "chrome/browser/signin/signin_manager.h"
|
| @@ -123,9 +123,12 @@ void GCMInvalidationBridge::Core::RegisterFinished(
|
| callback.Run(registration_id, result);
|
| }
|
|
|
| -GCMInvalidationBridge::GCMInvalidationBridge(Profile* profile)
|
| +GCMInvalidationBridge::GCMInvalidationBridge(
|
| + gcm::GCMProfileService* gcm_profile_service,
|
| + InvalidationAuthProvider* auth_provider)
|
| : OAuth2TokenService::Consumer("gcm_network_channel"),
|
| - profile_(profile),
|
| + gcm_profile_service_(gcm_profile_service),
|
| + auth_provider_(auth_provider),
|
| weak_factory_(this) {}
|
|
|
| GCMInvalidationBridge::~GCMInvalidationBridge() {}
|
| @@ -161,15 +164,11 @@ void GCMInvalidationBridge::RequestToken(
|
| error,
|
| access_token));
|
| }
|
| - ProfileOAuth2TokenService* token_service =
|
| - ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
|
| request_token_callback_ = callback;
|
| - SigninManagerBase* signin_manager =
|
| - SigninManagerFactory::GetForProfile(profile_);
|
| - std::string account_id = signin_manager->GetAuthenticatedAccountId();
|
| OAuth2TokenService::ScopeSet scopes;
|
| scopes.insert(GaiaConstants::kGoogleTalkOAuth2Scope);
|
| - access_token_request_ = token_service->StartRequest(account_id, scopes, this);
|
| + access_token_request_ = auth_provider_->GetTokenService()->StartRequest(
|
| + auth_provider_->GetAccountId(), scopes, this);
|
| }
|
|
|
| void GCMInvalidationBridge::OnGetTokenSuccess(
|
| @@ -206,29 +205,23 @@ void GCMInvalidationBridge::OnGetTokenFailure(
|
| }
|
|
|
| void GCMInvalidationBridge::InvalidateToken(const std::string& token) {
|
| - ProfileOAuth2TokenService* token_service =
|
| - ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
|
| DCHECK(CalledOnValidThread());
|
| - SigninManagerBase* signin_manager =
|
| - SigninManagerFactory::GetForProfile(profile_);
|
| - std::string account_id = signin_manager->GetAuthenticatedAccountId();
|
| OAuth2TokenService::ScopeSet scopes;
|
| scopes.insert(GaiaConstants::kGoogleTalkOAuth2Scope);
|
| - token_service->InvalidateToken(account_id, scopes, token);
|
| + auth_provider_->GetTokenService()->InvalidateToken(
|
| + auth_provider_->GetAccountId(), scopes, token);
|
| }
|
|
|
| void GCMInvalidationBridge::Register(
|
| syncer::GCMNetworkChannelDelegate::RegisterCallback callback) {
|
| DCHECK(CalledOnValidThread());
|
| // No-op if GCMClient is disabled.
|
| - gcm::GCMProfileService* gcm_profile_service =
|
| - gcm::GCMProfileServiceFactory::GetForProfile(profile_);
|
| - if (gcm_profile_service == NULL)
|
| + if (gcm_profile_service_ == NULL)
|
| return;
|
|
|
| std::vector<std::string> sender_ids;
|
| sender_ids.push_back(kInvalidationsSenderId);
|
| - gcm_profile_service->Register(
|
| + gcm_profile_service_->Register(
|
| kInvalidationsAppId,
|
| sender_ids,
|
| base::Bind(&GCMInvalidationBridge::RegisterFinished,
|
|
|