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:
janekptacijarabaci 2018-04-29 12:26:49 +02:00 committed by Roy Tam
commit 94ea4f222c
7 changed files with 10 additions and 23 deletions

View file

@ -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()
{

View file

@ -68,7 +68,7 @@ public:
void ClearResourceTimings();
virtual DOMHighResTimeStamp Now() const = 0;
DOMHighResTimeStamp Now() const;
DOMHighResTimeStamp TimeOrigin();

View file

@ -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.

View file

@ -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;

View file

@ -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)
{

View file

@ -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.");

View file

@ -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();
}
}