Files
Hippy/driver/js/include/devtools/trace_control.h
T
2022-08-11 20:34:35 +08:00

58 lines
1.9 KiB
C++

/*
* Tencent is pleased to support the open source community by making
* Hippy available.
*
* Copyright (C) 2017-2019 THL A29 Limited, a Tencent company.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef ENABLE_INSPECTOR
#pragma once
#include <string>
#if defined(JS_V8) && !defined(V8_WITHOUT_INSPECTOR)
#include "v8/libplatform/v8-tracing.h"
#endif
namespace hippy::devtools {
class TraceControl {
public:
static TraceControl &GetInstance() {
static TraceControl trace_control;
return trace_control;
}
void StartTracing();
void StopTracing();
#if defined(JS_V8) && !defined(V8_WITHOUT_INSPECTOR)
void SetGlobalTracingController(v8::platform::tracing::TracingController *tracing_control);
#endif
std::string GetTracingContent(const std::string& params_key);
inline void SetFileCacheDir(std::string file_cache_dir) { cache_file_dir_ = std::move(file_cache_dir); }
private:
TraceControl() = default;
TraceControl(const TraceControl &) = delete;
void operator=(const TraceControl &) = delete;
#if defined(JS_V8) && !defined(V8_WITHOUT_INSPECTOR)
v8::platform::tracing::TracingController *v8_trace_control_ = nullptr;
#endif
std::ofstream trace_file_;
bool OpenCacheFile();
std::string cache_file_dir_;
std::string cache_file_path_;
bool tracing_has_start_ = false;
};
} // namespace hippy::devtools
#endif