fake_resource.cc (1318B)
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 <string> 14 15 #include "absl/strings/string_view.h" 16 #include "api/adaptation/resource.h" 17 #include "api/make_ref_counted.h" 18 #include "api/scoped_refptr.h" 19 20 namespace webrtc { 21 22 // static 23 scoped_refptr<FakeResource> FakeResource::Create(absl::string_view name) { 24 return make_ref_counted<FakeResource>(name); 25 } 26 27 FakeResource::FakeResource(absl::string_view name) 28 : Resource(), name_(name), listener_(nullptr) {} 29 30 FakeResource::~FakeResource() {} 31 32 void FakeResource::SetUsageState(ResourceUsageState usage_state) { 33 if (listener_) { 34 listener_->OnResourceUsageStateMeasured(scoped_refptr<Resource>(this), 35 usage_state); 36 } 37 } 38 39 std::string FakeResource::Name() const { 40 return name_; 41 } 42 43 void FakeResource::SetResourceListener(ResourceListener* listener) { 44 listener_ = listener; 45 } 46 47 } // namespace webrtc