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

Unified Diff: google_apis/gcm/gcm_client_impl.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: google_apis/gcm/gcm_client_impl.cc
diff --git a/google_apis/gcm/gcm_client_impl.cc b/google_apis/gcm/gcm_client_impl.cc
index 4cc0fdd38b0acf28280c6df8b7cef754703a3db2..4a779640899dabdbecadc1acf89e5ff14a5a1545 100644
--- a/google_apis/gcm/gcm_client_impl.cc
+++ b/google_apis/gcm/gcm_client_impl.cc
@@ -11,6 +11,7 @@
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/sequenced_task_runner.h"
+#include "base/strings/stringprintf.h"
#include "base/time/default_clock.h"
#include "google_apis/gcm/base/mcs_message.h"
#include "google_apis/gcm/base/mcs_util.h"
@@ -18,6 +19,7 @@
#include "google_apis/gcm/engine/connection_factory_impl.h"
#include "google_apis/gcm/engine/gcm_store_impl.h"
#include "google_apis/gcm/engine/mcs_client.h"
+#include "google_apis/gcm/gcm_stats_recorder.h"
#include "google_apis/gcm/protocol/mcs.pb.h"
#include "net/http/http_network_session.h"
#include "net/url_request/url_request_context.h"
@@ -128,12 +130,14 @@ scoped_ptr<MCSClient> GCMInternalsBuilder::BuildMCSClient(
const std::string& version,
base::Clock* clock,
ConnectionFactory* connection_factory,
- GCMStore* gcm_store) {
+ GCMStore* gcm_store,
+ GCMStatsRecorder* recorder) {
return make_scoped_ptr<MCSClient>(
new MCSClient(version,
clock,
connection_factory,
- gcm_store));
+ gcm_store,
+ recorder));
}
scoped_ptr<ConnectionFactory> GCMInternalsBuilder::BuildConnectionFactory(
@@ -237,7 +241,8 @@ void GCMClientImpl::InitializeMCSClient(
chrome_build_proto_.chrome_version(),
clock_.get(),
connection_factory_.get(),
- gcm_store_.get()).Pass();
+ gcm_store_.get(),
+ &recorder_).Pass();
mcs_client_->Initialize(
base::Bind(&GCMClientImpl::OnMCSError, weak_ptr_factory_.GetWeakPtr()),
@@ -522,16 +527,33 @@ std::string GCMClientImpl::GetStateString() const {
}
}
+void GCMClientImpl::SetRecording(bool recording) {
+ recorder_.SetRecording(recording);
+}
+
+void GCMClientImpl::ClearActivityLogs() {
+ recorder_.Clear();
+}
+
GCMClient::GCMStatistics GCMClientImpl::GetStatistics() const {
GCMClient::GCMStatistics stats;
- stats.gcm_client_state = GCMClientImpl::GetStateString();
+ stats.gcm_client_created = true;
+ stats.is_recording = recorder_.is_recording();
+ stats.gcm_client_state = GetStateString();
stats.connection_client_created = mcs_client_.get() != NULL;
if (mcs_client_.get()) {
stats.connection_state = mcs_client_->GetStateString();
- // TODO(juyik): add more statistics such as message metadata list, etc.
+ stats.send_queue_size = mcs_client_->GetSendQueueSize();
+ stats.resend_queue_size = mcs_client_->GetResendQueueSize();
}
if (device_checkin_info_.android_id > 0)
stats.android_id = device_checkin_info_.android_id;
+ recorder_.CollectSendingActivities(&stats.sending);
+
+ for (RegistrationInfoMap::const_iterator it = registrations_.begin();
+ it != registrations_.end(); ++it) {
+ stats.registered_app_ids.push_back(it->first);
+ }
return stats;
}
@@ -660,6 +682,10 @@ void GCMClientImpl::HandleIncomingSendError(
send_error_details.additional_data.erase(iter);
}
+ recorder_.RecordIncomingSendError(
+ data_message_stanza.category(),
+ data_message_stanza.to(),
+ data_message_stanza.id());
delegate_->OnMessageSendError(data_message_stanza.category(),
send_error_details);
}

Powered by Google App Engine
This is Rietveld 408576698