1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "memory_collector.h" 17 #include "hiview_service_memory_delegate.h" 18 19 using namespace OHOS::HiviewDFX::UCollect; 20 21 namespace OHOS { 22 namespace HiviewDFX { 23 namespace UCollectClient { 24 25 class MemoryCollectorImpl : public MemoryCollector { 26 public: 27 MemoryCollectorImpl() = default; 28 virtual ~MemoryCollectorImpl() = default; 29 public: 30 CollectResult<int32_t> SetAppResourceLimit(UCollectClient::MemoryCaller& memoryCaller) override; 31 CollectResult<int32_t> GetGraphicUsage() override; 32 }; 33 Create()34std::shared_ptr<MemoryCollector> MemoryCollector::Create() 35 { 36 return std::make_shared<MemoryCollectorImpl>(); 37 } 38 SetAppResourceLimit(UCollectClient::MemoryCaller & memoryCaller)39CollectResult<int32_t> MemoryCollectorImpl::SetAppResourceLimit(UCollectClient::MemoryCaller& memoryCaller) 40 { 41 return HiViewServiceMemoryDelegate::SetAppResourceLimit(memoryCaller); 42 } 43 GetGraphicUsage()44CollectResult<int32_t> MemoryCollectorImpl::GetGraphicUsage() 45 { 46 return HiViewServiceMemoryDelegate::GetGraphicUsage(); 47 } 48 } 49 } 50 } 51