1 /* 2 * Copyright (c) 2021 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 ECMASCRIPT_JOBS_HIREACE_SCOPE_H 17 #define ECMASCRIPT_JOBS_HIREACE_SCOPE_H 18 19 #include "ecmascript/jobs/micro_job_queue.h" 20 #include "ecmascript/js_handle.h" 21 #include "ecmascript/js_thread.h" 22 23 #if defined(ENABLE_HITRACE) 24 #include "hitrace/hitraceid.h" 25 #endif 26 27 namespace panda::ecmascript::job { 28 #if defined(ENABLE_HITRACE) 29 using namespace OHOS::HiviewDFX; 30 #endif 31 class PendingJob; 32 class EnqueueJobScope { 33 public: 34 EnqueueJobScope(const JSHandle<PendingJob> &pendingJob, job::QueueType queueType); 35 36 ~EnqueueJobScope(); 37 }; 38 39 class ExecuteJobScope { 40 public: 41 explicit ExecuteJobScope(const JSHandle<PendingJob> &pendingJob); 42 43 ~ExecuteJobScope(); 44 private: 45 #if defined(ENABLE_HITRACE) 46 HiTraceId saveId_; 47 HiTraceId hitraceId_; 48 #endif 49 }; 50 51 class EnqueueJobTrace { 52 public: 53 EnqueueJobTrace(JSThread *thread, const JSHandle<PendingJob> &pendingJob); 54 ~EnqueueJobTrace(); 55 56 private: 57 bool isMicroJobTraceEnable_ {false}; 58 }; 59 60 class ExecuteJobTrace { 61 public: 62 ExecuteJobTrace(JSThread *thread, const JSHandle<PendingJob> &pendingJob); 63 ~ExecuteJobTrace(); 64 65 private: 66 bool isMicroJobTraceEnable_ {false}; 67 }; 68 } // namespace panda::ecmascript::job 69 #endif // ECMASCRIPT_JOBS_HIREACE_SCOPE_H 70