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 #ifndef FLOWBUFFER_ADAPTER_IMPL_H 17 #define FLOWBUFFER_ADAPTER_IMPL_H 18 19 #include "flowbuffer_adapter.h" 20 21 namespace OHOS::NWeb { 22 class FlowbufferAdapterImpl : public FlowbufferAdapter { 23 public: 24 /** 25 * @brief Construct a new FlowbufferAdapterImpl object 26 */ 27 FlowbufferAdapterImpl() = default; 28 29 /** 30 * @brief Destroy the FlowbufferAdapterImpl object 31 */ 32 ~FlowbufferAdapterImpl() override; 33 34 /** 35 * @brief Start temporary performance boost when some key tasks are running 36 */ 37 void StartPerformanceBoost() override; 38 39 /** 40 * @brief Create ashmem 41 * 42 * @param size size of the ashmem to be created 43 * @param mapType mapType of the ashmem to be created 44 * @param fd fd of the ashmem to be created 45 * @return the address of the created ashmem 46 */ 47 void* CreateAshmem(size_t size, int mapType, int& fd) override; 48 49 /** 50 * @brief Create ashmem with fd 51 * 52 * @param fd fd of the ashmem to be created 53 * @param size size of the ashmem to be created 54 * @param mapType mapType of the ashmem to be created 55 * @return the address of the created ashmem 56 */ 57 void* CreateAshmemWithFd(const int fd, size_t size, int mapType) override; 58 59 private: 60 bool NeedReportScene(); 61 62 static int64_t timeStamp_; 63 static int64_t preTimeStamp_; 64 void* data_ = nullptr; 65 size_t size_; 66 }; 67 } // namespace OHOS::NWeb 68 69 #endif // FLOWBUFFER_ADAPTER_IMPL_H 70