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 OHOS_ABILITY_RUNTIME_RENDER_RECORD_H 17 #define OHOS_ABILITY_RUNTIME_RENDER_RECORD_H 18 19 #include "irender_scheduler.h" 20 #include "app_death_recipient.h" 21 #include "fd_guard.h" 22 23 namespace OHOS { 24 namespace AppExecFwk { 25 using AAFwk::FdGuard; 26 class AppRunningRecord; 27 28 /** 29 * @class RenderRecord 30 * Record nweb render process info. 31 */ 32 class RenderRecord { 33 public: 34 RenderRecord(pid_t hostPid, const std::string &renderParam, 35 FdGuard &&ipcFd, FdGuard &&sharedFd, FdGuard &&crashFd, 36 const std::shared_ptr<AppRunningRecord> &host); 37 38 virtual ~RenderRecord(); 39 40 static std::shared_ptr<RenderRecord> 41 CreateRenderRecord(pid_t hostPid, const std::string &renderParam, 42 FdGuard &&ipcFd, FdGuard &&sharedFd, FdGuard &&crashFd, 43 const std::shared_ptr<AppRunningRecord> &host); 44 45 void SetPid(pid_t pid); 46 pid_t GetPid() const ; 47 pid_t GetHostPid() const; 48 void SetUid(int32_t uid); 49 int32_t GetUid() const; 50 int32_t GetHostUid() const; 51 std::string GetHostBundleName() const; 52 std::string GetRenderParam() const; 53 std::string GetProcessName() const; 54 int32_t GetIpcFd() const; 55 int32_t GetSharedFd() const; 56 int32_t GetCrashFd() const; 57 ProcessType GetProcessType() const; 58 std::shared_ptr<AppRunningRecord> GetHostRecord() const; 59 sptr<IRenderScheduler> GetScheduler() const; 60 void SetScheduler(const sptr<IRenderScheduler> &scheduler); 61 void SetDeathRecipient(const sptr<AppDeathRecipient> recipient); 62 void RegisterDeathRecipient(); 63 void SetState(int32_t state); 64 int32_t GetState() const; 65 void SetProcessType(ProcessType type); 66 void SetProcessName(const std::string &processName); 67 68 private: 69 void SetHostUid(const int32_t hostUid); 70 void SetHostBundleName(const std::string &hostBundleName); 71 72 pid_t pid_ = 0; 73 pid_t hostPid_ = 0; 74 int32_t uid_ = 0; 75 int32_t hostUid_ = 0; 76 int32_t state_ = 0; 77 ProcessType processType_ = ProcessType::RENDER; 78 FdGuard ipcFd_; 79 FdGuard sharedFd_; 80 FdGuard crashFd_; 81 std::weak_ptr<AppRunningRecord> host_; // nweb host 82 sptr<IRenderScheduler> renderScheduler_ = nullptr; 83 sptr<AppDeathRecipient> deathRecipient_ = nullptr; 84 std::string renderParam_; 85 std::string hostBundleName_; 86 std::string processName_; 87 }; 88 } // namespace AppExecFwk 89 } // namespace OHOS 90 #endif // OHOS_ABILITY_RUNTIME_RENDER_RECORD_H