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

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: Removed find_bad_constructs and GYP android test dep (but not GN android) Created 4 years, 4 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
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, maps from |RTCStats::id| to |RTCStats|.
hta - Chromium 2016/08/15 15:14:57 Grammar nit: "A collection of stats. This is acces
hbos 2016/08/15 22:46:43 Done.
26 class RTCStatsReport : public rtc::RefCountInterface {
27 public:
28 typedef std::map<std::string, std::unique_ptr<const RTCStats>> StatsMap;
29
30 class ConstIterator {
31 public:
32 ConstIterator(const ConstIterator&& other);
33 ~ConstIterator();
34
35 ConstIterator& operator++();
36 ConstIterator& operator++(int);
37 const RTCStats& operator*() const;
38 bool operator==(const ConstIterator& other) const;
39 bool operator!=(const ConstIterator& other) const;
40
41 private:
42 friend class RTCStatsReport;
43 ConstIterator(const rtc::scoped_refptr<const RTCStatsReport>& report,
44 StatsMap::const_iterator it);
45
46 // Reference report to make sure it is kept alive.
47 rtc::scoped_refptr<const RTCStatsReport> report_;
48 StatsMap::const_iterator it_;
49 };
50
51 static rtc::scoped_refptr<RTCStatsReport> Create();
52
53 RTCStatsReport();
54 RTCStatsReport(const RTCStatsReport& other) = delete;
55
56 bool AddStats(std::unique_ptr<const RTCStats> stats);
57 const RTCStats* operator[](const std::string& id) const;
58 size_t size() const { return stats_.size(); }
59
60 ConstIterator begin() const;
61 ConstIterator end() const;
62
63 // Gets the subset of stats that are of type |T|, where |T| is any class
64 // descending from |RTCStats|.
65 template<typename T>
66 std::vector<const T*> GetStatsOfType() const {
67 std::vector<const T*> stats_of_type;
68 for (const RTCStats& stats : *this) {
69 if (stats.type() == &T::kType)
70 stats_of_type.push_back(&stats.to<const T>());
71 }
72 return stats_of_type;
73 }
74
75 friend class rtc::RefCountedObject<RTCStatsReport>;
76
77 private:
78 ~RTCStatsReport() override;
79
80 StatsMap stats_;
81 };
82
83 } // namespace webrtc
84
85 #endif // WEBRTC_API_RTCSTATSREPORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698