| 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..1e0fc74fb3b690d52410b0736b46bc5d987770e2 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"
|
|
|
| @@ -273,6 +274,8 @@ class GCMProfileService::IOWorker
|
| void Send(const std::string& app_id,
|
| const std::string& receiver_id,
|
| const GCMClient::OutgoingMessage& message);
|
| + bool IsGCMClientCreated();
|
| + 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 +462,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;
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
| +
|
| + if (gcm_client_.get()) {
|
| + stats = gcm_client_->GetStatistics();
|
| + }
|
| + stats.gcm_client_created = (gcm_client_.get() != NULL);
|
| +
|
| + 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();
|
| +}
|
| +
|
| GCMProfileService::RegistrationInfo::RegistrationInfo() {
|
| }
|
|
|
| @@ -705,6 +741,31 @@ GCMClient* GCMProfileService::GetGCMClientForTesting() const {
|
| return io_worker_ ? io_worker_->gcm_client_for_testing() : NULL;
|
| }
|
|
|
| +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) {
|
| @@ -1070,6 +1131,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;
|
|
|