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

Side by Side Diff: content/renderer/media/webrtc/rtc_stats.cc

Issue 2359103002: WebRTCStatsReport::copyHandle and getStats added (Closed)
Patch Set: Created 4 years, 3 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
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/webrtc/rtc_stats.h" 5 #include "content/renderer/media/webrtc/rtc_stats.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 RTCStatsReport::RTCStatsReport( 12 RTCStatsReport::RTCStatsReport(
13 const scoped_refptr<const webrtc::RTCStatsReport>& stats_report) 13 const scoped_refptr<const webrtc::RTCStatsReport>& stats_report)
14 : stats_report_(stats_report), 14 : stats_report_(stats_report),
15 it_(stats_report_->begin()), 15 it_(stats_report_->begin()),
16 end_(stats_report_->end()) { 16 end_(stats_report_->end()) {
17 DCHECK(stats_report_); 17 DCHECK(stats_report_);
18 } 18 }
19 19
20 RTCStatsReport::~RTCStatsReport() { 20 RTCStatsReport::~RTCStatsReport() {
21 } 21 }
22 22
23 std::unique_ptr<blink::WebRTCStatsReport> RTCStatsReport::copyHandle() const {
24 return std::unique_ptr<blink::WebRTCStatsReport>(
25 new RTCStatsReport(stats_report_));
26 }
27
28 std::unique_ptr<blink::WebRTCStats> RTCStatsReport::getStats(
29 blink::WebString id) const {
30 const webrtc::RTCStats* stats = stats_report_->Get(id.utf8());
31 if (!stats)
32 return std::unique_ptr<blink::WebRTCStats>();
33 return std::unique_ptr<blink::WebRTCStats>(
34 new RTCStats(stats_report_, stats));
35 }
36
23 std::unique_ptr<blink::WebRTCStats> RTCStatsReport::next() { 37 std::unique_ptr<blink::WebRTCStats> RTCStatsReport::next() {
24 if (it_ == end_) 38 if (it_ == end_)
25 return std::unique_ptr<blink::WebRTCStats>(); 39 return std::unique_ptr<blink::WebRTCStats>();
26 const webrtc::RTCStats& next = *it_; 40 const webrtc::RTCStats& next = *it_;
27 ++it_; 41 ++it_;
28 return std::unique_ptr<blink::WebRTCStats>( 42 return std::unique_ptr<blink::WebRTCStats>(
29 new RTCStats(stats_report_, &next)); 43 new RTCStats(stats_report_, &next));
30 } 44 }
31 45
32 RTCStats::RTCStats( 46 RTCStats::RTCStats(
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 blink::WebVector<blink::WebString> RTCStatsMember::valueSequenceString() const { 181 blink::WebVector<blink::WebString> RTCStatsMember::valueSequenceString() const {
168 const std::vector<std::string>& sequence = 182 const std::vector<std::string>& sequence =
169 *member_->cast_to<webrtc::RTCStatsMember<std::vector<std::string>>>(); 183 *member_->cast_to<webrtc::RTCStatsMember<std::vector<std::string>>>();
170 blink::WebVector<blink::WebString> web_sequence(sequence.size()); 184 blink::WebVector<blink::WebString> web_sequence(sequence.size());
171 for (size_t i = 0; i < sequence.size(); ++i) 185 for (size_t i = 0; i < sequence.size(); ++i)
172 web_sequence[i] = blink::WebString::fromUTF8(sequence[i]); 186 web_sequence[i] = blink::WebString::fromUTF8(sequence[i]);
173 return web_sequence; 187 return web_sequence;
174 } 188 }
175 189
176 } // namespace content 190 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698