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_client.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> SetSplitMemoryValue(std::vector<UCollectClient::MemoryCaller>& memList) override; 32 CollectResult<int32_t> GetGraphicUsage() override; 33 }; 34 Create()35std::shared_ptr<MemoryCollector> MemoryCollector::Create() 36 { 37 return std::make_shared<MemoryCollectorImpl>(); 38 } 39 SetAppResourceLimit(UCollectClient::MemoryCaller & memoryCaller)40CollectResult<int32_t> MemoryCollectorImpl::SetAppResourceLimit(UCollectClient::MemoryCaller& memoryCaller) 41 { 42 return HiViewServiceMemoryDelegate::SetAppResourceLimit(memoryCaller); 43 } 44 SetSplitMemoryValue(std::vector<UCollectClient::MemoryCaller> & memList)45CollectResult<int32_t> MemoryCollectorImpl::SetSplitMemoryValue(std::vector<UCollectClient::MemoryCaller>& memList) 46 { 47 return HiViewServiceMemoryDelegate::SetSplitMemoryValue(memList); 48 } 49 GetGraphicUsage()50CollectResult<int32_t> MemoryCollectorImpl::GetGraphicUsage() 51 { 52 return HiViewServiceMemoryDelegate::GetGraphicUsage(); 53 } 54 } 55 } 56 } 57