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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 #include "bindings/v8/ScriptWrappable.h" | 30 #include "bindings/v8/ScriptWrappable.h" |
31 #include "bindings/v8/WorkerScriptController.h" | 31 #include "bindings/v8/WorkerScriptController.h" |
32 #include "core/dom/ExecutionContext.h" | 32 #include "core/dom/ExecutionContext.h" |
33 #include "core/events/EventListener.h" | 33 #include "core/events/EventListener.h" |
34 #include "core/events/EventTarget.h" | 34 #include "core/events/EventTarget.h" |
35 #include "core/events/ThreadLocalEventNames.h" | 35 #include "core/events/ThreadLocalEventNames.h" |
36 #include "core/frame/csp/ContentSecurityPolicy.h" | 36 #include "core/frame/csp/ContentSecurityPolicy.h" |
37 #include "core/workers/WorkerConsole.h" | 37 #include "core/workers/WorkerConsole.h" |
38 #include "core/workers/WorkerEventQueue.h" | 38 #include "core/workers/WorkerEventQueue.h" |
39 #include "core/workers/WorkerSupplementable.h" | 39 #include "heap/Handle.h" |
40 #include "platform/network/ContentSecurityPolicyParsers.h" | 40 #include "platform/network/ContentSecurityPolicyParsers.h" |
41 #include "wtf/Assertions.h" | 41 #include "wtf/Assertions.h" |
42 #include "wtf/HashMap.h" | 42 #include "wtf/HashMap.h" |
43 #include "wtf/OwnPtr.h" | 43 #include "wtf/OwnPtr.h" |
44 #include "wtf/PassRefPtr.h" | 44 #include "wtf/PassRefPtr.h" |
45 #include "wtf/RefCounted.h" | 45 #include "wtf/RefCounted.h" |
46 #include "wtf/RefPtr.h" | 46 #include "wtf/RefPtr.h" |
47 #include "wtf/text/AtomicStringHash.h" | 47 #include "wtf/text/AtomicStringHash.h" |
48 | 48 |
49 namespace WebCore { | 49 namespace WebCore { |
50 | 50 |
51 class Blob; | 51 class Blob; |
52 class ExceptionState; | 52 class ExceptionState; |
53 class ScheduledAction; | 53 class ScheduledAction; |
54 class WorkerClients; | 54 class WorkerClients; |
55 class WorkerConsole; | 55 class WorkerConsole; |
56 class WorkerInspectorController; | 56 class WorkerInspectorController; |
57 class WorkerLocation; | 57 class WorkerLocation; |
58 class WorkerNavigator; | 58 class WorkerNavigator; |
59 class WorkerThread; | 59 class WorkerThread; |
60 | 60 |
61 class WorkerGlobalScope : public RefCounted<WorkerGlobalScope>, public Scrip
tWrappable, public SecurityContext, public ExecutionContext, public ExecutionCon
textClient, public WorkerSupplementable, public EventTargetWithInlineData { | 61 class WorkerGlobalScope : public RefCountedWillBeRefCountedGarbageCollected<
WorkerGlobalScope>, public ScriptWrappable, public SecurityContext, public Execu
tionContext, public ExecutionContextClient, public WillBeHeapSupplementable<Work
erGlobalScope>, public EventTargetWithInlineData { |
62 REFCOUNTED_EVENT_TARGET(WorkerGlobalScope); | 62 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollect
ed<WorkerGlobalScope>); |
63 public: | 63 public: |
64 virtual ~WorkerGlobalScope(); | 64 virtual ~WorkerGlobalScope(); |
65 | 65 |
66 virtual bool isWorkerGlobalScope() const OVERRIDE FINAL { return true; } | 66 virtual bool isWorkerGlobalScope() const OVERRIDE FINAL { return true; } |
67 | 67 |
68 virtual ExecutionContext* executionContext() const OVERRIDE FINAL; | 68 virtual ExecutionContext* executionContext() const OVERRIDE FINAL; |
69 | 69 |
70 virtual bool isSharedWorkerGlobalScope() const { return false; } | 70 virtual bool isSharedWorkerGlobalScope() const { return false; } |
71 virtual bool isDedicatedWorkerGlobalScope() const { return false; } | 71 virtual bool isDedicatedWorkerGlobalScope() const { return false; } |
72 virtual bool isServiceWorkerGlobalScope() const { return false; } | 72 virtual bool isServiceWorkerGlobalScope() const { return false; } |
73 | 73 |
74 const KURL& url() const { return m_url; } | 74 const KURL& url() const { return m_url; } |
75 KURL completeURL(const String&) const; | 75 KURL completeURL(const String&) const; |
76 | 76 |
77 virtual String userAgent(const KURL&) const OVERRIDE FINAL; | 77 virtual String userAgent(const KURL&) const OVERRIDE FINAL; |
78 virtual void disableEval(const String& errorMessage) OVERRIDE FINAL; | 78 virtual void disableEval(const String& errorMessage) OVERRIDE FINAL; |
79 | 79 |
80 WorkerScriptController* script() { return m_script.get(); } | 80 WorkerScriptController* script() { return m_script.get(); } |
81 void clearScript() { m_script.clear(); } | 81 void clearScript() { m_script.clear(); } |
82 void clearInspector(); | 82 void clearInspector(); |
83 | 83 |
| 84 void dispose(); |
| 85 |
84 WorkerThread* thread() const { return m_thread; } | 86 WorkerThread* thread() const { return m_thread; } |
85 | 87 |
86 virtual void postTask(PassOwnPtr<ExecutionContextTask>) OVERRIDE FINAL;
// Executes the task on context's thread asynchronously. | 88 virtual void postTask(PassOwnPtr<ExecutionContextTask>) OVERRIDE FINAL;
// Executes the task on context's thread asynchronously. |
87 | 89 |
88 // WorkerGlobalScope | 90 // WorkerGlobalScope |
89 WorkerGlobalScope* self() { return this; } | 91 WorkerGlobalScope* self() { return this; } |
90 WorkerConsole* console(); | 92 WorkerConsole* console(); |
91 WorkerLocation* location() const; | 93 WorkerLocation* location() const; |
92 void close(); | 94 void close(); |
93 | 95 |
(...skipping 23 matching lines...) Expand all Loading... |
117 | 119 |
118 bool idleNotification(); | 120 bool idleNotification(); |
119 | 121 |
120 double timeOrigin() const { return m_timeOrigin; } | 122 double timeOrigin() const { return m_timeOrigin; } |
121 | 123 |
122 WorkerClients* clients() { return m_workerClients.get(); } | 124 WorkerClients* clients() { return m_workerClients.get(); } |
123 | 125 |
124 using SecurityContext::securityOrigin; | 126 using SecurityContext::securityOrigin; |
125 using SecurityContext::contentSecurityPolicy; | 127 using SecurityContext::contentSecurityPolicy; |
126 | 128 |
| 129 virtual void trace(Visitor*); |
| 130 |
127 protected: | 131 protected: |
128 WorkerGlobalScope(const KURL&, const String& userAgent, WorkerThread*, d
ouble timeOrigin, PassOwnPtr<WorkerClients>); | 132 WorkerGlobalScope(const KURL&, const String& userAgent, WorkerThread*, d
ouble timeOrigin, PassOwnPtr<WorkerClients>); |
129 void applyContentSecurityPolicyFromString(const String& contentSecurityP
olicy, ContentSecurityPolicyHeaderType); | 133 void applyContentSecurityPolicyFromString(const String& contentSecurityP
olicy, ContentSecurityPolicyHeaderType); |
130 | 134 |
131 virtual void logExceptionToConsole(const String& errorMessage, const Str
ing& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) O
VERRIDE; | 135 virtual void logExceptionToConsole(const String& errorMessage, const Str
ing& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallStack>) O
VERRIDE; |
132 void addMessageToWorkerConsole(MessageSource, MessageLevel, const String
& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallSt
ack>, ScriptState*); | 136 void addMessageToWorkerConsole(MessageSource, MessageLevel, const String
& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallSt
ack>, ScriptState*); |
133 | 137 |
134 private: | 138 private: |
135 virtual void refExecutionContext() OVERRIDE FINAL { ref(); } | 139 virtual void refExecutionContext() OVERRIDE FINAL { ref(); } |
136 virtual void derefExecutionContext() OVERRIDE FINAL { deref(); } | 140 virtual void derefExecutionContext() OVERRIDE FINAL { deref(); } |
137 | 141 |
138 virtual const KURL& virtualURL() const OVERRIDE FINAL; | 142 virtual const KURL& virtualURL() const OVERRIDE FINAL; |
139 virtual KURL virtualCompleteURL(const String&) const OVERRIDE FINAL; | 143 virtual KURL virtualCompleteURL(const String&) const OVERRIDE FINAL; |
140 | 144 |
141 virtual void reportBlockedScriptExecutionToInspector(const String& direc
tiveText) OVERRIDE FINAL; | 145 virtual void reportBlockedScriptExecutionToInspector(const String& direc
tiveText) OVERRIDE FINAL; |
142 virtual void addMessage(MessageSource, MessageLevel, const String& messa
ge, const String& sourceURL, unsigned lineNumber, ScriptState* = 0) OVERRIDE FIN
AL; | 146 virtual void addMessage(MessageSource, MessageLevel, const String& messa
ge, const String& sourceURL, unsigned lineNumber, ScriptState* = 0) OVERRIDE FIN
AL; |
143 | 147 |
144 virtual EventTarget* errorEventTarget() OVERRIDE FINAL; | 148 virtual EventTarget* errorEventTarget() OVERRIDE FINAL; |
145 virtual void didUpdateSecurityOrigin() OVERRIDE FINAL { } | 149 virtual void didUpdateSecurityOrigin() OVERRIDE FINAL { } |
146 | 150 |
147 KURL m_url; | 151 KURL m_url; |
148 String m_userAgent; | 152 String m_userAgent; |
149 | 153 |
150 mutable RefPtr<WorkerConsole> m_console; | 154 mutable RefPtrWillBeMember<WorkerConsole> m_console; |
151 mutable RefPtr<WorkerLocation> m_location; | 155 mutable RefPtrWillBeMember<WorkerLocation> m_location; |
152 mutable RefPtr<WorkerNavigator> m_navigator; | 156 mutable RefPtrWillBeMember<WorkerNavigator> m_navigator; |
153 | 157 |
154 OwnPtr<WorkerScriptController> m_script; | 158 OwnPtr<WorkerScriptController> m_script; |
155 WorkerThread* m_thread; | 159 WorkerThread* m_thread; |
156 | 160 |
157 OwnPtr<WorkerInspectorController> m_workerInspectorController; | 161 OwnPtr<WorkerInspectorController> m_workerInspectorController; |
158 bool m_closing; | 162 bool m_closing; |
159 | 163 |
160 OwnPtr<WorkerEventQueue> m_eventQueue; | 164 OwnPtr<WorkerEventQueue> m_eventQueue; |
161 | 165 |
162 OwnPtr<WorkerClients> m_workerClients; | 166 OwnPtr<WorkerClients> m_workerClients; |
163 | 167 |
164 double m_timeOrigin; | 168 double m_timeOrigin; |
165 }; | 169 }; |
166 | 170 |
167 DEFINE_TYPE_CASTS(WorkerGlobalScope, ExecutionContext, context, context->isWorke
rGlobalScope(), context.isWorkerGlobalScope()); | 171 DEFINE_TYPE_CASTS(WorkerGlobalScope, ExecutionContext, context, context->isWorke
rGlobalScope(), context.isWorkerGlobalScope()); |
168 | 172 |
169 } // namespace WebCore | 173 } // namespace WebCore |
170 | 174 |
171 #endif // WorkerGlobalScope_h | 175 #endif // WorkerGlobalScope_h |
OLD | NEW |