Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2831)

Unified Diff: chrome/browser/services/gcm/gcm_profile_service.cc

Issue 202083005: Add activity recording capability to gcm internals page. User can refresh, start/stop recording, an… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/services/gcm/gcm_profile_service.h ('k') | chrome/browser/ui/webui/gcm_internals_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cf7e1b54f6c96e38983435c57b4d7b54aa7278d6..f93b427cf9ba7f97dab449c9559413dd8fa714b5 100644
--- a/chrome/browser/services/gcm/gcm_profile_service.cc
+++ b/chrome/browser/services/gcm/gcm_profile_service.cc
@@ -176,7 +176,8 @@ class GCMProfileService::IOWorker
void Send(const std::string& app_id,
const std::string& receiver_id,
const GCMClient::OutgoingMessage& message);
- void RequestGCMStatistics();
+ void GetGCMStatistics(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(); }
@@ -372,19 +373,38 @@ void GCMProfileService::IOWorker::Send(
gcm_client_->Send(app_id, receiver_id, message);
}
-void GCMProfileService::IOWorker::RequestGCMStatistics() {
+void GCMProfileService::IOWorker::GetGCMStatistics(bool clear_logs) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
gcm::GCMClient::GCMStatistics stats;
if (gcm_client_.get()) {
- stats.gcm_client_created = true;
+ if (clear_logs)
+ gcm_client_->ClearActivityLogs();
stats = gcm_client_->GetStatistics();
}
content::BrowserThread::PostTask(
content::BrowserThread::UI,
FROM_HERE,
- base::Bind(&GCMProfileService::RequestGCMStatisticsFinished,
+ base::Bind(&GCMProfileService::GetGCMStatisticsFinished,
+ 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(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&GCMProfileService::GetGCMStatisticsFinished,
service_,
stats));
}
@@ -688,8 +708,8 @@ bool GCMProfileService::IsGCMClientReady() const {
return gcm_client_ready_;
}
-void GCMProfileService::RequestGCMStatistics(
- RequestGCMStatisticsCallback callback) {
+void GCMProfileService::GetGCMStatistics(
+ GetGCMStatisticsCallback callback, bool clear_logs) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
DCHECK(!callback.is_null());
@@ -697,8 +717,22 @@ void GCMProfileService::RequestGCMStatistics(
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,
- base::Bind(&GCMProfileService::IOWorker::RequestGCMStatistics,
- io_worker_));
+ base::Bind(&GCMProfileService::IOWorker::GetGCMStatistics,
+ io_worker_,
+ clear_logs));
+}
+
+void GCMProfileService::SetGCMRecording(
+ GetGCMStatisticsCallback 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,
@@ -904,10 +938,9 @@ GCMAppHandler* GCMProfileService::GetAppHandler(const std::string& app_id) {
return iter == app_handlers_.end() ? &default_app_handler_ : iter->second;
}
-void GCMProfileService::RequestGCMStatisticsFinished(
+void GCMProfileService::GetGCMStatisticsFinished(
GCMClient::GCMStatistics stats) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
-
request_gcm_statistics_callback_.Run(stats);
}
« no previous file with comments | « chrome/browser/services/gcm/gcm_profile_service.h ('k') | chrome/browser/ui/webui/gcm_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698