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 c215192c8df17f593250d6d4f9d6306a0d3b5f73..cc9a7c623c0819bbaf9faa2102e3a34e52cbb066 100644 |
| --- a/chrome/browser/services/gcm/gcm_profile_service.cc |
| +++ b/chrome/browser/services/gcm/gcm_profile_service.cc |
| @@ -273,6 +273,8 @@ class GCMProfileService::IOWorker |
| void Send(const std::string& app_id, |
| const std::string& receiver_id, |
| const GCMClient::OutgoingMessage& message); |
| + bool IsGCMClientCreated(); |
|
jianli
2014/03/06 01:55:21
It seems that none is calling it.
juyik
2014/03/06 02:23:59
Done.
|
| + void RequestGCMStatistics(); |
| // For testing purpose. Can be called from UI thread. Use with care. |
| GCMClient* gcm_client_for_testing() const { return gcm_client_.get(); } |
| @@ -459,6 +461,39 @@ void GCMProfileService::IOWorker::Send( |
| gcm_client_->Send(app_id, receiver_id, message); |
| } |
| +bool GCMProfileService::IOWorker::IsGCMClientCreated() { |
| + return (gcm_client_.get() != NULL); |
| +} |
| + |
| +void GCMProfileService::IOWorker::RequestGCMStatistics() { |
| + gcm::GCMClient::GCMStatistics stats; |
|
jianli
2014/03/06 01:55:21
nit: this should be placed after DCHECK.
juyik
2014/03/06 02:23:59
Done.
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| + |
| + if (gcm_client_.get()) { |
| + stats = gcm_client_->GetStatistics(); |
| + } |
| + stats.gcm_client_created = (gcm_client_.get() != NULL); |
|
jianli
2014/03/06 01:55:21
this can be simply moved inside the if block above
juyik
2014/03/06 02:23:59
Done.
|
| + |
| + content::BrowserThread::PostTask( |
| + content::BrowserThread::UI, |
| + FROM_HERE, |
| + base::Bind(&GCMProfileService::RequestGCMStatisticsFinished, |
| + service_, |
| + stats)); |
| +} |
| + |
| +std::string GCMProfileService::GetGCMEnabledStateString(GCMEnabledState state) { |
| + switch (state) { |
| + case GCMProfileService::ALWAYS_ENABLED: |
| + return "ALWAYS_ENABLED"; |
| + case GCMProfileService::ENABLED_FOR_APPS: |
| + return "ENABLED_FOR_APPS"; |
| + case GCMProfileService::ALWAYS_DISABLED: |
| + return "ALWAYS_DISABLED"; |
| + } |
| + return std::string(); |
|
jianli
2014/03/06 01:55:21
ditto
juyik
2014/03/06 02:23:59
Done.
|
| +} |
| + |
| GCMProfileService::RegistrationInfo::RegistrationInfo() { |
| } |
| @@ -705,6 +740,27 @@ GCMClient* GCMProfileService::GetGCMClientForTesting() const { |
| return io_worker_ ? io_worker_->gcm_client_for_testing() : NULL; |
| } |
| +bool GCMProfileService::IsSignedIn() const { |
| + return !username_.empty(); |
|
jianli
2014/03/06 01:55:21
This indeed means more than signed-in. We set |use
juyik
2014/03/06 02:23:59
In that case, I will just display the username her
|
| +} |
| + |
| +bool GCMProfileService::IsGCMClientReady() const { |
| + return gcm_client_ready_; |
| +} |
| + |
| +void GCMProfileService::RequestGCMStatistics( |
| + RequestGCMStatisticsCallback callback) { |
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| + DCHECK(!callback.is_null()); |
| + |
| + request_gcm_statistics_callback_ = callback; |
| + content::BrowserThread::PostTask( |
| + content::BrowserThread::IO, |
| + FROM_HERE, |
| + base::Bind(&GCMProfileService::IOWorker::RequestGCMStatistics, |
| + io_worker_)); |
| +} |
| + |
| void GCMProfileService::Observe(int type, |
| const content::NotificationSource& source, |
| const content::NotificationDetails& details) { |
| @@ -1070,6 +1126,13 @@ bool GCMProfileService::ParsePersistedRegistrationInfo( |
| return true; |
| } |
| +void GCMProfileService::RequestGCMStatisticsFinished( |
| + GCMClient::GCMStatistics stats) { |
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| + |
| + request_gcm_statistics_callback_.Run(stats); |
| +} |
| + |
| // static |
| const char* GCMProfileService::GetPersistentRegisterKeyForTesting() { |
| return kRegistrationKey; |