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

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: Addressed comments 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
« no previous file with comments | « webrtc/stats/rtcstats_unittest.cc ('k') | webrtc/stats/stats.gyp » ('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 #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::operator[](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 RTCStatsReport::ConstIterator RTCStatsReport::begin() const {
77 return ConstIterator(rtc::scoped_refptr<const RTCStatsReport>(this),
78 stats_.cbegin());
79 }
80
81 RTCStatsReport::ConstIterator RTCStatsReport::end() const {
82 return ConstIterator(rtc::scoped_refptr<const RTCStatsReport>(this),
83 stats_.cend());
84 }
85
86 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/stats/rtcstats_unittest.cc ('k') | webrtc/stats/stats.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698