mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-03 14:28:39 +09:00
Bug 1322292 - Some fixes for the Performance API in workers - part 1 - Centralized Performance.now()
https://hg.mozilla.org/mozilla-central/rev/291a68ca4825
This commit is contained in:
parent
d40e56137b
commit
94ea4f222c
7 changed files with 10 additions and 23 deletions
|
|
@ -120,6 +120,13 @@ Performance::Performance(nsPIDOMWindowInner* aWindow)
|
|||
Performance::~Performance()
|
||||
{}
|
||||
|
||||
DOMHighResTimeStamp
|
||||
Performance::Now() const
|
||||
{
|
||||
TimeDuration duration = TimeStamp::Now() - CreationTimeStamp();
|
||||
return RoundTime(duration.ToMilliseconds());
|
||||
}
|
||||
|
||||
DOMHighResTimeStamp
|
||||
Performance::TimeOrigin()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public:
|
|||
|
||||
void ClearResourceTimings();
|
||||
|
||||
virtual DOMHighResTimeStamp Now() const = 0;
|
||||
DOMHighResTimeStamp Now() const;
|
||||
|
||||
DOMHighResTimeStamp TimeOrigin();
|
||||
|
||||
|
|
|
|||
|
|
@ -105,12 +105,6 @@ PerformanceMainThread::Navigation()
|
|||
return mNavigation;
|
||||
}
|
||||
|
||||
DOMHighResTimeStamp
|
||||
PerformanceMainThread::Now() const
|
||||
{
|
||||
return RoundTime(GetDOMTiming()->TimeStampToDOMHighRes(TimeStamp::Now()));
|
||||
}
|
||||
|
||||
/**
|
||||
* An entry should be added only after the resource is loaded.
|
||||
* This method is not thread safe and can only be called on the main thread.
|
||||
|
|
|
|||
|
|
@ -23,9 +23,6 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(PerformanceMainThread,
|
||||
Performance)
|
||||
|
||||
// Performance WebIDL methods
|
||||
DOMHighResTimeStamp Now() const override;
|
||||
|
||||
virtual PerformanceTiming* Timing() override;
|
||||
|
||||
virtual PerformanceNavigation* Navigation() override;
|
||||
|
|
|
|||
|
|
@ -23,14 +23,6 @@ PerformanceWorker::~PerformanceWorker()
|
|||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
}
|
||||
|
||||
DOMHighResTimeStamp
|
||||
PerformanceWorker::Now() const
|
||||
{
|
||||
TimeDuration duration =
|
||||
TimeStamp::Now() - mWorkerPrivate->NowBaseTimeStamp();
|
||||
return RoundTime(duration.ToMilliseconds());
|
||||
}
|
||||
|
||||
void
|
||||
PerformanceWorker::InsertUserEntry(PerformanceEntry* aEntry)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ class PerformanceWorker final : public Performance
|
|||
public:
|
||||
explicit PerformanceWorker(workers::WorkerPrivate* aWorkerPrivate);
|
||||
|
||||
// Performance WebIDL methods
|
||||
DOMHighResTimeStamp Now() const override;
|
||||
|
||||
virtual PerformanceTiming* Timing() override
|
||||
{
|
||||
MOZ_CRASH("This should not be called on workers.");
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ function testWorker() {
|
|||
{ type: "text/javascript" });
|
||||
var w = new Worker(URL.createObjectURL(blob));
|
||||
w.onmessage = function(e) {
|
||||
ok (e.data.now + e.data.timeOrigin > now + performance.timeOrigin, "Comparing worker.now and window.now");
|
||||
ok (e.now + e.timeOrigin > now + performance.now, "Comparing worker.now and window.now");
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ function testSharedWorker() {
|
|||
{ type: "text/javascript" });
|
||||
var w = new SharedWorker(URL.createObjectURL(blob));
|
||||
w.port.onmessage = function(e) {
|
||||
ok (e.data.now + e.data.timeOrigin > now + performance.timeOrigin, "Comparing worker.now and window.now");
|
||||
ok (e.now + e.timeOrigin > now + performance.now, "Comparing worker.now and window.now");
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue