summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-29 12:26:49 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-29 12:26:49 +0200
commit4cc7ba03de09708af9a808ccdc7ada5e8b4536c7 (patch)
treee6c10fb27a6d102b15d10dca41023f0ec2af1b0f
parent4f230aa917be964e753e903acb616ec0ab97653c (diff)
downloaduxp-4cc7ba03de09708af9a808ccdc7ada5e8b4536c7.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
-rwxr-xr-xdom/performance/Performance.cpp7
-rw-r--r--dom/performance/Performance.h2
-rw-r--r--dom/performance/PerformanceMainThread.cpp6
-rw-r--r--dom/performance/PerformanceMainThread.h3
-rw-r--r--dom/performance/PerformanceWorker.cpp8
-rw-r--r--dom/performance/PerformanceWorker.h3
-rw-r--r--dom/performance/tests/test_timeOrigin.html4
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();
}
}