Bug 1627460 - Add markers for ImportScripts and require in workers, r=mstange.

Differential Revision: https://phabricator.services.mozilla.com/D69711

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Florian Quèze 2020-04-09 10:10:38 +00:00
Родитель 070b148444
Коммит 9746b4f2de
2 изменённых файлов: 23 добавлений и 2 удалений

Просмотреть файл

@ -37,6 +37,7 @@
#include "mozilla/dom/WorkerNavigator.h"
#include "mozilla/dom/cache/CacheStorage.h"
#include "mozilla/StorageAccess.h"
#include "GeckoProfiler.h"
#include "nsContentUtils.h"
#include "nsJSUtils.h"
#include "nsServiceManagerUtils.h"
@ -286,8 +287,25 @@ void WorkerGlobalScope::ImportScripts(JSContext* aCx,
stack = GetCurrentStackForNetMonitor(aCx);
}
workerinternals::Load(mWorkerPrivate, std::move(stack), aScriptURLs,
WorkerScript, aRv);
{
#ifdef MOZ_GECKO_PROFILER
nsCString urls;
if (profiler_can_accept_markers()) {
const uint32_t urlCount = aScriptURLs.Length();
if (urlCount) {
urls = NS_ConvertUTF16toUTF8(aScriptURLs[0]);
for (uint32_t index = 1; index < urlCount; index++) {
urls.AppendLiteral(",");
urls.Append(NS_ConvertUTF16toUTF8(aScriptURLs[index]));
}
}
}
AUTO_PROFILER_TEXT_MARKER_CAUSE("ImportScripts", urls, JS, Nothing(),
profiler_get_backtrace());
#endif
workerinternals::Load(mWorkerPrivate, std::move(stack), aScriptURLs,
WorkerScript, aRv);
}
}
int32_t WorkerGlobalScope::SetTimeout(JSContext* aCx, Function& aHandler,

Просмотреть файл

@ -88,6 +88,7 @@
* @return {*} An object containing the properties exported by the module.
*/
return function require(path) {
let startTime = performance.now();
if (typeof path != "string" || !path.includes("://")) {
throw new TypeError(
"The argument to require() must be a string uri, got " + path
@ -146,6 +147,8 @@
// after all.
modules.delete(path);
throw ex;
} finally {
ChromeUtils.addProfilerMarker("require", startTime, path);
}
Object.freeze(module.exports);