mirror of
https://github.com/Tencent/Hippy.git
synced 2026-10-26 03:00:18 +08:00
Co-authored-by: luomy <ozonelmy@163.com> Co-authored-by: maxli <maxli@tencent.com> Co-authored-by: shermanchen <shermanchen@tencent.com> Co-authored-by: omegaxiao <omegaxiao@tencent.com>
58 lines
1.9 KiB
C++
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
|