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

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: Addressing filip's comments. Created 6 years, 9 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
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 fd69c0cc86c1dc875562d735bed647580de87116..2e6f068ce776c7248bf43b4d4ba4b9ca89cf0e6b 100644
--- a/chrome/browser/services/gcm/gcm_profile_service.cc
+++ b/chrome/browser/services/gcm/gcm_profile_service.cc
@@ -174,7 +174,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(); }
@@ -370,19 +371,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));
}
@@ -686,8 +706,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());
@@ -695,8 +715,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,
@@ -902,10 +936,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);
}

Powered by Google App Engine
This is Rietveld 408576698