Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license | |
| 5 * that can be found in the LICENSE file in the root of the source | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #ifndef WEBRTC_STATS_RTCSTATSCOLLECTOR_H_ | |
| 12 #define WEBRTC_STATS_RTCSTATSCOLLECTOR_H_ | |
| 13 | |
| 14 #include <memory> | |
| 15 | |
| 16 #include "webrtc/api/peerconnection.h" | |
|
magjed_webrtc
2016/08/25 09:07:52
If this is only used for PeerConnection*, forward
hbos
2016/08/29 13:10:58
Done.
| |
| 17 #include "webrtc/api/rtcstats_objects.h" | |
| 18 #include "webrtc/api/rtcstatsreport.h" | |
| 19 #include "webrtc/base/refcount.h" | |
|
magjed_webrtc
2016/08/25 09:07:52
refcount is not needed?
hbos
2016/08/29 13:10:59
Done.
| |
| 20 #include "webrtc/base/scoped_ref_ptr.h" | |
| 21 #include "webrtc/base/timing.h" | |
| 22 | |
| 23 namespace webrtc { | |
| 24 | |
| 25 // All calls to the collector and gathering of stats is performed on the | |
| 26 // signaling thread. A stats report is cached for |cache_lifetime_| ms. | |
| 27 class RTCStatsCollector { | |
| 28 public: | |
| 29 RTCStatsCollector( | |
|
magjed_webrtc
2016/08/25 09:07:52
You have only one mandatory argument, so I think y
hbos
2016/08/29 13:10:58
Done.
| |
| 30 PeerConnection* pc, | |
| 31 double cache_lifetime = 0.05, | |
| 32 std::unique_ptr<rtc::Timing> timing = std::unique_ptr<rtc::Timing>( | |
| 33 new rtc::Timing())); | |
| 34 | |
| 35 // Gets a recent stats report. If there is a report cached that is still fresh | |
| 36 // it is returned, otherwise new stats are gathered and returned. A report is | |
| 37 // considered fresh for |cache_lifetime_| ms. const RTCStatsReports are safe | |
| 38 // to use across multiple threads and may be destructed on any thread. | |
| 39 rtc::scoped_refptr<const RTCStatsReport> GetStatsReport(); | |
| 40 // Clears the cache's reference to the most recent stats report. Subsequently | |
| 41 // calling |GetStatsReport| guarantees fresh stats. | |
| 42 void ClearCachedStatsReport(); | |
| 43 | |
| 44 private: | |
| 45 bool IsSignalingThread() const; | |
|
hta-webrtc
2016/08/26 09:28:57
Naming nit: This isn't a thread, so "IsSignalingTh
hbos
2016/08/29 13:10:58
Done.
| |
| 46 | |
| 47 std::unique_ptr<RTCPeerConnectionStats> ProducePeerConnectionStats() const; | |
| 48 | |
| 49 PeerConnection* const pc_; | |
| 50 mutable std::unique_ptr<rtc::Timing> timing_; | |
| 51 // Time relative to the UNIX epoch (Jan 1, 1970, UTC), in seconds. | |
| 52 double cache_timestamp_; | |
| 53 double cache_lifetime_; // In seconds. | |
| 54 rtc::scoped_refptr<const RTCStatsReport> cached_report_; | |
| 55 }; | |
| 56 | |
| 57 } // namespace webrtc | |
| 58 | |
| 59 #endif // WEBRTC_STATS_RTCSTATSCOLLECTOR_H_ | |
| OLD | NEW |