xref: /aosp_15_r20/external/webrtc/call/adaptation/test/fake_resource.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2019 The WebRTC Project Authors. All rights reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "call/adaptation/test/fake_resource.h"
12 
13 #include <algorithm>
14 #include <utility>
15 
16 #include "absl/strings/string_view.h"
17 #include "api/make_ref_counted.h"
18 
19 namespace webrtc {
20 
21 // static
Create(absl::string_view name)22 rtc::scoped_refptr<FakeResource> FakeResource::Create(absl::string_view name) {
23   return rtc::make_ref_counted<FakeResource>(name);
24 }
25 
FakeResource(absl::string_view name)26 FakeResource::FakeResource(absl::string_view name)
27     : Resource(), name_(name), listener_(nullptr) {}
28 
~FakeResource()29 FakeResource::~FakeResource() {}
30 
SetUsageState(ResourceUsageState usage_state)31 void FakeResource::SetUsageState(ResourceUsageState usage_state) {
32   if (listener_) {
33     listener_->OnResourceUsageStateMeasured(rtc::scoped_refptr<Resource>(this),
34                                             usage_state);
35   }
36 }
37 
Name() const38 std::string FakeResource::Name() const {
39   return name_;
40 }
41 
SetResourceListener(ResourceListener * listener)42 void FakeResource::SetResourceListener(ResourceListener* listener) {
43   listener_ = listener;
44 }
45 
46 }  // namespace webrtc
47