2016-11-06 11:54:29 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_WorkletGlobalScope_h
|
|
|
|
#define mozilla_dom_WorkletGlobalScope_h
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
2018-11-28 20:09:24 +03:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2016-11-06 11:55:41 +03:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2019-03-09 00:48:39 +03:00
|
|
|
#include "nsDOMNavigationTiming.h"
|
2016-11-06 11:54:29 +03:00
|
|
|
#include "nsIGlobalObject.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
|
2016-11-06 11:54:52 +03:00
|
|
|
#define WORKLET_IID \
|
2018-11-30 13:46:48 +03:00
|
|
|
{ \
|
2016-11-06 11:54:52 +03:00
|
|
|
0x1b3f62e7, 0xe357, 0x44be, { \
|
|
|
|
0xbf, 0xe0, 0xdf, 0x85, 0xe6, 0x56, 0x85, 0xac \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2016-11-06 11:54:29 +03:00
|
|
|
namespace mozilla {
|
2018-09-18 12:33:49 +03:00
|
|
|
|
|
|
|
class WorkletImpl;
|
|
|
|
|
2016-11-06 11:54:29 +03:00
|
|
|
namespace dom {
|
|
|
|
|
2016-11-06 11:54:52 +03:00
|
|
|
class Console;
|
|
|
|
|
2016-12-14 16:43:26 +03:00
|
|
|
class WorkletGlobalScope : public nsIGlobalObject, public nsWrapperCache {
|
2016-11-06 11:54:29 +03:00
|
|
|
public:
|
2016-11-06 11:54:52 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(WORKLET_IID)
|
|
|
|
|
2016-11-06 11:54:29 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WorkletGlobalScope)
|
|
|
|
|
2018-11-01 02:03:39 +03:00
|
|
|
WorkletGlobalScope();
|
2016-11-06 11:54:29 +03:00
|
|
|
|
|
|
|
nsIGlobalObject* GetParentObject() const { return nullptr; }
|
|
|
|
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
2018-04-12 06:14:48 +03:00
|
|
|
virtual bool WrapGlobalObject(JSContext* aCx,
|
|
|
|
JS::MutableHandle<JSObject*> aReflector) = 0;
|
2016-11-06 11:54:29 +03:00
|
|
|
|
2019-05-03 00:23:35 +03:00
|
|
|
JSObject* GetGlobalJSObject() override { return GetWrapper(); }
|
|
|
|
JSObject* GetGlobalJSObjectPreserveColor() const override {
|
|
|
|
return GetWrapperPreserveColor();
|
|
|
|
}
|
2016-11-06 11:54:29 +03:00
|
|
|
|
2018-02-22 10:49:51 +03:00
|
|
|
already_AddRefed<Console> GetConsole(JSContext* aCx, ErrorResult& aRv);
|
2016-11-06 11:54:52 +03:00
|
|
|
|
2018-11-01 02:03:39 +03:00
|
|
|
virtual WorkletImpl* Impl() const = 0;
|
2018-09-18 12:29:15 +03:00
|
|
|
|
2016-11-06 11:55:41 +03:00
|
|
|
void Dump(const Optional<nsAString>& aString) const;
|
|
|
|
|
2018-11-28 20:09:24 +03:00
|
|
|
DOMHighResTimeStamp TimeStampToDOMHighRes(const TimeStamp& aTimeStamp) const {
|
|
|
|
MOZ_ASSERT(!aTimeStamp.IsNull());
|
|
|
|
TimeDuration duration = aTimeStamp - mCreationTimeStamp;
|
|
|
|
return duration.ToMilliseconds();
|
|
|
|
}
|
|
|
|
|
2016-12-14 16:43:26 +03:00
|
|
|
protected:
|
2018-09-18 12:33:49 +03:00
|
|
|
~WorkletGlobalScope();
|
2018-11-30 13:46:48 +03:00
|
|
|
;
|
2016-11-06 11:54:52 +03:00
|
|
|
|
2016-12-14 16:43:26 +03:00
|
|
|
private:
|
2018-11-28 20:09:24 +03:00
|
|
|
TimeStamp mCreationTimeStamp;
|
2016-11-06 11:54:52 +03:00
|
|
|
RefPtr<Console> mConsole;
|
2016-11-06 11:54:29 +03:00
|
|
|
};
|
|
|
|
|
2016-11-06 11:54:52 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(WorkletGlobalScope, WORKLET_IID)
|
|
|
|
|
2016-11-06 11:54:29 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_WorkletGlobalScope_h
|