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 #include "webrtc/api/rtcstatsreport.h" | |
12 | |
13 namespace webrtc { | |
14 | |
15 RTCStatsReport::ConstIterator::ConstIterator( | |
16 const rtc::scoped_refptr<const RTCStatsReport>& report, | |
17 StatsMap::const_iterator it) | |
18 : report_(report), | |
19 it_(it) { | |
20 } | |
21 | |
22 RTCStatsReport::ConstIterator::ConstIterator(const ConstIterator&& other) | |
23 : report_(std::move(other.report_)), | |
24 it_(std::move(other.it_)) { | |
25 } | |
26 | |
27 RTCStatsReport::ConstIterator::~ConstIterator() { | |
28 } | |
29 | |
30 RTCStatsReport::ConstIterator& RTCStatsReport::ConstIterator::operator++() { | |
31 ++it_; | |
32 return *this; | |
33 } | |
34 | |
35 RTCStatsReport::ConstIterator& RTCStatsReport::ConstIterator::operator++(int) { | |
36 return ++(*this); | |
37 } | |
38 | |
39 const RTCStats& RTCStatsReport::ConstIterator::operator*() const { | |
40 return *it_->second.get(); | |
41 } | |
42 | |
43 bool RTCStatsReport::ConstIterator::operator==( | |
44 const RTCStatsReport::ConstIterator& other) const { | |
45 return it_ == other.it_; | |
46 } | |
47 | |
48 bool RTCStatsReport::ConstIterator::operator!=( | |
49 const RTCStatsReport::ConstIterator& other) const { | |
50 return !(*this == other); | |
51 } | |
52 | |
53 rtc::scoped_refptr<RTCStatsReport> RTCStatsReport::Create() { | |
54 return rtc::scoped_refptr<RTCStatsReport>( | |
55 new rtc::RefCountedObject<RTCStatsReport>()); | |
56 } | |
57 | |
58 RTCStatsReport::RTCStatsReport() { | |
59 } | |
60 | |
61 RTCStatsReport::~RTCStatsReport() { | |
62 } | |
63 | |
64 bool RTCStatsReport::AddStats(std::unique_ptr<const RTCStats> stats) { | |
65 return !stats_.insert(std::make_pair(std::string(stats->id()), | |
66 std::move(stats))).second; | |
67 } | |
68 | |
69 const RTCStats* RTCStatsReport::Get(const std::string& id) const { | |
70 StatsMap::const_iterator it = stats_.find(id); | |
71 if (it != stats_.cend()) | |
72 return it->second.get(); | |
73 return nullptr; | |
74 } | |
75 | |
76 void RTCStatsReport::TakeMembersFrom( | |
77 rtc::scoped_refptr<RTCStatsReport> victim) { | |
78 for (StatsMap::iterator it = victim->stats_.begin(); | |
79 it != victim->stats_.end(); ++it) { | |
80 AddStats(std::unique_ptr<const RTCStats>(it->second.release())); | |
81 } | |
82 victim->stats_.clear(); | |
83 } | |
84 | |
85 RTCStatsReport::ConstIterator RTCStatsReport::begin() const { | |
86 return ConstIterator(rtc::scoped_refptr<const RTCStatsReport>(this), | |
87 stats_.cbegin()); | |
88 } | |
89 | |
90 RTCStatsReport::ConstIterator RTCStatsReport::end() const { | |
91 return ConstIterator(rtc::scoped_refptr<const RTCStatsReport>(this), | |
92 stats_.cend()); | |
93 } | |
94 | |
95 } // namespace webrtc | |
OLD | NEW |