Chromium Code Reviews| Index: chrome/browser/services/gcm/gcm_profile_service.cc |
| diff --git a/chrome/browser/services/gcm/gcm_profile_service.cc b/chrome/browser/services/gcm/gcm_profile_service.cc |
| index 3afea2173d8d888f726db7c801a655b191af6703..643fad831b503889a1baf6da526f55e2479558ce 100644 |
| --- a/chrome/browser/services/gcm/gcm_profile_service.cc |
| +++ b/chrome/browser/services/gcm/gcm_profile_service.cc |
| @@ -12,6 +12,7 @@ |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/extensions/extension_system.h" |
| #include "chrome/browser/extensions/state_store.h" |
| +#include "chrome/browser/services/gcm/gcm_client_factory.h" |
| #include "chrome/browser/services/gcm/gcm_event_router.h" |
| #include "chrome/browser/signin/signin_manager.h" |
| #include "chrome/browser/signin/signin_manager_factory.h" |
| @@ -200,7 +201,6 @@ class GCMProfileService::IOWorker |
| GCMClient::Result result) OVERRIDE; |
| virtual GCMClient::CheckinInfo GetCheckinInfo() const OVERRIDE; |
| virtual void OnLoadingCompleted() OVERRIDE; |
| - virtual base::TaskRunner* GetFileTaskRunner() OVERRIDE; |
| void CheckGCMClientLoading(); |
| void SetUser(const std::string& username); |
| @@ -223,6 +223,9 @@ class GCMProfileService::IOWorker |
| const base::WeakPtr<GCMProfileService> service_; |
| + // Not owned. |
| + GCMClient* gcm_client_; |
| + |
| // The username (email address) of the signed-in user. |
| std::string username_; |
| @@ -234,6 +237,7 @@ class GCMProfileService::IOWorker |
| GCMProfileService::IOWorker::IOWorker( |
| const base::WeakPtr<GCMProfileService>& service) |
| : service_(service) { |
| + gcm_client_ = GCMClientFactory::GetClient(); |
|
fgorski
2014/01/16 23:18:31
will it work on the initialization list?
: service
jianli
2014/01/17 00:43:54
Yes, your suggestion works. However, I need to mov
|
| } |
| GCMProfileService::IOWorker::~IOWorker() { |
| @@ -340,18 +344,13 @@ void GCMProfileService::IOWorker::OnLoadingCompleted() { |
| service_)); |
| } |
| -base::TaskRunner* GCMProfileService::IOWorker::GetFileTaskRunner() { |
| - // TODO(jianli): to be implemented. |
| - return NULL; |
| -} |
| - |
| void GCMProfileService::IOWorker::CheckGCMClientLoading() { |
| content::BrowserThread::PostTask( |
| content::BrowserThread::UI, |
| FROM_HERE, |
| base::Bind(&GCMProfileService::CheckGCMClientLoadingFinished, |
| service_, |
| - GCMClient::Get()->IsLoading())); |
| + gcm_client_->IsLoading())); |
| } |
| void GCMProfileService::IOWorker::SetUser(const std::string& username) { |
| @@ -359,7 +358,7 @@ void GCMProfileService::IOWorker::SetUser(const std::string& username) { |
| DCHECK(username_.empty() && !username.empty()); |
| username_ = username; |
| - GCMClient::Get()->SetUserDelegate(username_, this); |
| + gcm_client_->SetUserDelegate(username_, this); |
| } |
| void GCMProfileService::IOWorker::RemoveUser(const std::string& username) { |
| @@ -369,13 +368,13 @@ void GCMProfileService::IOWorker::RemoveUser(const std::string& username) { |
| if (username_.empty()) |
| return; |
| username_.clear(); |
| - GCMClient::Get()->SetUserDelegate(username_, NULL); |
| + gcm_client_->SetUserDelegate(username_, NULL); |
| } |
| void GCMProfileService::IOWorker::CheckIn() { |
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| - GCMClient::Get()->CheckIn(username_); |
| + gcm_client_->CheckIn(username_); |
| } |
| void GCMProfileService::IOWorker::SetCheckinInfo( |
| @@ -399,14 +398,14 @@ void GCMProfileService::IOWorker::Register( |
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| DCHECK(!username_.empty() && checkin_info_.IsValid()); |
| - GCMClient::Get()->Register(username_, app_id, cert, sender_ids); |
| + gcm_client_->Register(username_, app_id, cert, sender_ids); |
| } |
| void GCMProfileService::IOWorker::Unregister(const std::string& app_id) { |
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| DCHECK(!username_.empty() && checkin_info_.IsValid()); |
| - GCMClient::Get()->Unregister(username_, app_id); |
| + gcm_client_->Unregister(username_, app_id); |
| } |
| void GCMProfileService::IOWorker::Send( |
| @@ -416,7 +415,7 @@ void GCMProfileService::IOWorker::Send( |
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| DCHECK(!username_.empty() && checkin_info_.IsValid()); |
| - GCMClient::Get()->Send(username_, app_id, receiver_id, message); |
| + gcm_client_->Send(username_, app_id, receiver_id, message); |
| } |
| GCMProfileService::RegistrationInfo::RegistrationInfo() { |
| @@ -465,6 +464,7 @@ GCMProfileService::GCMProfileService(Profile* profile) |
| testing_delegate_(NULL), |
| weak_ptr_factory_(this) { |
| DCHECK(!profile->IsOffTheRecord()); |
| + |
| Init(); |
| } |