Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: webrtc/api/rtcstatsreport.h

Issue 2241093002: RTCStats and RTCStatsReport added (webrtc/stats) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/api/rtcstats.h ('k') | webrtc/stats/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_API_RTCSTATSREPORT_H_
12 #define WEBRTC_API_RTCSTATSREPORT_H_
13
14 #include <map>
15 #include <memory>
16 #include <string>
17 #include <vector>
18
19 #include "webrtc/api/rtcstats.h"
20 #include "webrtc/base/refcount.h"
21 #include "webrtc/base/scoped_ref_ptr.h"
22
23 namespace webrtc {
24
25 // A collection of stats.
26 // This is accessible as a map from |RTCStats::id| to |RTCStats|.
27 class RTCStatsReport : public rtc::RefCountInterface {
28 public:
29 typedef std::map<std::string, std::unique_ptr<const RTCStats>> StatsMap;
30
31 class ConstIterator {
32 public:
33 ConstIterator(const ConstIterator&& other);
34 ~ConstIterator();
35
36 ConstIterator& operator++();
37 ConstIterator& operator++(int);
38 const RTCStats& operator*() const;
39 bool operator==(const ConstIterator& other) const;
40 bool operator!=(const ConstIterator& other) const;
41
42 private:
43 friend class RTCStatsReport;
44 ConstIterator(const rtc::scoped_refptr<const RTCStatsReport>& report,
45 StatsMap::const_iterator it);
46
47 // Reference report to make sure it is kept alive.
48 rtc::scoped_refptr<const RTCStatsReport> report_;
49 StatsMap::const_iterator it_;
50 };
51
52 static rtc::scoped_refptr<RTCStatsReport> Create();
53
54 RTCStatsReport();
55 RTCStatsReport(const RTCStatsReport& other) = delete;
56
57 bool AddStats(std::unique_ptr<const RTCStats> stats);
58 const RTCStats* operator[](const std::string& id) const;
59 size_t size() const { return stats_.size(); }
60
61 ConstIterator begin() const;
62 ConstIterator end() const;
63
64 // Gets the subset of stats that are of type |T|, where |T| is any class
65 // descending from |RTCStats|.
66 template<typename T>
67 std::vector<const T*> GetStatsOfType() const {
68 std::vector<const T*> stats_of_type;
69 for (const RTCStats& stats : *this) {
70 if (stats.type() == T::kType)
71 stats_of_type.push_back(&stats.cast_to<const T>());
72 }
73 return stats_of_type;
74 }
75
76 friend class rtc::RefCountedObject<RTCStatsReport>;
77
78 private:
79 ~RTCStatsReport() override;
80
81 StatsMap stats_;
82 };
83
84 } // namespace webrtc
85
86 #endif // WEBRTC_API_RTCSTATSREPORT_H_
OLDNEW
« no previous file with comments | « webrtc/api/rtcstats.h ('k') | webrtc/stats/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698