| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/gcm_driver/gcm_stats_recorder_impl.h" | 5 #include "components/gcm_driver/gcm_stats_recorder_impl.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 GCMStatsRecorderImpl::GCMStatsRecorderImpl() | 146 GCMStatsRecorderImpl::GCMStatsRecorderImpl() |
| 147 : is_recording_(false), | 147 : is_recording_(false), |
| 148 delegate_(NULL), | 148 delegate_(NULL), |
| 149 data_message_received_since_connected_(false), | 149 data_message_received_since_connected_(false), |
| 150 received_data_message_burst_size_(0) { | 150 received_data_message_burst_size_(0) { |
| 151 } | 151 } |
| 152 | 152 |
| 153 GCMStatsRecorderImpl::~GCMStatsRecorderImpl() { | 153 GCMStatsRecorderImpl::~GCMStatsRecorderImpl() { |
| 154 } | 154 } |
| 155 | 155 |
| 156 void GCMStatsRecorderImpl::SetRecording(bool recording) { | |
| 157 is_recording_ = recording; | |
| 158 } | |
| 159 | |
| 160 void GCMStatsRecorderImpl::SetDelegate(Delegate* delegate) { | 156 void GCMStatsRecorderImpl::SetDelegate(Delegate* delegate) { |
| 161 delegate_ = delegate; | 157 delegate_ = delegate; |
| 162 } | 158 } |
| 163 | 159 |
| 164 void GCMStatsRecorderImpl::Clear() { | 160 void GCMStatsRecorderImpl::Clear() { |
| 165 checkin_activities_.clear(); | 161 checkin_activities_.clear(); |
| 166 connection_activities_.clear(); | 162 connection_activities_.clear(); |
| 167 registration_activities_.clear(); | 163 registration_activities_.clear(); |
| 168 receiving_activities_.clear(); | 164 receiving_activities_.clear(); |
| 169 sending_activities_.clear(); | 165 sending_activities_.clear(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 inserted_data->app_id = app_id; | 279 inserted_data->app_id = app_id; |
| 284 inserted_data->source = source; | 280 inserted_data->source = source; |
| 285 inserted_data->event = event; | 281 inserted_data->event = event; |
| 286 inserted_data->details = details; | 282 inserted_data->details = details; |
| 287 NotifyActivityRecorded(); | 283 NotifyActivityRecorded(); |
| 288 } | 284 } |
| 289 | 285 |
| 290 void GCMStatsRecorderImpl::RecordRegistrationSent( | 286 void GCMStatsRecorderImpl::RecordRegistrationSent( |
| 291 const std::string& app_id, | 287 const std::string& app_id, |
| 292 const std::string& sender_ids) { | 288 const std::string& sender_ids) { |
| 293 UMA_HISTOGRAM_COUNTS("GCM.RegistrationRequest", 1); | 289 UMA_HISTOGRAM_BOOLEAN("GCM.RegistrationRequest", true); |
| 294 if (!is_recording_) | 290 if (!is_recording_) |
| 295 return; | 291 return; |
| 296 RecordRegistration(app_id, sender_ids, | 292 RecordRegistration(app_id, sender_ids, |
| 297 "Registration request sent", std::string()); | 293 "Registration request sent", std::string()); |
| 298 } | 294 } |
| 299 | 295 |
| 300 void GCMStatsRecorderImpl::RecordRegistrationResponse( | 296 void GCMStatsRecorderImpl::RecordRegistrationResponse( |
| 301 const std::string& app_id, | 297 const std::string& app_id, |
| 302 const std::string& source, | 298 const std::string& source, |
| 303 RegistrationRequest::Status status) { | 299 RegistrationRequest::Status status) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 319 app_id, | 315 app_id, |
| 320 source, | 316 source, |
| 321 "Registration retry delayed", | 317 "Registration retry delayed", |
| 322 base::StringPrintf("Delayed for %" PRId64 " msec, retries left: %d", | 318 base::StringPrintf("Delayed for %" PRId64 " msec, retries left: %d", |
| 323 delay_msec, | 319 delay_msec, |
| 324 retries_left)); | 320 retries_left)); |
| 325 } | 321 } |
| 326 | 322 |
| 327 void GCMStatsRecorderImpl::RecordUnregistrationSent( | 323 void GCMStatsRecorderImpl::RecordUnregistrationSent( |
| 328 const std::string& app_id, const std::string& source) { | 324 const std::string& app_id, const std::string& source) { |
| 329 UMA_HISTOGRAM_COUNTS("GCM.UnregistrationRequest", 1); | 325 UMA_HISTOGRAM_BOOLEAN("GCM.UnregistrationRequest", true); |
| 330 if (!is_recording_) | 326 if (!is_recording_) |
| 331 return; | 327 return; |
| 332 RecordRegistration(app_id, source, "Unregistration request sent", | 328 RecordRegistration(app_id, source, "Unregistration request sent", |
| 333 std::string()); | 329 std::string()); |
| 334 } | 330 } |
| 335 | 331 |
| 336 void GCMStatsRecorderImpl::RecordUnregistrationResponse( | 332 void GCMStatsRecorderImpl::RecordUnregistrationResponse( |
| 337 const std::string& app_id, | 333 const std::string& app_id, |
| 338 const std::string& source, | 334 const std::string& source, |
| 339 UnregistrationRequest::Status status) { | 335 UnregistrationRequest::Status status) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 NotifyActivityRecorded(); | 374 NotifyActivityRecorded(); |
| 379 } | 375 } |
| 380 | 376 |
| 381 void GCMStatsRecorderImpl::RecordDataMessageReceived( | 377 void GCMStatsRecorderImpl::RecordDataMessageReceived( |
| 382 const std::string& app_id, | 378 const std::string& app_id, |
| 383 const std::string& from, | 379 const std::string& from, |
| 384 int message_byte_size, | 380 int message_byte_size, |
| 385 bool to_registered_app, | 381 bool to_registered_app, |
| 386 ReceivedMessageType message_type) { | 382 ReceivedMessageType message_type) { |
| 387 if (to_registered_app) | 383 if (to_registered_app) |
| 388 UMA_HISTOGRAM_COUNTS("GCM.DataMessageReceived", 1); | 384 UMA_HISTOGRAM_BOOLEAN("GCM.DataMessageReceived", true); |
| 389 | 385 |
| 390 base::TimeTicks new_timestamp = base::TimeTicks::Now(); | 386 base::TimeTicks new_timestamp = base::TimeTicks::Now(); |
| 391 if (last_received_data_message_burst_start_time_.is_null()) { | 387 if (last_received_data_message_burst_start_time_.is_null()) { |
| 392 last_received_data_message_burst_start_time_ = new_timestamp; | 388 last_received_data_message_burst_start_time_ = new_timestamp; |
| 393 last_received_data_message_time_within_burst_ = new_timestamp; | 389 last_received_data_message_time_within_burst_ = new_timestamp; |
| 394 received_data_message_burst_size_ = 1; | 390 received_data_message_burst_size_ = 1; |
| 395 } else if ((new_timestamp - last_received_data_message_burst_start_time_) >= | 391 } else if ((new_timestamp - last_received_data_message_burst_start_time_) >= |
| 396 base::TimeDelta::FromSeconds( | 392 base::TimeDelta::FromSeconds( |
| 397 RECEIVED_DATA_MESSAGE_BURST_LENGTH_SECONDS)) { | 393 RECEIVED_DATA_MESSAGE_BURST_LENGTH_SECONDS)) { |
| 398 UMA_HISTOGRAM_LONG_TIMES( | 394 UMA_HISTOGRAM_LONG_TIMES( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 RecordReceiving(app_id, from, message_byte_size, "Data msg received", | 431 RecordReceiving(app_id, from, message_byte_size, "Data msg received", |
| 436 "Message has been deleted on server"); | 432 "Message has been deleted on server"); |
| 437 break; | 433 break; |
| 438 default: | 434 default: |
| 439 NOTREACHED(); | 435 NOTREACHED(); |
| 440 } | 436 } |
| 441 } | 437 } |
| 442 } | 438 } |
| 443 | 439 |
| 444 void GCMStatsRecorderImpl::CollectActivities( | 440 void GCMStatsRecorderImpl::CollectActivities( |
| 445 RecordedActivities* recorder_activities) const { | 441 RecordedActivities* recorded_activities) const { |
| 446 recorder_activities->checkin_activities.insert( | 442 recorded_activities->checkin_activities.insert( |
| 447 recorder_activities->checkin_activities.begin(), | 443 recorded_activities->checkin_activities.begin(), |
| 448 checkin_activities_.begin(), | 444 checkin_activities_.begin(), |
| 449 checkin_activities_.end()); | 445 checkin_activities_.end()); |
| 450 recorder_activities->connection_activities.insert( | 446 recorded_activities->connection_activities.insert( |
| 451 recorder_activities->connection_activities.begin(), | 447 recorded_activities->connection_activities.begin(), |
| 452 connection_activities_.begin(), | 448 connection_activities_.begin(), |
| 453 connection_activities_.end()); | 449 connection_activities_.end()); |
| 454 recorder_activities->registration_activities.insert( | 450 recorded_activities->registration_activities.insert( |
| 455 recorder_activities->registration_activities.begin(), | 451 recorded_activities->registration_activities.begin(), |
| 456 registration_activities_.begin(), | 452 registration_activities_.begin(), |
| 457 registration_activities_.end()); | 453 registration_activities_.end()); |
| 458 recorder_activities->receiving_activities.insert( | 454 recorded_activities->receiving_activities.insert( |
| 459 recorder_activities->receiving_activities.begin(), | 455 recorded_activities->receiving_activities.begin(), |
| 460 receiving_activities_.begin(), | 456 receiving_activities_.begin(), |
| 461 receiving_activities_.end()); | 457 receiving_activities_.end()); |
| 462 recorder_activities->sending_activities.insert( | 458 recorded_activities->sending_activities.insert( |
| 463 recorder_activities->sending_activities.begin(), | 459 recorded_activities->sending_activities.begin(), |
| 464 sending_activities_.begin(), | 460 sending_activities_.begin(), |
| 465 sending_activities_.end()); | 461 sending_activities_.end()); |
| 466 } | 462 } |
| 467 | 463 |
| 468 void GCMStatsRecorderImpl::RecordSending(const std::string& app_id, | 464 void GCMStatsRecorderImpl::RecordSending(const std::string& app_id, |
| 469 const std::string& receiver_id, | 465 const std::string& receiver_id, |
| 470 const std::string& message_id, | 466 const std::string& message_id, |
| 471 const std::string& event, | 467 const std::string& event, |
| 472 const std::string& details) { | 468 const std::string& details) { |
| 473 SendingActivity data; | 469 SendingActivity data; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 const std::string& receiver_id, | 513 const std::string& receiver_id, |
| 518 const std::string& message_id) { | 514 const std::string& message_id) { |
| 519 UMA_HISTOGRAM_COUNTS("GCM.IncomingSendErrors", 1); | 515 UMA_HISTOGRAM_COUNTS("GCM.IncomingSendErrors", 1); |
| 520 if (!is_recording_) | 516 if (!is_recording_) |
| 521 return; | 517 return; |
| 522 RecordSending(app_id, receiver_id, message_id, "Received 'send error' msg", | 518 RecordSending(app_id, receiver_id, message_id, "Received 'send error' msg", |
| 523 std::string()); | 519 std::string()); |
| 524 } | 520 } |
| 525 | 521 |
| 526 } // namespace gcm | 522 } // namespace gcm |
| OLD | NEW |