Files
ark_js_runtime/ecmascript/tooling/interface/file_stream.h
T
Riachel 557c07bb07 Descriptor: support heapprofiler domain
details:
1. add statsUpdate event
2. add lastObjectId event
issue: https://gitee.com/openharmony/ark_js_runtime/issues/I5AUJA

Signed-off-by: Riachel <caolili14@huawei.com>
2022-06-07 11:29:50 +08:00

85 lines
2.3 KiB
C++

/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* 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.
*/
#ifndef ECMASCRIPT_TOOLING_INTERFACE_FILE_STREAM_H
#define ECMASCRIPT_TOOLING_INTERFACE_FILE_STREAM_H
#include <fstream>
#include "ecmascript/tooling/interface/stream.h"
namespace panda::ecmascript {
class FileStream : public Stream {
public:
FileStream(const std::string &fileName);
~FileStream() override = default;
void EndOfStream() override;
// Get chunk's size
int GetSize() override
{
const static int fileChunkSize = 10240;
return fileChunkSize;
}
// Writes the chunk of data into the stream
bool WriteChunk(char* data, int size) override;
bool Good() override;
void UpdateHeapStats([[maybe_unused]]HeapStat* data, [[maybe_unused]]int count) override
{
}
void UpdateLastSeenObjectId([[maybe_unused]]uint32_t lastSeenObjectId) override
{
}
private:
void Initialize(const std::string &fileName);
std::pair<bool, std::string> FilePathValid(const std::string &fileName);
std::fstream fileStream_;
};
class FileDescriptorStream : public Stream {
public:
explicit FileDescriptorStream(int32_t fd): fd_(fd) {}
~FileDescriptorStream() override = default;
void EndOfStream() override;
// Get chunk's size
int GetSize() override
{
const static int fileChunkSize = 10240;
return fileChunkSize;
}
// Writes the chunk of data into the stream
bool WriteChunk(char *data, int size) override;
bool Good() override;
void UpdateHeapStats([[maybe_unused]]HeapStat* data, [[maybe_unused]]int count) override
{
}
void UpdateLastSeenObjectId([[maybe_unused]]uint32_t lastSeenObjectId) override
{
}
private:
int32_t fd_;
};
} // namespace panda::ecmascript::tooling
#endif // ECMASCRIPT_TOOLING_INTERFACE_FILE_STREAM_H