| 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 376f6abc9e3eb7400d5f6459f419185e1993e3ed..daa1a6e6b66fb634adda70ca787253a243ed5640 100644
|
| --- a/chrome/browser/services/gcm/gcm_profile_service.cc
|
| +++ b/chrome/browser/services/gcm/gcm_profile_service.cc
|
| @@ -14,6 +14,7 @@
|
| #include "base/path_service.h"
|
| #include "base/prefs/pref_service.h"
|
| #include "base/strings/string_number_conversions.h"
|
| +#include "base/strings/string_util.h"
|
| #include "base/threading/sequenced_worker_pool.h"
|
| #include "chrome/browser/chrome_notification_types.h"
|
| #if !defined(OS_ANDROID)
|
| @@ -274,7 +275,8 @@ class GCMProfileService::IOWorker
|
| void Send(const std::string& app_id,
|
| const std::string& receiver_id,
|
| const GCMClient::OutgoingMessage& message);
|
| - void RequestGCMStatistics();
|
| + void RequestGCMStatistics(bool clear_logs);
|
| + void SetGCMRecording(bool recording);
|
|
|
| // For testing purpose. Can be called from UI thread. Use with care.
|
| GCMClient* gcm_client_for_testing() const { return gcm_client_.get(); }
|
| @@ -464,13 +466,33 @@ void GCMProfileService::IOWorker::Send(
|
| gcm_client_->Send(app_id, receiver_id, message);
|
| }
|
|
|
| -void GCMProfileService::IOWorker::RequestGCMStatistics() {
|
| +void GCMProfileService::IOWorker::RequestGCMStatistics(bool clear_logs) {
|
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
| gcm::GCMClient::GCMStatistics stats;
|
|
|
| if (gcm_client_.get()) {
|
| + if (clear_logs)
|
| + gcm_client_->ClearActivityLogs();
|
| + stats = gcm_client_->GetStatistics();
|
| stats.gcm_client_created = true;
|
| + }
|
| +
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::UI,
|
| + FROM_HERE,
|
| + base::Bind(&GCMProfileService::RequestGCMStatisticsFinished,
|
| + service_,
|
| + stats));
|
| +}
|
| +
|
| +void GCMProfileService::IOWorker::SetGCMRecording(bool recording) {
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
| + gcm::GCMClient::GCMStatistics stats;
|
| +
|
| + if (gcm_client_.get()) {
|
| + gcm_client_->SetRecording(recording);
|
| stats = gcm_client_->GetStatistics();
|
| + stats.gcm_client_created = true;
|
| }
|
|
|
| content::BrowserThread::PostTask(
|
| @@ -790,7 +812,7 @@ bool GCMProfileService::IsGCMClientReady() const {
|
| }
|
|
|
| void GCMProfileService::RequestGCMStatistics(
|
| - RequestGCMStatisticsCallback callback) {
|
| + RequestGCMStatisticsCallback callback, bool clear_logs) {
|
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| DCHECK(!callback.is_null());
|
|
|
| @@ -799,7 +821,21 @@ void GCMProfileService::RequestGCMStatistics(
|
| content::BrowserThread::IO,
|
| FROM_HERE,
|
| base::Bind(&GCMProfileService::IOWorker::RequestGCMStatistics,
|
| - io_worker_));
|
| + io_worker_,
|
| + clear_logs));
|
| +}
|
| +
|
| +void GCMProfileService::SetGCMRecording(
|
| + RequestGCMStatisticsCallback callback, bool recording) {
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| +
|
| + request_gcm_statistics_callback_ = callback;
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::IO,
|
| + FROM_HERE,
|
| + base::Bind(&GCMProfileService::IOWorker::SetGCMRecording,
|
| + io_worker_,
|
| + recording));
|
| }
|
|
|
| void GCMProfileService::Observe(int type,
|
| @@ -1192,6 +1228,12 @@ void GCMProfileService::RequestGCMStatisticsFinished(
|
| GCMClient::GCMStatistics stats) {
|
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
|
|
| + std::vector<std::string> ids;
|
| + for (RegistrationInfoMap::const_iterator it = registration_info_map_.begin();
|
| + it != registration_info_map_.end(); ++it) {
|
| + ids.push_back(it->first);
|
| + }
|
| + stats.app_ids_cached = JoinString(ids, ',');;
|
| request_gcm_statistics_callback_.Run(stats);
|
| }
|
|
|
|
|