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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 default: | 135 default: |
136 NOTREACHED(); | 136 NOTREACHED(); |
137 return "UNKNOWN_STATUS"; | 137 return "UNKNOWN_STATUS"; |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 } // namespace | 141 } // namespace |
142 | 142 |
143 GCMStatsRecorderImpl::GCMStatsRecorderImpl() | 143 GCMStatsRecorderImpl::GCMStatsRecorderImpl() |
144 : is_recording_(false), | 144 : is_recording_(false), |
145 delegate_(NULL) { | 145 delegate_(NULL), |
146 clock_(new base::DefaultClock()), | |
147 last_data_message_received_timestamp_(0) { | |
146 } | 148 } |
147 | 149 |
148 GCMStatsRecorderImpl::~GCMStatsRecorderImpl() { | 150 GCMStatsRecorderImpl::~GCMStatsRecorderImpl() { |
149 } | 151 } |
150 | 152 |
151 void GCMStatsRecorderImpl::SetRecording(bool recording) { | 153 void GCMStatsRecorderImpl::SetRecording(bool recording) { |
152 is_recording_ = recording; | 154 is_recording_ = recording; |
153 } | 155 } |
154 | 156 |
155 void GCMStatsRecorderImpl::SetDelegate(Delegate* delegate) { | 157 void GCMStatsRecorderImpl::SetDelegate(Delegate* delegate) { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 } | 357 } |
356 | 358 |
357 void GCMStatsRecorderImpl::RecordDataMessageReceived( | 359 void GCMStatsRecorderImpl::RecordDataMessageReceived( |
358 const std::string& app_id, | 360 const std::string& app_id, |
359 const std::string& from, | 361 const std::string& from, |
360 int message_byte_size, | 362 int message_byte_size, |
361 bool to_registered_app, | 363 bool to_registered_app, |
362 ReceivedMessageType message_type) { | 364 ReceivedMessageType message_type) { |
363 if (to_registered_app) | 365 if (to_registered_app) |
364 UMA_HISTOGRAM_COUNTS("GCM.DataMessageReceived", 1); | 366 UMA_HISTOGRAM_COUNTS("GCM.DataMessageReceived", 1); |
367 | |
368 int64 new_timestamp = clock_->Now().ToTimeT(); | |
jianli
2014/06/19 17:24:06
Why not calling Time::Now()?
juyik
2014/07/15 23:42:12
Done.
| |
369 if (last_data_message_received_timestamp_ > 0) { | |
fgorski
2014/06/18 20:06:19
will this trigger only after all of the messages t
fgorski
2014/06/20 14:23:45
Ju-Yi, given that the wake-up period during sleep
juyik
2014/07/15 23:42:12
This is triggered every time a data message is con
juyik
2014/07/15 23:42:13
Done. Collapsed all received data message within 2
| |
370 UMA_HISTOGRAM_COUNTS("GCM.DataMessageReceivedIntervalSeconds", | |
fgorski
2014/06/18 20:06:19
please update histograms as well.
juyik
2014/07/15 23:42:13
Updated the name.
| |
371 new_timestamp - last_data_message_received_timestamp_); | |
372 } | |
373 last_data_message_received_timestamp_ = new_timestamp; | |
374 | |
365 if (!is_recording_) | 375 if (!is_recording_) |
366 return; | 376 return; |
367 if (!to_registered_app) { | 377 if (!to_registered_app) { |
368 RecordReceiving(app_id, from, message_byte_size, "Data msg received", | 378 RecordReceiving(app_id, from, message_byte_size, "Data msg received", |
369 to_registered_app ? std::string() : | 379 to_registered_app ? std::string() : |
370 "No such registered app found"); | 380 "No such registered app found"); |
371 } else { | 381 } else { |
372 switch(message_type) { | 382 switch(message_type) { |
373 case GCMStatsRecorderImpl::DATA_MESSAGE: | 383 case GCMStatsRecorderImpl::DATA_MESSAGE: |
374 RecordReceiving(app_id, from, message_byte_size, "Data msg received", | 384 RecordReceiving(app_id, from, message_byte_size, "Data msg received", |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 const std::string& receiver_id, | 470 const std::string& receiver_id, |
461 const std::string& message_id) { | 471 const std::string& message_id) { |
462 UMA_HISTOGRAM_COUNTS("GCM.IncomingSendErrors", 1); | 472 UMA_HISTOGRAM_COUNTS("GCM.IncomingSendErrors", 1); |
463 if (!is_recording_) | 473 if (!is_recording_) |
464 return; | 474 return; |
465 RecordSending(app_id, receiver_id, message_id, "Received 'send error' msg", | 475 RecordSending(app_id, receiver_id, message_id, "Received 'send error' msg", |
466 std::string()); | 476 std::string()); |
467 } | 477 } |
468 | 478 |
469 } // namespace gcm | 479 } // namespace gcm |
OLD | NEW |