OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 class WorkerInspectorController; | 59 class WorkerInspectorController; |
60 class WorkerLocation; | 60 class WorkerLocation; |
61 class WorkerNavigator; | 61 class WorkerNavigator; |
62 class WorkerThread; | 62 class WorkerThread; |
63 | 63 |
64 class CORE_EXPORT WorkerGlobalScope : public EventTargetWithInlineData, public R
efCountedWillBeNoBase<WorkerGlobalScope>, public SecurityContext, public Executi
onContext, public WillBeHeapSupplementable<WorkerGlobalScope>, public DOMWindowB
ase64 { | 64 class CORE_EXPORT WorkerGlobalScope : public EventTargetWithInlineData, public R
efCountedWillBeNoBase<WorkerGlobalScope>, public SecurityContext, public Executi
onContext, public WillBeHeapSupplementable<WorkerGlobalScope>, public DOMWindowB
ase64 { |
65 DEFINE_WRAPPERTYPEINFO(); | 65 DEFINE_WRAPPERTYPEINFO(); |
66 REFCOUNTED_EVENT_TARGET(WorkerGlobalScope); | 66 REFCOUNTED_EVENT_TARGET(WorkerGlobalScope); |
67 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WorkerGlobalScope); | 67 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WorkerGlobalScope); |
68 public: | 68 public: |
69 virtual ~WorkerGlobalScope(); | 69 ~WorkerGlobalScope() override; |
70 | 70 |
71 bool isWorkerGlobalScope() const override final { return true; } | 71 bool isWorkerGlobalScope() const final { return true; } |
72 | 72 |
73 ExecutionContext* executionContext() const override final; | 73 ExecutionContext* executionContext() const final; |
74 | 74 |
75 virtual void countFeature(UseCounter::Feature) const; | 75 virtual void countFeature(UseCounter::Feature) const; |
76 virtual void countDeprecation(UseCounter::Feature) const; | 76 virtual void countDeprecation(UseCounter::Feature) const; |
77 | 77 |
78 const KURL& url() const { return m_url; } | 78 const KURL& url() const { return m_url; } |
79 KURL completeURL(const String&) const; | 79 KURL completeURL(const String&) const; |
80 | 80 |
81 String userAgent(const KURL&) const override final; | 81 String userAgent(const KURL&) const final; |
82 void disableEval(const String& errorMessage) override final; | 82 void disableEval(const String& errorMessage) final; |
83 | 83 |
84 WorkerScriptController* script() { return m_script.get(); } | 84 WorkerScriptController* script() { return m_script.get(); } |
85 | 85 |
86 virtual void didEvaluateWorkerScript(); | 86 virtual void didEvaluateWorkerScript(); |
87 void dispose(); | 87 void dispose(); |
88 | 88 |
89 WorkerThread* thread() const { return m_thread; } | 89 WorkerThread* thread() const { return m_thread; } |
90 | 90 |
91 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>) ove
rride final; // Executes the task on context's thread asynchronously. | 91 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>) fin
al; // Executes the task on context's thread asynchronously. |
92 | 92 |
93 // WorkerGlobalScope | 93 // WorkerGlobalScope |
94 WorkerGlobalScope* self() { return this; } | 94 WorkerGlobalScope* self() { return this; } |
95 WorkerConsole* console(); | 95 WorkerConsole* console(); |
96 WorkerLocation* location() const; | 96 WorkerLocation* location() const; |
97 void close(); | 97 void close(); |
98 | 98 |
99 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 99 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
100 DEFINE_ATTRIBUTE_EVENT_LISTENER(rejectionhandled); | 100 DEFINE_ATTRIBUTE_EVENT_LISTENER(rejectionhandled); |
101 DEFINE_ATTRIBUTE_EVENT_LISTENER(unhandledrejection); | 101 DEFINE_ATTRIBUTE_EVENT_LISTENER(unhandledrejection); |
102 | 102 |
103 // WorkerUtils | 103 // WorkerUtils |
104 virtual void importScripts(const Vector<String>& urls, ExceptionState&); | 104 virtual void importScripts(const Vector<String>& urls, ExceptionState&); |
105 // Returns null if caching is not supported. | 105 // Returns null if caching is not supported. |
106 virtual PassOwnPtr<CachedMetadataHandler> createWorkerScriptCachedMetadataHa
ndler(const KURL& scriptURL, const Vector<char>* metaData) { return nullptr; } | 106 virtual PassOwnPtr<CachedMetadataHandler> createWorkerScriptCachedMetadataHa
ndler(const KURL& scriptURL, const Vector<char>* metaData) { return nullptr; } |
107 | 107 |
108 WorkerNavigator* navigator() const; | 108 WorkerNavigator* navigator() const; |
109 | 109 |
110 // ScriptWrappable | 110 // ScriptWrappable |
111 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte
xt) override final; | 111 v8::Local<v8::Object> wrap(v8::Isolate*, v8::Local<v8::Object> creationConte
xt) final; |
112 v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeIn
fo*, v8::Local<v8::Object> wrapper) override final; | 112 v8::Local<v8::Object> associateWithWrapper(v8::Isolate*, const WrapperTypeIn
fo*, v8::Local<v8::Object> wrapper) final; |
113 | 113 |
114 // ExecutionContextClient | 114 // ExecutionContextClient |
115 WorkerEventQueue* eventQueue() const override final; | 115 WorkerEventQueue* eventQueue() const final; |
116 SecurityContext& securityContext() override final { return *this; } | 116 SecurityContext& securityContext() final { return *this; } |
117 | 117 |
118 bool isContextThread() const override final; | 118 bool isContextThread() const final; |
119 bool isJSExecutionForbidden() const override final; | 119 bool isJSExecutionForbidden() const final; |
120 | 120 |
121 double timerAlignmentInterval() const override final; | 121 double timerAlignmentInterval() const final; |
122 DOMTimerCoordinator* timers() override final; | 122 DOMTimerCoordinator* timers() final; |
123 | 123 |
124 WorkerInspectorController* workerInspectorController() { return m_workerInsp
ectorController.get(); } | 124 WorkerInspectorController* workerInspectorController() { return m_workerInsp
ectorController.get(); } |
125 | 125 |
126 bool isClosing() { return m_closing; } | 126 bool isClosing() { return m_closing; } |
127 | 127 |
128 double timeOrigin() const { return m_timeOrigin; } | 128 double timeOrigin() const { return m_timeOrigin; } |
129 | 129 |
130 WorkerClients* clients() { return m_workerClients.get(); } | 130 WorkerClients* clients() { return m_workerClients.get(); } |
131 | 131 |
132 using SecurityContext::securityOrigin; | 132 using SecurityContext::securityOrigin; |
133 using SecurityContext::contentSecurityPolicy; | 133 using SecurityContext::contentSecurityPolicy; |
134 | 134 |
135 void addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) override fina
l; | 135 void addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) final; |
136 ConsoleMessageStorage* messageStorage(); | 136 ConsoleMessageStorage* messageStorage(); |
137 | 137 |
138 void exceptionHandled(int exceptionId, bool isHandled); | 138 void exceptionHandled(int exceptionId, bool isHandled); |
139 | 139 |
140 virtual void scriptLoaded(size_t scriptSize, size_t cachedMetadataSize) { } | 140 virtual void scriptLoaded(size_t scriptSize, size_t cachedMetadataSize) { } |
141 | 141 |
142 bool isPrivilegedContext(String& errorMessage, const PrivilegeContextCheck =
StandardPrivilegeCheck) const override; | 142 bool isPrivilegedContext(String& errorMessage, const PrivilegeContextCheck =
StandardPrivilegeCheck) const override; |
143 | 143 |
144 DECLARE_VIRTUAL_TRACE(); | 144 DECLARE_VIRTUAL_TRACE(); |
145 | 145 |
146 protected: | 146 protected: |
147 WorkerGlobalScope(const KURL&, const String& userAgent, WorkerThread*, doubl
e timeOrigin, const SecurityOrigin*, PassOwnPtrWillBeRawPtr<WorkerClients>); | 147 WorkerGlobalScope(const KURL&, const String& userAgent, WorkerThread*, doubl
e timeOrigin, const SecurityOrigin*, PassOwnPtrWillBeRawPtr<WorkerClients>); |
148 void applyContentSecurityPolicyFromVector(const Vector<CSPHeaderAndType>& he
aders); | 148 void applyContentSecurityPolicyFromVector(const Vector<CSPHeaderAndType>& he
aders); |
149 | 149 |
150 void logExceptionToConsole(const String& errorMessage, int scriptId, const S
tring& sourceURL, int lineNumber, int columnNumber, PassRefPtrWillBeRawPtr<Scrip
tCallStack>) override; | 150 void logExceptionToConsole(const String& errorMessage, int scriptId, const S
tring& sourceURL, int lineNumber, int columnNumber, PassRefPtrWillBeRawPtr<Scrip
tCallStack>) override; |
151 void addMessageToWorkerConsole(PassRefPtrWillBeRawPtr<ConsoleMessage>); | 151 void addMessageToWorkerConsole(PassRefPtrWillBeRawPtr<ConsoleMessage>); |
152 void setV8CacheOptions(V8CacheOptions v8CacheOptions) { m_v8CacheOptions = v
8CacheOptions; } | 152 void setV8CacheOptions(V8CacheOptions v8CacheOptions) { m_v8CacheOptions = v
8CacheOptions; } |
153 | 153 |
154 void removeURLFromMemoryCache(const KURL&) override; | 154 void removeURLFromMemoryCache(const KURL&) override; |
155 | 155 |
156 private: | 156 private: |
157 #if !ENABLE(OILPAN) | 157 #if !ENABLE(OILPAN) |
158 void refExecutionContext() override final { ref(); } | 158 void refExecutionContext() final { ref(); } |
159 void derefExecutionContext() override final { deref(); } | 159 void derefExecutionContext() final { deref(); } |
160 #endif | 160 #endif |
161 | 161 |
162 const KURL& virtualURL() const override final; | 162 const KURL& virtualURL() const final; |
163 KURL virtualCompleteURL(const String&) const override final; | 163 KURL virtualCompleteURL(const String&) const final; |
164 | 164 |
165 void reportBlockedScriptExecutionToInspector(const String& directiveText) ov
erride final; | 165 void reportBlockedScriptExecutionToInspector(const String& directiveText) fi
nal; |
166 | 166 |
167 EventTarget* errorEventTarget() override final; | 167 EventTarget* errorEventTarget() final; |
168 void didUpdateSecurityOrigin() override final { } | 168 void didUpdateSecurityOrigin() final { } |
169 | 169 |
170 void clearScript() { m_script.clear(); } | 170 void clearScript() { m_script.clear(); } |
171 void clearInspector(); | 171 void clearInspector(); |
172 | 172 |
173 static void removeURLFromMemoryCacheInternal(const KURL&); | 173 static void removeURLFromMemoryCacheInternal(const KURL&); |
174 | 174 |
175 KURL m_url; | 175 KURL m_url; |
176 String m_userAgent; | 176 String m_userAgent; |
177 V8CacheOptions m_v8CacheOptions; | 177 V8CacheOptions m_v8CacheOptions; |
178 | 178 |
(...skipping 21 matching lines...) Expand all Loading... |
200 | 200 |
201 unsigned long m_workerExceptionUniqueIdentifier; | 201 unsigned long m_workerExceptionUniqueIdentifier; |
202 WillBeHeapHashMap<unsigned long, RefPtrWillBeMember<ConsoleMessage>> m_pendi
ngMessages; | 202 WillBeHeapHashMap<unsigned long, RefPtrWillBeMember<ConsoleMessage>> m_pendi
ngMessages; |
203 }; | 203 }; |
204 | 204 |
205 DEFINE_TYPE_CASTS(WorkerGlobalScope, ExecutionContext, context, context->isWorke
rGlobalScope(), context.isWorkerGlobalScope()); | 205 DEFINE_TYPE_CASTS(WorkerGlobalScope, ExecutionContext, context, context->isWorke
rGlobalScope(), context.isWorkerGlobalScope()); |
206 | 206 |
207 } // namespace blink | 207 } // namespace blink |
208 | 208 |
209 #endif // WorkerGlobalScope_h | 209 #endif // WorkerGlobalScope_h |
OLD | NEW |