1 /* 2 * Copyright (c) 2023 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 #ifndef INTERFACES_INNER_API_UNIFIED_COLLECTION_UTILITY_MEM_PROFILER_COLLECTOR_H 16 #define INTERFACES_INNER_API_UNIFIED_COLLECTION_UTILITY_MEM_PROFILER_COLLECTOR_H 17 #include <memory> 18 #include "collect_result.h" 19 #include "native_memory_profiler_sa_client_manager.h" 20 21 namespace OHOS { 22 namespace HiviewDFX { 23 namespace UCollectUtil { 24 using ProfilerType = Developtools::NativeDaemon::NativeMemoryProfilerSaClientManager::NativeMemProfilerType; 25 class MemProfilerCollector { 26 public: 27 MemProfilerCollector() = default; 28 virtual ~MemProfilerCollector() = default; 29 30 public: 31 virtual int Start(ProfilerType type, 32 int pid, int duration, int sampleInterval) = 0; 33 virtual int StartPrintNmd(int fd, int pid, int type) = 0; 34 virtual int Stop(int pid) = 0; 35 virtual int Stop(const std::string& processName) = 0; 36 virtual int Start(int fd, ProfilerType type, 37 int pid, int duration, int sampleInterval) = 0; 38 virtual int Start(int fd, ProfilerType type, 39 std::string processName, int duration, int sampleInterval, bool startup = false) = 0; 40 virtual int Prepare() = 0; 41 static std::shared_ptr<MemProfilerCollector> Create(); 42 }; // MemProfilerCollector 43 } // UCollectUtil 44 } // HiviewDFX 45 } // OHOS 46 #endif // INTERFACES_INNER_API_UNIFIED_COLLECTION_UTILITY_MEM_PROFILER_COLLECTOR_H