Chromium Code Reviews| 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 "content/browser/renderer_host/media/media_stream_track_metrics_host.h" | 5 #include "content/browser/renderer_host/media/media_stream_track_metrics_host.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "content/common/media/media_stream_track_metrics_host_messages.h" | 8 #include "content/common/media/media_stream_track_metrics_host_messages.h" |
| 9 | 9 |
| 10 // We use a histogram with a maximum bucket of 16 hours to infinity | 10 // We use a histogram with a maximum bucket of 16 hours to infinity |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 IPC_MESSAGE_HANDLER(MediaStreamTrackMetricsHost_RemoveTrack, OnRemoveTrack) | 42 IPC_MESSAGE_HANDLER(MediaStreamTrackMetricsHost_RemoveTrack, OnRemoveTrack) |
| 43 IPC_MESSAGE_UNHANDLED(handled = false) | 43 IPC_MESSAGE_UNHANDLED(handled = false) |
| 44 IPC_END_MESSAGE_MAP() | 44 IPC_END_MESSAGE_MAP() |
| 45 | 45 |
| 46 return handled; | 46 return handled; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void MediaStreamTrackMetricsHost::OnAddTrack(uint64 id, | 49 void MediaStreamTrackMetricsHost::OnAddTrack(uint64 id, |
| 50 bool is_audio, | 50 bool is_audio, |
| 51 bool is_remote) { | 51 bool is_remote) { |
| 52 DCHECK(tracks_.find(id) == tracks_.end()); | 52 if (tracks_.find(id) != tracks_.end()) |
| 53 return; | |
| 54 | |
| 53 TrackInfo info = {is_audio, is_remote, base::TimeTicks::Now()}; | 55 TrackInfo info = {is_audio, is_remote, base::TimeTicks::Now()}; |
| 54 tracks_[id] = info; | 56 tracks_[id] = info; |
| 55 } | 57 } |
| 56 | 58 |
| 57 void MediaStreamTrackMetricsHost::OnRemoveTrack(uint64 id) { | 59 void MediaStreamTrackMetricsHost::OnRemoveTrack(uint64 id) { |
|
Ronghua Wu (Left Chromium)
2014/07/23 15:53:42
curious, when will OnAddTrack and OnRemoveTrack be
no longer working on chromium
2014/07/24 13:23:31
When a track is added to peer connection.
| |
| 58 DCHECK(tracks_.find(id) != tracks_.end()); | 60 if (tracks_.find(id) == tracks_.end()) |
| 61 return; | |
| 59 | 62 |
| 60 TrackInfo& info = tracks_[id]; | 63 TrackInfo& info = tracks_[id]; |
| 61 ReportDuration(info); | 64 ReportDuration(info); |
| 62 tracks_.erase(id); | 65 tracks_.erase(id); |
| 63 } | 66 } |
| 64 | 67 |
| 65 void MediaStreamTrackMetricsHost::ReportDuration(const TrackInfo& info) { | 68 void MediaStreamTrackMetricsHost::ReportDuration(const TrackInfo& info) { |
| 66 base::TimeDelta duration = base::TimeTicks::Now() - info.timestamp; | 69 base::TimeDelta duration = base::TimeTicks::Now() - info.timestamp; |
| 67 if (info.is_remote) { | 70 if (info.is_remote) { |
| 68 if (info.is_audio) { | 71 if (info.is_audio) { |
| 69 DVLOG(3) << "WebRTC.ReceivedAudioTrackDuration: " << duration.InSeconds(); | 72 DVLOG(3) << "WebRTC.ReceivedAudioTrackDuration: " << duration.InSeconds(); |
| 70 UMA_HISTOGRAM_TIMES_16H("WebRTC.ReceivedAudioTrackDuration", duration); | 73 UMA_HISTOGRAM_TIMES_16H("WebRTC.ReceivedAudioTrackDuration", duration); |
| 71 } else { | 74 } else { |
| 72 DVLOG(3) << "WebRTC.ReceivedVideoTrackDuration: " << duration.InSeconds(); | 75 DVLOG(3) << "WebRTC.ReceivedVideoTrackDuration: " << duration.InSeconds(); |
| 73 UMA_HISTOGRAM_TIMES_16H("WebRTC.ReceivedVideoTrackDuration", duration); | 76 UMA_HISTOGRAM_TIMES_16H("WebRTC.ReceivedVideoTrackDuration", duration); |
| 74 } | 77 } |
| 75 } else { | 78 } else { |
| 76 if (info.is_audio) { | 79 if (info.is_audio) { |
| 77 DVLOG(3) << "WebRTC.SentAudioTrackDuration: " << duration.InSeconds(); | 80 DVLOG(3) << "WebRTC.SentAudioTrackDuration: " << duration.InSeconds(); |
| 78 UMA_HISTOGRAM_TIMES_16H("WebRTC.SentAudioTrackDuration", duration); | 81 UMA_HISTOGRAM_TIMES_16H("WebRTC.SentAudioTrackDuration", duration); |
| 79 } else { | 82 } else { |
| 80 DVLOG(3) << "WebRTC.SentVideoTrackDuration: " << duration.InSeconds(); | 83 DVLOG(3) << "WebRTC.SentVideoTrackDuration: " << duration.InSeconds(); |
| 81 UMA_HISTOGRAM_TIMES_16H("WebRTC.SentVideoTrackDuration", duration); | 84 UMA_HISTOGRAM_TIMES_16H("WebRTC.SentVideoTrackDuration", duration); |
| 82 } | 85 } |
| 83 } | 86 } |
| 84 } | 87 } |
| 85 | 88 |
| 86 } // namespace content | 89 } // namespace content |
| OLD | NEW |