Chromium Code Reviews| Index: chrome/browser/services/gcm/gcm_service.cc |
| diff --git a/chrome/browser/services/gcm/gcm_service.cc b/chrome/browser/services/gcm/gcm_service.cc |
| index 0b5c74dc601e0143b80e6e65927317069ebc740f..6f892b3adbd3e9031ef69f25b6f2229dbf833eb2 100644 |
| --- a/chrome/browser/services/gcm/gcm_service.cc |
| +++ b/chrome/browser/services/gcm/gcm_service.cc |
| @@ -146,6 +146,7 @@ class GCMService::IOWorker : public GCMClient::Delegate { |
| const std::string& app_id, |
| const GCMClient::SendErrorDetails& send_error_details) OVERRIDE; |
| virtual void OnGCMReady() OVERRIDE; |
| + virtual void OnActivityRecorded() OVERRIDE; |
| // Called on IO thread. |
| void Initialize(scoped_ptr<GCMClientFactory> gcm_client_factory, |
| @@ -169,6 +170,9 @@ class GCMService::IOWorker : public GCMClient::Delegate { |
| GCMClient* gcm_client_for_testing() const { return gcm_client_.get(); } |
| private: |
| + // Do the actual work of fetching GCM stats from GCM client and post back. |
| + void DoGetGCMStatistics(); |
| + |
| base::WeakPtr<GCMService> service_; |
| scoped_ptr<GCMClient> gcm_client_; |
| @@ -296,6 +300,13 @@ void GCMService::IOWorker::OnGCMReady() { |
| service_)); |
| } |
| +void GCMService::IOWorker::OnActivityRecorded() { |
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| + // When an activity is recorded, get all the stats and refresh the UI of |
| + // gcm-internals page. |
| + DoGetGCMStatistics(); |
|
jianli
2014/05/06 22:54:53
Why not just calleding GetGCMStatistics with false
juyik
2014/05/07 00:07:48
Done.
|
| +} |
| + |
| void GCMService::IOWorker::Load(const base::WeakPtr<GCMService>& service) { |
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| @@ -342,11 +353,18 @@ void GCMService::IOWorker::Send(const std::string& app_id, |
| void GCMService::IOWorker::GetGCMStatistics(bool clear_logs) { |
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| - gcm::GCMClient::GCMStatistics stats; |
| if (gcm_client_.get()) { |
|
jianli
2014/05/06 22:54:53
It seems that there is behavior change when gcm_cl
juyik
2014/05/07 00:07:48
Done.
|
| if (clear_logs) |
| gcm_client_->ClearActivityLogs(); |
| + DoGetGCMStatistics(); |
| + } |
| +} |
| + |
| +void GCMService::IOWorker::DoGetGCMStatistics() { |
| + gcm::GCMClient::GCMStatistics stats; |
| + |
| + if (gcm_client_.get()) { |
|
jianli
2014/05/06 22:54:53
nit: brackets not needed
juyik
2014/05/07 00:07:48
Done.
|
| stats = gcm_client_->GetStatistics(); |
| } |