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

Side by Side Diff: webrtc/stats/rtcstatsreport.cc

Issue 2241093002: RTCStats and RTCStatsReport added (webrtc/stats) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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 #include "webrtc/api/rtcstatsreport.h"
12
13 namespace webrtc {
14
15 RTCStatsReport::ConstIterator& RTCStatsReport::ConstIterator::operator++() {
16 ++it_;
17 return *this;
18 }
19
20 RTCStatsReport::ConstIterator& RTCStatsReport::ConstIterator::operator++(int) {
21 return ++(*this);
22 }
23
24 const RTCStats& RTCStatsReport::ConstIterator::operator*() const {
25 return *it_->second.get();
26 }
27
28 bool RTCStatsReport::ConstIterator::operator==(
29 const RTCStatsReport::ConstIterator& other) const {
30 return it_ == other.it_;
31 }
32
33 bool RTCStatsReport::ConstIterator::operator!=(
34 const RTCStatsReport::ConstIterator& other) const {
35 return !(*this == other);
36 }
37
38 rtc::scoped_refptr<RTCStatsReport> RTCStatsReport::Create() {
39 return rtc::scoped_refptr<RTCStatsReport>(
40 new rtc::RefCountedObject<RTCStatsReport>());
41 }
42
43 bool RTCStatsReport::AddStats(std::unique_ptr<const RTCStats> stats) {
44 return !stats_.insert(std::make_pair(std::string(stats->id()),
45 std::move(stats))).second;
46 }
47
48 const RTCStats* RTCStatsReport::operator[](const std::string& id) const {
49 StatsMap::const_iterator it = stats_.find(id);
50 if (it != stats_.cend())
51 return it->second.get();
52 return nullptr;
53 }
54
55 RTCStatsReport::ConstIterator RTCStatsReport::begin() const {
56 return ConstIterator(rtc::scoped_refptr<const RTCStatsReport>(this),
57 stats_.cbegin());
58 }
59
60 RTCStatsReport::ConstIterator RTCStatsReport::end() const {
61 return ConstIterator(rtc::scoped_refptr<const RTCStatsReport>(this),
62 stats_.cend());
63 }
64
65 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698