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

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 zea'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..143558769237fb904886225f7f1718d0905baa8e 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 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(); }
@@ -370,13 +371,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;
fgorski 2014/03/29 05:09:29 with all of the stuff that is happening inside of
juyik 2014/03/31 22:19:23 Done.
+ }
+
+ 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(
@@ -687,7 +708,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());
@@ -696,7 +717,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,
@@ -905,7 +940,6 @@ GCMAppHandler* GCMProfileService::GetAppHandler(const std::string& app_id) {
void GCMProfileService::RequestGCMStatisticsFinished(
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