2019-12-10 14:14:09 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright 2019 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 "call/adaptation/test/fake_resource.h"
|
|
|
|
|
|
2020-06-01 17:59:05 +02:00
|
|
|
#include <algorithm>
|
2019-12-10 14:14:09 +01:00
|
|
|
#include <utility>
|
|
|
|
|
|
2020-06-01 17:59:05 +02:00
|
|
|
#include "rtc_base/ref_counted_object.h"
|
|
|
|
|
|
2019-12-10 14:14:09 +01:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
2020-06-01 17:59:05 +02:00
|
|
|
// static
|
|
|
|
|
rtc::scoped_refptr<FakeResource> FakeResource::Create(std::string name) {
|
2021-04-22 19:21:43 +02:00
|
|
|
return rtc::make_ref_counted<FakeResource>(name);
|
2020-06-01 17:59:05 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-20 12:04:12 +02:00
|
|
|
FakeResource::FakeResource(std::string name)
|
2020-06-03 09:21:34 +02:00
|
|
|
: Resource(), name_(std::move(name)), listener_(nullptr) {}
|
2019-12-10 14:14:09 +01:00
|
|
|
|
2020-02-06 12:49:57 +01:00
|
|
|
FakeResource::~FakeResource() {}
|
2019-12-10 14:14:09 +01:00
|
|
|
|
2020-06-02 13:02:36 +02:00
|
|
|
void FakeResource::SetUsageState(ResourceUsageState usage_state) {
|
2020-06-01 17:59:05 +02:00
|
|
|
if (listener_) {
|
2022-01-14 09:18:23 +01:00
|
|
|
listener_->OnResourceUsageStateMeasured(rtc::scoped_refptr<Resource>(this),
|
|
|
|
|
usage_state);
|
2020-06-01 17:59:05 +02:00
|
|
|
}
|
2020-02-25 16:26:01 +01:00
|
|
|
}
|
2019-12-10 14:14:09 +01:00
|
|
|
|
2020-06-02 13:02:36 +02:00
|
|
|
std::string FakeResource::Name() const {
|
|
|
|
|
return name_;
|
2020-06-01 17:59:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FakeResource::SetResourceListener(ResourceListener* listener) {
|
|
|
|
|
listener_ = listener;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 14:14:09 +01:00
|
|
|
} // namespace webrtc
|