OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 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 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 * | 24 * |
25 */ | 25 */ |
26 | 26 |
27 #ifndef WorkerMessagingProxy_h | 27 #ifndef WorkerMessagingProxy_h |
28 #define WorkerMessagingProxy_h | 28 #define WorkerMessagingProxy_h |
29 | 29 |
30 #include "core/dom/ScriptExecutionContext.h" | 30 #include "core/dom/ScriptExecutionContext.h" |
31 #include "core/workers/WorkerContextProxy.h" | 31 #include "core/workers/WorkerGlobalScopeProxy.h" |
32 #include "core/workers/WorkerLoaderProxy.h" | 32 #include "core/workers/WorkerLoaderProxy.h" |
33 #include "core/workers/WorkerObjectProxy.h" | 33 #include "core/workers/WorkerObjectProxy.h" |
34 #include <wtf/Forward.h> | 34 #include <wtf/Forward.h> |
35 #include <wtf/Noncopyable.h> | 35 #include <wtf/Noncopyable.h> |
36 #include <wtf/PassOwnPtr.h> | 36 #include <wtf/PassOwnPtr.h> |
37 #include <wtf/PassRefPtr.h> | 37 #include <wtf/PassRefPtr.h> |
38 #include <wtf/RefPtr.h> | 38 #include <wtf/RefPtr.h> |
39 #include <wtf/Vector.h> | 39 #include <wtf/Vector.h> |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 class DedicatedWorkerThread; | 43 class DedicatedWorkerThread; |
44 class ScriptExecutionContext; | 44 class ScriptExecutionContext; |
45 class Worker; | 45 class Worker; |
46 | 46 |
47 class WorkerMessagingProxy : public WorkerContextProxy, public WorkerObjectP
roxy, public WorkerLoaderProxy { | 47 class WorkerMessagingProxy : public WorkerGlobalScopeProxy, public WorkerObj
ectProxy, public WorkerLoaderProxy { |
48 WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy); WTF_MAKE_FAST_ALLOCATED; | 48 WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy); WTF_MAKE_FAST_ALLOCATED; |
49 public: | 49 public: |
50 explicit WorkerMessagingProxy(Worker*); | 50 explicit WorkerMessagingProxy(Worker*); |
51 | 51 |
52 // Implementations of WorkerContextProxy. | 52 // Implementations of WorkerGlobalScopeProxy. |
53 // (Only use these methods in the worker object thread.) | 53 // (Only use these methods in the worker object thread.) |
54 virtual void startWorkerContext(const KURL& scriptURL, const String& use
rAgent, const String& sourceCode, WorkerThreadStartMode) OVERRIDE; | 54 virtual void startWorkerGlobalScope(const KURL& scriptURL, const String&
userAgent, const String& sourceCode, WorkerThreadStartMode) OVERRIDE; |
55 virtual void terminateWorkerContext() OVERRIDE; | 55 virtual void terminateWorkerGlobalScope() OVERRIDE; |
56 virtual void postMessageToWorkerContext(PassRefPtr<SerializedScriptValue
>, PassOwnPtr<MessagePortChannelArray>) OVERRIDE; | 56 virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptV
alue>, PassOwnPtr<MessagePortChannelArray>) OVERRIDE; |
57 virtual bool hasPendingActivity() const OVERRIDE; | 57 virtual bool hasPendingActivity() const OVERRIDE; |
58 virtual void workerObjectDestroyed() OVERRIDE; | 58 virtual void workerObjectDestroyed() OVERRIDE; |
59 virtual void connectToInspector(WorkerContextProxy::PageInspector*) OVER
RIDE; | 59 virtual void connectToInspector(WorkerGlobalScopeProxy::PageInspector*)
OVERRIDE; |
60 virtual void disconnectFromInspector() OVERRIDE; | 60 virtual void disconnectFromInspector() OVERRIDE; |
61 virtual void sendMessageToInspector(const String&) OVERRIDE; | 61 virtual void sendMessageToInspector(const String&) OVERRIDE; |
62 | 62 |
63 // Implementations of WorkerObjectProxy. | 63 // Implementations of WorkerObjectProxy. |
64 // (Only use these methods in the worker context thread.) | 64 // (Only use these methods in the worker context thread.) |
65 virtual void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>
, PassOwnPtr<MessagePortChannelArray>) OVERRIDE; | 65 virtual void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>
, PassOwnPtr<MessagePortChannelArray>) OVERRIDE; |
66 virtual void postExceptionToWorkerObject(const String& errorMessage, int
lineNumber, const String& sourceURL) OVERRIDE; | 66 virtual void postExceptionToWorkerObject(const String& errorMessage, int
lineNumber, const String& sourceURL) OVERRIDE; |
67 virtual void postConsoleMessageToWorkerObject(MessageSource, MessageLeve
l, const String& message, int lineNumber, const String& sourceURL) OVERRIDE; | 67 virtual void postConsoleMessageToWorkerObject(MessageSource, MessageLeve
l, const String& message, int lineNumber, const String& sourceURL) OVERRIDE; |
68 virtual void postMessageToPageInspector(const String&) OVERRIDE; | 68 virtual void postMessageToPageInspector(const String&) OVERRIDE; |
69 virtual void updateInspectorStateCookie(const String&) OVERRIDE; | 69 virtual void updateInspectorStateCookie(const String&) OVERRIDE; |
70 virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) OVE
RRIDE; | 70 virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) OVE
RRIDE; |
71 virtual void reportPendingActivity(bool hasPendingActivity) OVERRIDE; | 71 virtual void reportPendingActivity(bool hasPendingActivity) OVERRIDE; |
72 virtual void workerContextClosed() OVERRIDE; | 72 virtual void workerGlobalScopeClosed() OVERRIDE; |
73 virtual void workerContextDestroyed() OVERRIDE; | 73 virtual void workerGlobalScopeDestroyed() OVERRIDE; |
74 | 74 |
75 // Implementation of WorkerLoaderProxy. | 75 // Implementation of WorkerLoaderProxy. |
76 // These methods are called on different threads to schedule loading | 76 // These methods are called on different threads to schedule loading |
77 // requests and to send callbacks back to WorkerContext. | 77 // requests and to send callbacks back to WorkerGlobalScope. |
78 virtual void postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Task>)
OVERRIDE; | 78 virtual void postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Task>)
OVERRIDE; |
79 virtual bool postTaskForModeToWorkerContext(PassOwnPtr<ScriptExecutionCo
ntext::Task>, const String& mode) OVERRIDE; | 79 virtual bool postTaskForModeToWorkerGlobalScope(PassOwnPtr<ScriptExecuti
onContext::Task>, const String& mode) OVERRIDE; |
80 | 80 |
81 void workerThreadCreated(PassRefPtr<DedicatedWorkerThread>); | 81 void workerThreadCreated(PassRefPtr<DedicatedWorkerThread>); |
82 | 82 |
83 // Only use this method on the worker object thread. | 83 // Only use this method on the worker object thread. |
84 bool askedToTerminate() const { return m_askedToTerminate; } | 84 bool askedToTerminate() const { return m_askedToTerminate; } |
85 | 85 |
86 protected: | 86 protected: |
87 virtual ~WorkerMessagingProxy(); | 87 virtual ~WorkerMessagingProxy(); |
88 | 88 |
89 private: | 89 private: |
90 friend class MessageWorkerTask; | 90 friend class MessageWorkerTask; |
91 friend class PostMessageToPageInspectorTask; | 91 friend class PostMessageToPageInspectorTask; |
92 friend class WorkerContextDestroyedTask; | 92 friend class WorkerGlobalScopeDestroyedTask; |
93 friend class WorkerExceptionTask; | 93 friend class WorkerExceptionTask; |
94 friend class WorkerThreadActivityReportTask; | 94 friend class WorkerThreadActivityReportTask; |
95 | 95 |
96 void workerContextDestroyedInternal(); | 96 void workerGlobalScopeDestroyedInternal(); |
97 static void workerObjectDestroyedInternal(ScriptExecutionContext*, Worke
rMessagingProxy*); | 97 static void workerObjectDestroyedInternal(ScriptExecutionContext*, Worke
rMessagingProxy*); |
98 void reportPendingActivityInternal(bool confirmingMessage, bool hasPendi
ngActivity); | 98 void reportPendingActivityInternal(bool confirmingMessage, bool hasPendi
ngActivity); |
99 Worker* workerObject() const { return m_workerObject; } | 99 Worker* workerObject() const { return m_workerObject; } |
100 | 100 |
101 RefPtr<ScriptExecutionContext> m_scriptExecutionContext; | 101 RefPtr<ScriptExecutionContext> m_scriptExecutionContext; |
102 Worker* m_workerObject; | 102 Worker* m_workerObject; |
103 bool m_mayBeDestroyed; | 103 bool m_mayBeDestroyed; |
104 RefPtr<DedicatedWorkerThread> m_workerThread; | 104 RefPtr<DedicatedWorkerThread> m_workerThread; |
105 | 105 |
106 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker
object to worker thread. | 106 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker
object to worker thread. |
107 bool m_workerThreadHadPendingActivity; // The latest confirmation from w
orker thread reported that it was still active. | 107 bool m_workerThreadHadPendingActivity; // The latest confirmation from w
orker thread reported that it was still active. |
108 | 108 |
109 bool m_askedToTerminate; | 109 bool m_askedToTerminate; |
110 | 110 |
111 Vector<OwnPtr<ScriptExecutionContext::Task> > m_queuedEarlyTasks; // Tas
ks are queued here until there's a thread object created. | 111 Vector<OwnPtr<ScriptExecutionContext::Task> > m_queuedEarlyTasks; // Tas
ks are queued here until there's a thread object created. |
112 WorkerContextProxy::PageInspector* m_pageInspector; | 112 WorkerGlobalScopeProxy::PageInspector* m_pageInspector; |
113 }; | 113 }; |
114 | 114 |
115 } // namespace WebCore | 115 } // namespace WebCore |
116 | 116 |
117 #endif // WorkerMessagingProxy_h | 117 #endif // WorkerMessagingProxy_h |
OLD | NEW |