Skip to content

Commit cc67a9b

Browse files
committed
Add a type method to ScriptFetcher
This is to enable checking ScriptFetcher type without RTTI.
1 parent 3db0635 commit cc67a9b

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

Source/JavaScriptCore/runtime/ScriptFetcher.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,17 @@ namespace JSC {
3131

3232
class ScriptFetcher : public RefCounted<ScriptFetcher> {
3333
public:
34-
virtual ~ScriptFetcher() { }
34+
enum class Type: uint8_t {
35+
Cached,
36+
Worker,
37+
#if USE(BUN_JSC_ADDITIONS)
38+
NodeVM,
39+
#endif
40+
};
41+
42+
virtual ~ScriptFetcher() = default;
43+
44+
virtual Type type() const = 0;
3545
};
3646

3747
} // namespace JSC

Source/WebCore/bindings/js/CachedScriptFetcher.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class CachedScriptFetcher : public JSC::ScriptFetcher {
4444

4545
static Ref<CachedScriptFetcher> create(const AtomString& charset);
4646

47+
Type type() const final { return Type::Cached; }
48+
4749
protected:
4850
CachedScriptFetcher(const String& nonce, ReferrerPolicy referrerPolicy, RequestPriority fetchPriority, const AtomString& charset, const AtomString& initiatorType, bool isInUserAgentShadowTree)
4951
: m_nonce(nonce)

Source/WebCore/bindings/js/WorkerScriptFetcher.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class WorkerScriptFetcher final : public JSC::ScriptFetcher {
4444
return adoptRef(*new WorkerScriptFetcher(WTFMove(parameters), credentials, destination, referrerPolicy));
4545
}
4646

47+
Type type() const final { return Type::Worker; }
48+
4749
FetchOptions::Credentials credentials() const { return m_credentials; }
4850
FetchOptions::Destination destination() const { return m_destination; }
4951
ReferrerPolicy referrerPolicy() const { return m_referrerPolicy; }

0 commit comments

Comments
 (0)