| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 void GCMStatsRecorderImpl::SetDelegate(Delegate* delegate) { | 156 void GCMStatsRecorderImpl::SetDelegate(Delegate* delegate) { |
| 157 delegate_ = delegate; | 157 delegate_ = delegate; |
| 158 } | 158 } |
| 159 | 159 |
| 160 void GCMStatsRecorderImpl::Clear() { | 160 void GCMStatsRecorderImpl::Clear() { |
| 161 checkin_activities_.clear(); | 161 checkin_activities_.clear(); |
| 162 connection_activities_.clear(); | 162 connection_activities_.clear(); |
| 163 registration_activities_.clear(); | 163 registration_activities_.clear(); |
| 164 receiving_activities_.clear(); | 164 receiving_activities_.clear(); |
| 165 sending_activities_.clear(); | 165 sending_activities_.clear(); |
| 166 decryption_failure_activities_.clear(); |
| 166 } | 167 } |
| 167 | 168 |
| 168 void GCMStatsRecorderImpl::NotifyActivityRecorded() { | 169 void GCMStatsRecorderImpl::NotifyActivityRecorded() { |
| 169 if (delegate_) | 170 if (delegate_) |
| 170 delegate_->OnActivityRecorded(); | 171 delegate_->OnActivityRecorded(); |
| 171 } | 172 } |
| 172 | 173 |
| 174 void GCMStatsRecorderImpl::RecordDecryptionFailure( |
| 175 const std::string& app_id, |
| 176 GCMEncryptionProvider::DecryptionFailure reason) { |
| 177 if (!is_recording_) |
| 178 return; |
| 179 |
| 180 DecryptionFailureActivity data; |
| 181 DecryptionFailureActivity* inserted_data = InsertCircularBuffer( |
| 182 &decryption_failure_activities_, data); |
| 183 inserted_data->app_id = app_id; |
| 184 inserted_data->details = |
| 185 GCMEncryptionProvider::ToDecryptionFailureDetailsString(reason); |
| 186 |
| 187 NotifyActivityRecorded(); |
| 188 } |
| 189 |
| 173 void GCMStatsRecorderImpl::RecordCheckin( | 190 void GCMStatsRecorderImpl::RecordCheckin( |
| 174 const std::string& event, | 191 const std::string& event, |
| 175 const std::string& details) { | 192 const std::string& details) { |
| 176 CheckinActivity data; | 193 CheckinActivity data; |
| 177 CheckinActivity* inserted_data = InsertCircularBuffer( | 194 CheckinActivity* inserted_data = InsertCircularBuffer( |
| 178 &checkin_activities_, data); | 195 &checkin_activities_, data); |
| 179 inserted_data->event = event; | 196 inserted_data->event = event; |
| 180 inserted_data->details = details; | 197 inserted_data->details = details; |
| 181 NotifyActivityRecorded(); | 198 NotifyActivityRecorded(); |
| 182 } | 199 } |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 registration_activities_.begin(), | 470 registration_activities_.begin(), |
| 454 registration_activities_.end()); | 471 registration_activities_.end()); |
| 455 recorded_activities->receiving_activities.insert( | 472 recorded_activities->receiving_activities.insert( |
| 456 recorded_activities->receiving_activities.begin(), | 473 recorded_activities->receiving_activities.begin(), |
| 457 receiving_activities_.begin(), | 474 receiving_activities_.begin(), |
| 458 receiving_activities_.end()); | 475 receiving_activities_.end()); |
| 459 recorded_activities->sending_activities.insert( | 476 recorded_activities->sending_activities.insert( |
| 460 recorded_activities->sending_activities.begin(), | 477 recorded_activities->sending_activities.begin(), |
| 461 sending_activities_.begin(), | 478 sending_activities_.begin(), |
| 462 sending_activities_.end()); | 479 sending_activities_.end()); |
| 480 recorded_activities->decryption_failure_activities.insert( |
| 481 recorded_activities->decryption_failure_activities.begin(), |
| 482 decryption_failure_activities_.begin(), |
| 483 decryption_failure_activities_.end()); |
| 463 } | 484 } |
| 464 | 485 |
| 465 void GCMStatsRecorderImpl::RecordSending(const std::string& app_id, | 486 void GCMStatsRecorderImpl::RecordSending(const std::string& app_id, |
| 466 const std::string& receiver_id, | 487 const std::string& receiver_id, |
| 467 const std::string& message_id, | 488 const std::string& message_id, |
| 468 const std::string& event, | 489 const std::string& event, |
| 469 const std::string& details) { | 490 const std::string& details) { |
| 470 SendingActivity data; | 491 SendingActivity data; |
| 471 SendingActivity* inserted_data = InsertCircularBuffer( | 492 SendingActivity* inserted_data = InsertCircularBuffer( |
| 472 &sending_activities_, data); | 493 &sending_activities_, data); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 const std::string& receiver_id, | 535 const std::string& receiver_id, |
| 515 const std::string& message_id) { | 536 const std::string& message_id) { |
| 516 UMA_HISTOGRAM_COUNTS("GCM.IncomingSendErrors", 1); | 537 UMA_HISTOGRAM_COUNTS("GCM.IncomingSendErrors", 1); |
| 517 if (!is_recording_) | 538 if (!is_recording_) |
| 518 return; | 539 return; |
| 519 RecordSending(app_id, receiver_id, message_id, "Received 'send error' msg", | 540 RecordSending(app_id, receiver_id, message_id, "Received 'send error' msg", |
| 520 std::string()); | 541 std::string()); |
| 521 } | 542 } |
| 522 | 543 |
| 523 } // namespace gcm | 544 } // namespace gcm |
| OLD | NEW |