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

Side by Side Diff: webrtc/api/statscollector.cc

Issue 2290203002: Delete Timing class, timing.h, and update all users. (Closed)
Patch Set: New helper rtc::WallTimeSeconds. 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
« no previous file with comments | « no previous file | webrtc/base/BUILD.gn » ('j') | webrtc/base/timeutils.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/api/statscollector.h" 11 #include "webrtc/api/statscollector.h"
12 12
13 #include <memory> 13 #include <memory>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/api/peerconnection.h" 17 #include "webrtc/api/peerconnection.h"
18 #include "webrtc/base/base64.h" 18 #include "webrtc/base/base64.h"
19 #include "webrtc/base/checks.h" 19 #include "webrtc/base/checks.h"
20 #include "webrtc/base/timing.h"
21 #include "webrtc/pc/channel.h" 20 #include "webrtc/pc/channel.h"
22 21
23 namespace webrtc { 22 namespace webrtc {
24 namespace { 23 namespace {
25 24
26 // The following is the enum RTCStatsIceCandidateType from 25 // The following is the enum RTCStatsIceCandidateType from
27 // http://w3c.github.io/webrtc-stats/#rtcstatsicecandidatetype-enum such that 26 // http://w3c.github.io/webrtc-stats/#rtcstatsicecandidatetype-enum such that
28 // our stats report for ice candidate type could conform to that. 27 // our stats report for ice candidate type could conform to that.
29 const char STATSREPORT_LOCAL_PORT_TYPE[] = "host"; 28 const char STATSREPORT_LOCAL_PORT_TYPE[] = "host";
30 const char STATSREPORT_STUN_PORT_TYPE[] = "serverreflexive"; 29 const char STATSREPORT_STUN_PORT_TYPE[] = "serverreflexive";
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 StatsCollector::StatsCollector(PeerConnection* pc) 368 StatsCollector::StatsCollector(PeerConnection* pc)
370 : pc_(pc), stats_gathering_started_(0) { 369 : pc_(pc), stats_gathering_started_(0) {
371 RTC_DCHECK(pc_); 370 RTC_DCHECK(pc_);
372 } 371 }
373 372
374 StatsCollector::~StatsCollector() { 373 StatsCollector::~StatsCollector() {
375 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); 374 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
376 } 375 }
377 376
378 double StatsCollector::GetTimeNow() { 377 double StatsCollector::GetTimeNow() {
379 return rtc::Timing::WallTimeNow() * rtc::kNumMillisecsPerSec; 378 return rtc::WallClockSeconds();
380 } 379 }
381 380
382 // Adds a MediaStream with tracks that can be used as a |selector| in a call 381 // Adds a MediaStream with tracks that can be used as a |selector| in a call
383 // to GetStats. 382 // to GetStats.
384 void StatsCollector::AddStream(MediaStreamInterface* stream) { 383 void StatsCollector::AddStream(MediaStreamInterface* stream) {
385 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); 384 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
386 RTC_DCHECK(stream != NULL); 385 RTC_DCHECK(stream != NULL);
387 386
388 CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(), 387 CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(),
389 &reports_, track_ids_); 388 &reports_, track_ids_);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 const StatsReport::Value* v = 458 const StatsReport::Value* v =
460 r->FindValue(StatsReport::kStatsValueNameTrackId); 459 r->FindValue(StatsReport::kStatsValueNameTrackId);
461 if (v && v->string_val() == track->id()) 460 if (v && v->string_val() == track->id())
462 reports->push_back(r); 461 reports->push_back(r);
463 } 462 }
464 } 463 }
465 464
466 void 465 void
467 StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) { 466 StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
468 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); 467 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
469 double time_now = GetTimeNow(); 468 double time_now = GetTimeNow();
nisse-webrtc 2016/08/31 06:34:41 hbos: This is the only call to GetTimeNow. For t
pthatcher1 2016/08/31 18:19:46 I think using a ScopedFakeClock is easy. Why not
nisse-webrtc 2016/09/01 09:05:37 We'd need a separate hook to fake utc time. I don'
470 // Calls to UpdateStats() that occur less than kMinGatherStatsPeriod number of 469 // Calls to UpdateStats() that occur less than kMinGatherStatsPeriod number of
471 // ms apart will be ignored. 470 // ms apart will be ignored.
472 const double kMinGatherStatsPeriod = 50; 471 const double kMinGatherStatsPeriod = 50;
473 if (stats_gathering_started_ != 0 && 472 if (stats_gathering_started_ != 0 &&
474 stats_gathering_started_ + kMinGatherStatsPeriod > time_now) { 473 stats_gathering_started_ + kMinGatherStatsPeriod > time_now) {
475 return; 474 return;
476 } 475 }
477 stats_gathering_started_ = time_now; 476 stats_gathering_started_ = time_now;
478 477
479 // TODO(pthatcher): Merge PeerConnection and WebRtcSession so there is no 478 // TODO(pthatcher): Merge PeerConnection and WebRtcSession so there is no
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 StatsReport* report = entry.second; 960 StatsReport* report = entry.second;
962 report->set_timestamp(stats_gathering_started_); 961 report->set_timestamp(stats_gathering_started_);
963 } 962 }
964 } 963 }
965 964
966 void StatsCollector::ClearUpdateStatsCacheForTest() { 965 void StatsCollector::ClearUpdateStatsCacheForTest() {
967 stats_gathering_started_ = 0; 966 stats_gathering_started_ = 0;
968 } 967 }
969 968
970 } // namespace webrtc 969 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/BUILD.gn » ('j') | webrtc/base/timeutils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698