[Battery]: Delay start of CallStats.
To avoid unnecessary repeating tasks, CallStats' timer is started only upon Call::EnsureStarted(). Bug: chromium:1152887 Change-Id: I1015315f42127bf510affc3d22c930b20eac8bba Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206880 Commit-Queue: Tommi <tommi@webrtc.org> Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33232}
This commit is contained in:

committed by
Commit Bot

parent
4eb47f2b72
commit
cc4743795b
@ -686,6 +686,8 @@ void Call::EnsureStarted() {
|
||||
}
|
||||
is_started_ = true;
|
||||
|
||||
call_stats_->EnsureStarted();
|
||||
|
||||
// This call seems to kick off a number of things, so probably better left
|
||||
// off being kicked off on request rather than in the ctor.
|
||||
transport_send_ptr_->RegisterTargetTransferRateObserver(this);
|
||||
|
@ -77,11 +77,6 @@ CallStats::CallStats(Clock* clock, TaskQueueBase* task_queue)
|
||||
task_queue_(task_queue) {
|
||||
RTC_DCHECK(task_queue_);
|
||||
RTC_DCHECK_RUN_ON(task_queue_);
|
||||
repeating_task_ =
|
||||
RepeatingTaskHandle::DelayedStart(task_queue_, kUpdateInterval, [this]() {
|
||||
UpdateAndReport();
|
||||
return kUpdateInterval;
|
||||
});
|
||||
}
|
||||
|
||||
CallStats::~CallStats() {
|
||||
@ -93,6 +88,15 @@ CallStats::~CallStats() {
|
||||
UpdateHistograms();
|
||||
}
|
||||
|
||||
void CallStats::EnsureStarted() {
|
||||
RTC_DCHECK_RUN_ON(task_queue_);
|
||||
repeating_task_ =
|
||||
RepeatingTaskHandle::DelayedStart(task_queue_, kUpdateInterval, [this]() {
|
||||
UpdateAndReport();
|
||||
return kUpdateInterval;
|
||||
});
|
||||
}
|
||||
|
||||
void CallStats::UpdateAndReport() {
|
||||
RTC_DCHECK_RUN_ON(task_queue_);
|
||||
|
||||
|
@ -35,6 +35,9 @@ class CallStats {
|
||||
CallStats(Clock* clock, TaskQueueBase* task_queue);
|
||||
~CallStats();
|
||||
|
||||
// Ensure that necessary repeating tasks are started.
|
||||
void EnsureStarted();
|
||||
|
||||
// Expose an RtcpRttStats implementation without inheriting from RtcpRttStats.
|
||||
// That allows us to separate the threading model of how RtcpRttStats is
|
||||
// used (mostly on a process thread) and how CallStats is used (mostly on
|
||||
|
@ -38,7 +38,10 @@ class MockStatsObserver : public CallStatsObserver {
|
||||
|
||||
class CallStats2Test : public ::testing::Test {
|
||||
public:
|
||||
CallStats2Test() { process_thread_->Start(); }
|
||||
CallStats2Test() {
|
||||
call_stats_.EnsureStarted();
|
||||
process_thread_->Start();
|
||||
}
|
||||
|
||||
~CallStats2Test() override { process_thread_->Stop(); }
|
||||
|
||||
|
Reference in New Issue
Block a user