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 FOUNDATION_ACE_FRAMEWORKS_CORE_RECORDER_EXPOSURE_PROCESSOR_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_RECORDER_EXPOSURE_PROCESSOR_H 18 19 #include <string> 20 21 #include "base/memory/ace_type.h" 22 #include "core/common/recorder/event_config.h" 23 24 namespace OHOS::Ace::Recorder { 25 class ExposureProcessor : public AceType { 26 DECLARE_ACE_TYPE(ExposureProcessor, AceType) 27 28 public: 29 ExposureProcessor(const std::string& pageUrl, const std::string& inspectorId); 30 ExposureProcessor(const std::string& pageUrl, const std::string& inspectorId, double ratio, int duration); 31 explicit ExposureProcessor(const RefPtr<ExposureProcessor>& processor); 32 ~ExposureProcessor() = default; 33 34 bool IsNeedRecord() const; 35 36 double GetRatio() const; 37 38 void OnVisibleChange(bool isVisible, const std::string& param = ""); 39 SetContainerId(int32_t id)40 void SetContainerId(int32_t id) 41 { 42 containerId_ = id; 43 } 44 GetContainerId()45 int32_t GetContainerId() const 46 { 47 return containerId_; 48 } 49 SetListenState(bool state)50 void SetListenState(bool state) 51 { 52 isListening_ = state; 53 } 54 isListening()55 bool isListening() const 56 { 57 return isListening_; 58 } 59 60 private: 61 ExposureCfg cfg_ = { "", 0.0, 0 }; 62 int64_t startTime_ = -1; 63 64 int32_t containerId_ = -1; 65 66 std::string pageUrl_; 67 std::string navDstName_; 68 69 bool isListening_ = false; 70 71 ACE_DISALLOW_COPY_AND_MOVE(ExposureProcessor); 72 }; 73 } // namespace OHOS::Ace::Recorder 74 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_RECORDER_EXPOSURE_PROCESSOR_H 75