1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "Performance.h"
6 #include "mozilla/dom/PerformanceBinding.h"
8 #include "WorkerPrivate.h"
10 BEGIN_WORKERS_NAMESPACE
12 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(Performance
, AddRef
)
13 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(Performance
, Release
)
15 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(Performance
)
17 Performance::Performance(WorkerPrivate
* aWorkerPrivate
)
18 : mWorkerPrivate(aWorkerPrivate
)
20 mWorkerPrivate
->AssertIsOnWorkerThread();
23 Performance::~Performance()
25 mWorkerPrivate
->AssertIsOnWorkerThread();
29 Performance::WrapObject(JSContext
* aCx
)
31 return PerformanceBinding_workers::Wrap(aCx
, this);
35 Performance::Now() const
37 TimeDuration duration
=
38 TimeStamp::Now() - mWorkerPrivate
->NowBaseTimeStamp();
39 return duration
.ToMilliseconds();