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 16 #ifndef EVENT_HANDLER_ADAPTER_H 17 #define EVENT_HANDLER_ADAPTER_H 18 19 #include <string> 20 21 namespace OHOS::NWeb { 22 23 class EventHandlerFDListenerAdapter { 24 public: 25 EventHandlerFDListenerAdapter() = default; 26 27 virtual ~EventHandlerFDListenerAdapter() = default; 28 29 virtual void OnReadable(int32_t fileDescriptor) = 0; 30 }; 31 32 class EventHandlerAdapter { 33 public: 34 EventHandlerAdapter() = default; 35 36 virtual ~EventHandlerAdapter() = default; 37 38 virtual bool AddFileDescriptorListener( 39 int32_t fileDescriptor, uint32_t events, const std::shared_ptr<EventHandlerFDListenerAdapter> listener) = 0; 40 41 virtual void RemoveFileDescriptorListener(int32_t fileDescriptor) = 0; 42 43 // be consistent with 44 // rom/base/notification/eventhandler/interfaces/inner_api/file_descriptor_listener.h 45 // FILE_DESCRIPTOR_INPUT_EVENT 46 enum { 47 INPUT_EVENT = 1, 48 }; 49 }; 50 51 } // namespace OHOS::NWeb 52 53 #endif // EVENT_HANDLER_ADAPTER_H 54