diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-04-29 12:26:49 +0200 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-04-29 12:26:49 +0200 |
commit | 85a83305dd0caeb484687cf511f81024a683338b (patch) | |
tree | e6c10fb27a6d102b15d10dca41023f0ec2af1b0f /dom/performance | |
parent | 30cf4c5d9356ddb7d474107af66a83826d403922 (diff) | |
download | uxp-85a83305dd0caeb484687cf511f81024a683338b.tar.gz |
Bug 1322292 - Some fixes for the Performance API in workers - part 1 - Centralized Performance.now()
https://hg.mozilla.org/mozilla-central/rev/291a68ca4825
Diffstat (limited to 'dom/performance')
-rwxr-xr-x | dom/performance/Performance.cpp | 7 | ||||
-rw-r--r-- | dom/performance/Performance.h | 2 | ||||
-rw-r--r-- | dom/performance/PerformanceMainThread.cpp | 6 | ||||
-rw-r--r-- | dom/performance/PerformanceMainThread.h | 3 | ||||
-rw-r--r-- | dom/performance/PerformanceWorker.cpp | 8 | ||||
-rw-r--r-- | dom/performance/PerformanceWorker.h | 3 | ||||
-rw-r--r-- | dom/performance/tests/test_timeOrigin.html | 4 |
7 files changed, 10 insertions, 23 deletions
diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp index d1547dc065..8f6a61c85c 100755 --- a/dom/performance/Performance.cpp +++ b/dom/performance/Performance.cpp @@ -121,6 +121,13 @@ Performance::~Performance() {} DOMHighResTimeStamp +Performance::Now() const +{ + TimeDuration duration = TimeStamp::Now() - CreationTimeStamp(); + return RoundTime(duration.ToMilliseconds()); +} + +DOMHighResTimeStamp Performance::TimeOrigin() { if (!mPerformanceService) { diff --git a/dom/performance/Performance.h b/dom/performance/Performance.h index 8495235a28..32c689c6e3 100644 --- a/dom/performance/Performance.h +++ b/dom/performance/Performance.h @@ -68,7 +68,7 @@ public: void ClearResourceTimings(); - virtual DOMHighResTimeStamp Now() const = 0; + DOMHighResTimeStamp Now() const; DOMHighResTimeStamp TimeOrigin(); diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp index d67c0c906e..5eac15afdb 100644 --- a/dom/performance/PerformanceMainThread.cpp +++ b/dom/performance/PerformanceMainThread.cpp @@ -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. diff --git a/dom/performance/PerformanceMainThread.h b/dom/performance/PerformanceMainThread.h index fcaa6b9033..c5f8887a40 100644 --- a/dom/performance/PerformanceMainThread.h +++ b/dom/performance/PerformanceMainThread.h @@ -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; diff --git a/dom/performance/PerformanceWorker.cpp b/dom/performance/PerformanceWorker.cpp index db9d6aa6e9..17820d4347 100644 --- a/dom/performance/PerformanceWorker.cpp +++ b/dom/performance/PerformanceWorker.cpp @@ -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) { diff --git a/dom/performance/PerformanceWorker.h b/dom/performance/PerformanceWorker.h index 89bfea3edb..346bdd0260 100644 --- a/dom/performance/PerformanceWorker.h +++ b/dom/performance/PerformanceWorker.h @@ -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."); diff --git a/dom/performance/tests/test_timeOrigin.html b/dom/performance/tests/test_timeOrigin.html index 73c5106f4b..5a8a461f30 100644 --- a/dom/performance/tests/test_timeOrigin.html +++ b/dom/performance/tests/test_timeOrigin.html @@ -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(); } } |