From 2c3a1ae0be18e80f480fe2248dbc024eac9f0f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Qu=C3=A8ze?= Date: Wed, 11 Mar 2020 14:22:06 +0000 Subject: [PATCH] Bug 1620630 - The OS.File worker should record markers indicating which operation it is performing on which file, r=Yoric. Differential Revision: https://phabricator.services.mozilla.com/D65747 --HG-- extra : moz-landing-system : lando --- .../test/unit/test_attachments_downloader.js | 6 +++++- .../osfile/modules/osfile_async_worker.js | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/services/settings/test/unit/test_attachments_downloader.js b/services/settings/test/unit/test_attachments_downloader.js index ae0ea8d2ac73..1a2ad53b376c 100644 --- a/services/settings/test/unit/test_attachments_downloader.js +++ b/services/settings/test/unit/test_attachments_downloader.js @@ -192,7 +192,11 @@ add_task(async function test_delete_removes_local_file() { downloader.delete(RECORD); Assert.ok(!(await OS.File.exists(localFilePath))); - Assert.ok(!(await OS.File.exists(downloader.baseFolder))); + Assert.ok( + !(await OS.File.exists( + OS.Path.join(OS.Constants.Path.localProfileDir, ...downloader.folders) + )) + ); }); add_task(clear_state); diff --git a/toolkit/components/osfile/modules/osfile_async_worker.js b/toolkit/components/osfile/modules/osfile_async_worker.js index a37436947cf8..939784efc2fa 100644 --- a/toolkit/components/osfile/modules/osfile_async_worker.js +++ b/toolkit/components/osfile/modules/osfile_async_worker.js @@ -29,7 +29,23 @@ if (this.Components) { let worker = new PromiseWorker.AbstractWorker(); worker.dispatch = function(method, args = []) { - return Agent[method](...args); + let prefix = "OS.File " + method; + performance.mark(prefix + "-start"); + try { + return Agent[method](...args); + } finally { + let name = prefix; + if (args.length && args[0] instanceof Object && args[0].string) { + // Including the path in the marker name here means it will be part of + // profiles. It's fine to include personally identifiable information + // in profiles, because when a profile is captured only the user will + // see it, and before uploading it a sanitization step will be offered. + // The 'OS.File ' prefix will help the profiler know that these marker + // names should be sanitized. + name += " — " + args[0].string; + } + performance.measure(name, prefix + "-start"); + } }; worker.log = LOG; worker.postMessage = function(message, ...transfers) {