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 3f81a97eb0005fcda0f85a4e5bfa7af6f7c6d715..482307616210161edd0521a425533d4518d056f6 100644 |
--- a/chrome/browser/services/gcm/gcm_profile_service.cc |
+++ b/chrome/browser/services/gcm/gcm_profile_service.cc |
@@ -36,6 +36,7 @@ |
#include "content/public/browser/notification_source.h" |
#include "extensions/browser/extension_system.h" |
#include "extensions/common/extension.h" |
+#include "google_apis/gcm/gcm_client.h" |
#include "google_apis/gcm/protocol/android_checkin.pb.h" |
#include "net/url_request/url_request_context_getter.h" |
@@ -272,6 +273,8 @@ class GCMProfileService::IOWorker |
void Send(const std::string& app_id, |
const std::string& receiver_id, |
const GCMClient::OutgoingMessage& message); |
+ bool IsGCMClientCreated(); |
+ void RequestGCMStatistics(); |
private: |
friend class base::RefCountedThreadSafe<IOWorker>; |
@@ -454,6 +457,27 @@ 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; |
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
+ |
+ stats.gcm_client_created = (gcm_client_.get() != NULL); |
+ if (gcm_client_.get()) { |
+ gcm_client_->GetStatistics(&stats); |
+ } |
+ |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(&GCMProfileService::RequestGCMStatisticsFinished, |
+ service_, |
+ stats)); |
+} |
+ |
GCMProfileService::RegistrationInfo::RegistrationInfo() { |
} |
@@ -680,6 +704,31 @@ void GCMProfileService::DoSend(const std::string& app_id, |
message)); |
} |
+bool GCMProfileService::IsSignedIn() const { |
+ return !username_.empty(); |
+} |
+ |
+bool GCMProfileService::IsGCMClientCreated() const { |
+ return io_worker_->IsGCMClientCreated(); |
+} |
+ |
+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) { |
@@ -1043,6 +1092,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; |