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

Unified Diff: google_apis/gcm/gcm_client_impl.cc

Issue 248213004: Record connection, registration, and receiving activities. (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
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 e152d631cfd7ddf6666266bd44c26d5f28078341..755c86de6b4af1eccf28016e01d21ccc8b75f7b4 100644
--- a/google_apis/gcm/gcm_client_impl.cc
+++ b/google_apis/gcm/gcm_client_impl.cc
@@ -146,12 +146,14 @@ scoped_ptr<ConnectionFactory> GCMInternalsBuilder::BuildConnectionFactory(
const std::vector<GURL>& endpoints,
const net::BackoffEntry::Policy& backoff_policy,
scoped_refptr<net::HttpNetworkSession> network_session,
- net::NetLog* net_log) {
+ net::NetLog* net_log,
+ GCMStatsRecorder* recorder) {
return make_scoped_ptr<ConnectionFactory>(
new ConnectionFactoryImpl(endpoints,
backoff_policy,
network_session,
- net_log));
+ net_log,
+ recorder));
}
GCMClientImpl::GCMClientImpl(scoped_ptr<GCMInternalsBuilder> internals_builder)
@@ -240,7 +242,8 @@ void GCMClientImpl::InitializeMCSClient(
endpoints,
kDefaultBackoffPolicy,
network_session_,
- net_log_.net_log());
+ net_log_.net_log(),
+ &recorder_);
mcs_client_ = internals_builder_->BuildMCSClient(
chrome_build_proto_.chrome_version(),
clock_.get(),
@@ -417,7 +420,8 @@ void GCMClientImpl::Register(const std::string& app_id,
app_id,
sender_ids),
kMaxRegistrationRetries,
- url_request_context_getter_);
+ url_request_context_getter_,
+ &recorder_);
pending_registration_requests_[app_id] = registration_request;
registration_request->Start();
}
@@ -489,7 +493,8 @@ void GCMClientImpl::Unregister(const std::string& app_id) {
base::Bind(&GCMClientImpl::OnUnregisterCompleted,
weak_ptr_factory_.GetWeakPtr(),
app_id),
- url_request_context_getter_);
+ url_request_context_getter_,
+ &recorder_);
pending_unregistration_requests_[app_id] = unregistration_request;
unregistration_request->Start();
}
@@ -583,7 +588,10 @@ GCMClient::GCMStatistics GCMClientImpl::GetStatistics() const {
}
if (device_checkin_info_.android_id > 0)
stats.android_id = device_checkin_info_.android_id;
- recorder_.CollectSendingActivities(&stats.sending_activities);
+ recorder_.CollectActivities(&stats.connection_activities,
+ &stats.registration_activities,
+ &stats.receiving_activities,
+ &stats.sending_activities);
for (RegistrationInfoMap::const_iterator it = registrations_.begin();
it != registrations_.end(); ++it) {
@@ -667,6 +675,11 @@ void GCMClientImpl::HandleIncomingMessage(const gcm::MCSMessage& message) {
HandleIncomingDataMessage(data_message_stanza, message_data);
break;
case DELETED_MESSAGES:
+ recorder_.RecordDataMessageRecieved(data_message_stanza.category(),
+ data_message_stanza.from(),
+ data_message_stanza.ByteSize(),
+ true,
+ true);
delegate_->OnMessagesDeleted(data_message_stanza.category());
break;
case SEND_ERROR:
@@ -692,6 +705,8 @@ void GCMClientImpl::HandleIncomingDataMessage(
std::find(iter->second->sender_ids.begin(),
iter->second->sender_ids.end(),
data_message_stanza.from()) == iter->second->sender_ids.end()) {
+ recorder_.RecordDataMessageRecieved(app_id, data_message_stanza.from(),
jianli 2014/04/23 23:16:39 You can combine this recording with the following
juyik 2014/04/24 00:53:45 Done.
+ data_message_stanza.ByteSize(), false, false);
return;
}
@@ -700,6 +715,8 @@ void GCMClientImpl::HandleIncomingDataMessage(
if (data_message_stanza.has_token())
incoming_message.collapse_key = data_message_stanza.token();
incoming_message.data = message_data;
+ recorder_.RecordDataMessageRecieved(app_id, data_message_stanza.from(),
+ data_message_stanza.ByteSize(), true, false);
delegate_->OnMessageReceived(app_id, incoming_message);
}

Powered by Google App Engine
This is Rietveld 408576698