| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 typedef std::map<std::string, std::unique_ptr<const RTCStats>> StatsMap; | 29 typedef std::map<std::string, std::unique_ptr<const RTCStats>> StatsMap; |
| 30 | 30 |
| 31 class ConstIterator { | 31 class ConstIterator { |
| 32 public: | 32 public: |
| 33 ConstIterator(const ConstIterator&& other); | 33 ConstIterator(const ConstIterator&& other); |
| 34 ~ConstIterator(); | 34 ~ConstIterator(); |
| 35 | 35 |
| 36 ConstIterator& operator++(); | 36 ConstIterator& operator++(); |
| 37 ConstIterator& operator++(int); | 37 ConstIterator& operator++(int); |
| 38 const RTCStats& operator*() const; | 38 const RTCStats& operator*() const; |
| 39 const RTCStats* operator->() const; | |
| 40 bool operator==(const ConstIterator& other) const; | 39 bool operator==(const ConstIterator& other) const; |
| 41 bool operator!=(const ConstIterator& other) const; | 40 bool operator!=(const ConstIterator& other) const; |
| 42 | 41 |
| 43 private: | 42 private: |
| 44 friend class RTCStatsReport; | 43 friend class RTCStatsReport; |
| 45 ConstIterator(const rtc::scoped_refptr<const RTCStatsReport>& report, | 44 ConstIterator(const rtc::scoped_refptr<const RTCStatsReport>& report, |
| 46 StatsMap::const_iterator it); | 45 StatsMap::const_iterator it); |
| 47 | 46 |
| 48 // Reference report to make sure it is kept alive. | 47 // Reference report to make sure it is kept alive. |
| 49 rtc::scoped_refptr<const RTCStatsReport> report_; | 48 rtc::scoped_refptr<const RTCStatsReport> report_; |
| 50 StatsMap::const_iterator it_; | 49 StatsMap::const_iterator it_; |
| 51 }; | 50 }; |
| 52 | 51 |
| 53 static rtc::scoped_refptr<RTCStatsReport> Create(uint64_t timestamp_us); | 52 static rtc::scoped_refptr<RTCStatsReport> Create(); |
| 54 | 53 |
| 55 explicit RTCStatsReport(uint64_t timestamp_us); | 54 RTCStatsReport(); |
| 56 RTCStatsReport(const RTCStatsReport& other) = delete; | 55 RTCStatsReport(const RTCStatsReport& other) = delete; |
| 57 | 56 |
| 58 uint64_t timestamp_us() const { return timestamp_us_; } | |
| 59 bool AddStats(std::unique_ptr<const RTCStats> stats); | 57 bool AddStats(std::unique_ptr<const RTCStats> stats); |
| 60 const RTCStats* Get(const std::string& id) const; | 58 const RTCStats* Get(const std::string& id) const; |
| 61 size_t size() const { return stats_.size(); } | 59 size_t size() const { return stats_.size(); } |
| 62 | 60 |
| 63 // Takes ownership of all the stats in |victim|, leaving it empty. | 61 // Takes ownership of all the stats in |victim|, leaving it empty. |
| 64 void TakeMembersFrom(rtc::scoped_refptr<RTCStatsReport> victim); | 62 void TakeMembersFrom(rtc::scoped_refptr<RTCStatsReport> victim); |
| 65 | 63 |
| 66 // Stats iterators. Stats are ordered lexicographically on |RTCStats::id|. | 64 // Stats iterators. Stats are ordered lexicographically on |RTCStats::id|. |
| 67 ConstIterator begin() const; | 65 ConstIterator begin() const; |
| 68 ConstIterator end() const; | 66 ConstIterator end() const; |
| 69 | 67 |
| 70 // Gets the subset of stats that are of type |T|, where |T| is any class | 68 // Gets the subset of stats that are of type |T|, where |T| is any class |
| 71 // descending from |RTCStats|. | 69 // descending from |RTCStats|. |
| 72 template<typename T> | 70 template<typename T> |
| 73 std::vector<const T*> GetStatsOfType() const { | 71 std::vector<const T*> GetStatsOfType() const { |
| 74 std::vector<const T*> stats_of_type; | 72 std::vector<const T*> stats_of_type; |
| 75 for (const RTCStats& stats : *this) { | 73 for (const RTCStats& stats : *this) { |
| 76 if (stats.type() == T::kType) | 74 if (stats.type() == T::kType) |
| 77 stats_of_type.push_back(&stats.cast_to<const T>()); | 75 stats_of_type.push_back(&stats.cast_to<const T>()); |
| 78 } | 76 } |
| 79 return stats_of_type; | 77 return stats_of_type; |
| 80 } | 78 } |
| 81 | 79 |
| 82 // Creates a human readable string representation of the report, listing all | |
| 83 // of its stats objects. | |
| 84 std::string ToString() const; | |
| 85 | |
| 86 friend class rtc::RefCountedObject<RTCStatsReport>; | 80 friend class rtc::RefCountedObject<RTCStatsReport>; |
| 87 | 81 |
| 88 private: | 82 private: |
| 89 ~RTCStatsReport() override; | 83 ~RTCStatsReport() override; |
| 90 | 84 |
| 91 uint64_t timestamp_us_; | |
| 92 StatsMap stats_; | 85 StatsMap stats_; |
| 93 }; | 86 }; |
| 94 | 87 |
| 95 } // namespace webrtc | 88 } // namespace webrtc |
| 96 | 89 |
| 97 #endif // WEBRTC_API_STATS_RTCSTATSREPORT_H_ | 90 #endif // WEBRTC_API_STATS_RTCSTATSREPORT_H_ |
| OLD | NEW |