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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/stats/rtcstats_unittest.cc ('k') | webrtc/stats/stats.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/stats/rtcstatsreport.cc
diff --git a/webrtc/stats/rtcstatsreport.cc b/webrtc/stats/rtcstatsreport.cc
new file mode 100644
index 0000000000000000000000000000000000000000..870651d2dfc52b1afff2bda5f227ee57274c34ed
--- /dev/null
+++ b/webrtc/stats/rtcstatsreport.cc
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2016 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/api/rtcstatsreport.h"
+
+namespace webrtc {
+
+RTCStatsReport::ConstIterator::ConstIterator(
+ const rtc::scoped_refptr<const RTCStatsReport>& report,
+ StatsMap::const_iterator it)
+ : report_(report),
+ it_(it) {
+}
+
+RTCStatsReport::ConstIterator::ConstIterator(const ConstIterator&& other)
+ : report_(std::move(other.report_)),
+ it_(std::move(other.it_)) {
+}
+
+RTCStatsReport::ConstIterator::~ConstIterator() {
+}
+
+RTCStatsReport::ConstIterator& RTCStatsReport::ConstIterator::operator++() {
+ ++it_;
+ return *this;
+}
+
+RTCStatsReport::ConstIterator& RTCStatsReport::ConstIterator::operator++(int) {
+ return ++(*this);
+}
+
+const RTCStats& RTCStatsReport::ConstIterator::operator*() const {
+ return *it_->second.get();
+}
+
+bool RTCStatsReport::ConstIterator::operator==(
+ const RTCStatsReport::ConstIterator& other) const {
+ return it_ == other.it_;
+}
+
+bool RTCStatsReport::ConstIterator::operator!=(
+ const RTCStatsReport::ConstIterator& other) const {
+ return !(*this == other);
+}
+
+rtc::scoped_refptr<RTCStatsReport> RTCStatsReport::Create() {
+ return rtc::scoped_refptr<RTCStatsReport>(
+ new rtc::RefCountedObject<RTCStatsReport>());
+}
+
+RTCStatsReport::RTCStatsReport() {
+}
+
+RTCStatsReport::~RTCStatsReport() {
+}
+
+bool RTCStatsReport::AddStats(std::unique_ptr<const RTCStats> stats) {
+ return !stats_.insert(std::make_pair(std::string(stats->id()),
+ std::move(stats))).second;
+}
+
+const RTCStats* RTCStatsReport::operator[](const std::string& id) const {
+ StatsMap::const_iterator it = stats_.find(id);
+ if (it != stats_.cend())
+ return it->second.get();
+ return nullptr;
+}
+
+RTCStatsReport::ConstIterator RTCStatsReport::begin() const {
+ return ConstIterator(rtc::scoped_refptr<const RTCStatsReport>(this),
+ stats_.cbegin());
+}
+
+RTCStatsReport::ConstIterator RTCStatsReport::end() const {
+ return ConstIterator(rtc::scoped_refptr<const RTCStatsReport>(this),
+ stats_.cend());
+}
+
+} // namespace webrtc
« 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