summaryrefslogtreecommitdiffstats
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
commit85a83305dd0caeb484687cf511f81024a683338b (patch)
treee6c10fb27a6d102b15d10dca41023f0ec2af1b0f
parent30cf4c5d9356ddb7d474107af66a83826d403922 (diff)
downloadUXP-85a83305dd0caeb484687cf511f81024a683338b.tar
UXP-85a83305dd0caeb484687cf511f81024a683338b.tar.gz
UXP-85a83305dd0caeb484687cf511f81024a683338b.tar.lz
UXP-85a83305dd0caeb484687cf511f81024a683338b.tar.xz
UXP-85a83305dd0caeb484687cf511f81024a683338b.zip
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 d1547dc06..8f6a61c85 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 8495235a2..32c689c6e 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 d67c0c906..5eac15afd 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 fcaa6b903..c5f8887a4 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 db9d6aa6e..17820d434 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 89bfea3ed..346bdd026 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 73c5106f4..5a8a461f3 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();
}
}