2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-08-30 03:50:06 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2016-06-09 20:04:42 +03:00
|
|
|
#include "PerformanceWorker.h"
|
2018-01-31 10:24:08 +03:00
|
|
|
#include "mozilla/dom/WorkerPrivate.h"
|
2019-07-26 04:10:23 +03:00
|
|
|
#include "mozilla/StaticPrefs_dom.h"
|
2014-08-30 03:50:06 +04:00
|
|
|
|
2016-06-09 20:04:42 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
PerformanceWorker::PerformanceWorker(WorkerPrivate* aWorkerPrivate)
|
2018-06-16 17:21:46 +03:00
|
|
|
: Performance(aWorkerPrivate->UsesSystemPrincipal()),
|
|
|
|
mWorkerPrivate(aWorkerPrivate) {
|
2014-08-30 03:50:06 +04:00
|
|
|
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
|
|
}
|
|
|
|
|
2016-06-09 20:04:42 +03:00
|
|
|
PerformanceWorker::~PerformanceWorker() {
|
2014-08-30 03:50:06 +04:00
|
|
|
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
|
|
}
|
|
|
|
|
2016-06-09 20:04:42 +03:00
|
|
|
void PerformanceWorker::InsertUserEntry(PerformanceEntry* aEntry) {
|
2018-09-10 21:36:15 +03:00
|
|
|
if (StaticPrefs::dom_performance_enable_user_timing_logging()) {
|
2015-08-21 00:34:22 +03:00
|
|
|
nsAutoCString uri;
|
|
|
|
nsCOMPtr<nsIURI> scriptURI = mWorkerPrivate->GetResolvedScriptURI();
|
|
|
|
if (!scriptURI || NS_FAILED(scriptURI->GetHost(uri))) {
|
|
|
|
// If we have no URI, just put in "none".
|
|
|
|
uri.AssignLiteral("none");
|
|
|
|
}
|
2016-06-09 20:04:42 +03:00
|
|
|
Performance::LogEntry(aEntry, uri);
|
2015-07-28 19:33:37 +03:00
|
|
|
}
|
2016-06-09 20:04:42 +03:00
|
|
|
Performance::InsertUserEntry(aEntry);
|
2015-07-28 19:33:37 +03:00
|
|
|
}
|
|
|
|
|
2016-06-09 20:04:42 +03:00
|
|
|
TimeStamp PerformanceWorker::CreationTimeStamp() const {
|
2016-12-16 11:07:39 +03:00
|
|
|
return mWorkerPrivate->CreationTimeStamp();
|
2015-11-19 17:04:47 +03:00
|
|
|
}
|
2015-05-25 19:53:07 +03:00
|
|
|
|
2016-06-09 20:04:42 +03:00
|
|
|
DOMHighResTimeStamp PerformanceWorker::CreationTime() const {
|
2016-12-16 11:07:39 +03:00
|
|
|
return mWorkerPrivate->CreationTime();
|
2015-05-25 19:53:07 +03:00
|
|
|
}
|
|
|
|
|
2018-03-13 20:36:34 +03:00
|
|
|
uint64_t PerformanceWorker::GetRandomTimelineSeed() {
|
|
|
|
return mWorkerPrivate->GetRandomTimelineSeed();
|
|
|
|
}
|
|
|
|
|
2020-03-25 17:09:42 +03:00
|
|
|
bool PerformanceWorker::CrossOriginIsolated() const {
|
|
|
|
return mWorkerPrivate->CrossOriginIsolated();
|
|
|
|
}
|
|
|
|
|
2016-06-09 20:04:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|