Bug 1476514 move TimeStampToDOMHighRes() from WorkletThread to WorkletGlobalScope r=baku

Differential Revision: https://phabricator.services.mozilla.com/D13210

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Karl Tomlinson 2018-11-28 17:09:24 +00:00
Родитель 548cd8f122
Коммит 9db064fcec
5 изменённых файлов: 13 добавлений и 14 удалений

Просмотреть файл

@ -2931,8 +2931,8 @@ Console::MonotonicTimer(JSContext* aCx, MethodName aMethodName,
return true;
}
if (WorkletThread::IsOnWorkletThread()) {
*aTimeStamp = WorkletThread::Get()->TimeStampToDOMHighRes(TimeStamp::Now());
if (nsCOMPtr<WorkletGlobalScope> workletGlobal = do_QueryInterface(mGlobal)) {
*aTimeStamp = workletGlobal->TimeStampToDOMHighRes(TimeStamp::Now());
return true;
}

Просмотреть файл

@ -37,6 +37,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WorkletGlobalScope)
NS_INTERFACE_MAP_END
WorkletGlobalScope::WorkletGlobalScope()
: mCreationTimeStamp(TimeStamp::Now())
{
}

Просмотреть файл

@ -9,6 +9,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "nsIGlobalObject.h"
#include "nsWrapperCache.h"
@ -61,10 +62,19 @@ public:
void
Dump(const Optional<nsAString>& aString) const;
DOMHighResTimeStamp
TimeStampToDOMHighRes(const TimeStamp& aTimeStamp) const
{
MOZ_ASSERT(!aTimeStamp.IsNull());
TimeDuration duration = aTimeStamp - mCreationTimeStamp;
return duration.ToMilliseconds();
}
protected:
~WorkletGlobalScope();;
private:
TimeStamp mCreationTimeStamp;
RefPtr<Console> mConsole;
};

Просмотреть файл

@ -263,7 +263,6 @@ WorkletThread::WorkletThread()
: nsThread(MakeNotNull<ThreadEventQueue<mozilla::EventQueue>*>(
MakeUnique<mozilla::EventQueue>()),
nsThread::NOT_MAIN_THREAD, kWorkletStackSize)
, mCreationTimeStamp(TimeStamp::Now())
, mJSContext(nullptr)
, mIsTerminating(false)
{

Просмотреть файл

@ -11,7 +11,6 @@
#include "mozilla/CondVar.h"
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/TimeStamp.h"
#include "nsThread.h"
class nsIRunnable;
@ -45,14 +44,6 @@ public:
void
Terminate();
DOMHighResTimeStamp
TimeStampToDOMHighRes(const TimeStamp& aTimeStamp) const
{
MOZ_ASSERT(!aTimeStamp.IsNull());
TimeDuration duration = aTimeStamp - mCreationTimeStamp;
return duration.ToMilliseconds();
}
private:
WorkletThread();
~WorkletThread();
@ -76,8 +67,6 @@ private:
NS_IMETHOD
DelayedDispatch(already_AddRefed<nsIRunnable>, uint32_t) override;
TimeStamp mCreationTimeStamp;
// Touched only on the worklet thread. This is a raw pointer because it's set
// and nullified by RunEventLoop().
JSContext* mJSContext;