Skip to content

Commit

Permalink
devtools_frontend: remove blob recording
Browse files Browse the repository at this point in the history
  • Loading branch information
kobkaz committed Apr 12, 2024
1 parent ac3ee3c commit 6b5cc35
Showing 1 changed file with 3 additions and 37 deletions.
40 changes: 3 additions & 37 deletions devtools-frontend/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,49 +124,15 @@ class TelemetryRecorder {
this.run(rootRecordDirectory);
}

private async write(
recordDirectory: FileSystemDirectoryHandle,
writable: FileSystemWritableFileStream,
tmiv: Tmiv,
) {
// if tmiv has @blob field, save it to a file
let blobFileName = "";
const blob = tmiv.fields.find((field) => {
return field.name === "@blob";
});
if (blob !== undefined) {
if (blob.value.oneofKind == "bytes") {
const blobBytes = blob.value.bytes;
//FIXME: safer name consrtuction
const blobDirectory = await recordDirectory.getDirectoryHandle(
"blob_data",
{
create: true,
},
);

// FIXME: readable time format?
// FIXME: avoid name collision
blobFileName = `${Date.now()}.dat`;
const recordFile = await blobDirectory.getFileHandle(blobFileName, {
create: true,
});
const blobWritable = await recordFile.createWritable();
await blobWritable.write(blobBytes);
await blobWritable.close();
}
}

private async write(writable: FileSystemWritableFileStream, tmiv: Tmiv) {
const fields: { [key: string]: any } = {};
for (const field of tmiv.fields) {
if (field.name.includes("@RAW")) {
continue;
}
const name = field.name;
let value = undefined;
if (field.name == "@blob") {
value = blobFileName;
} else if (field.value.oneofKind == "integer") {
if (field.value.oneofKind == "integer") {
value = Number(field.value.integer);
} else if (field.value.oneofKind == "string") {
value = field.value.string;
Expand Down Expand Up @@ -217,7 +183,7 @@ class TelemetryRecorder {
}
const tmiv = next.value;

await this.write(recordDirectory, writable, tmiv);
await this.write(writable, tmiv);
if (Date.now() - lastFlushTime > 10000) {
lastFlushTime = Date.now();
await writable.close();
Expand Down

0 comments on commit 6b5cc35

Please sign in to comment.