| 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 21 matching lines...) Expand all Loading... |
| 32 #include "core/workers/WorkerLoaderProxy.h" | 32 #include "core/workers/WorkerLoaderProxy.h" |
| 33 #include "wtf/Forward.h" | 33 #include "wtf/Forward.h" |
| 34 #include "wtf/Noncopyable.h" | 34 #include "wtf/Noncopyable.h" |
| 35 #include "wtf/PassOwnPtr.h" | 35 #include "wtf/PassOwnPtr.h" |
| 36 #include "wtf/PassRefPtr.h" | 36 #include "wtf/PassRefPtr.h" |
| 37 #include "wtf/RefPtr.h" | 37 #include "wtf/RefPtr.h" |
| 38 #include "wtf/Vector.h" | 38 #include "wtf/Vector.h" |
| 39 | 39 |
| 40 namespace WebCore { | 40 namespace WebCore { |
| 41 | 41 |
| 42 class WorkerObjectProxy; | 42 class WorkerObjectProxy; |
| 43 class DedicatedWorkerThread; | 43 class DedicatedWorkerThread; |
| 44 class ExecutionContext; | 44 class ExecutionContext; |
| 45 class Worker; | 45 class Worker; |
| 46 class WorkerClients; | 46 class WorkerClients; |
| 47 | 47 |
| 48 class WorkerMessagingProxy FINAL : public WorkerGlobalScopeProxy, public Wor
kerLoaderProxy { | 48 class WorkerMessagingProxy FINAL : public WorkerGlobalScopeProxy, public WorkerL
oaderProxy { |
| 49 WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy); WTF_MAKE_FAST_ALLOCATED; | 49 WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy); WTF_MAKE_FAST_ALLOCATED; |
| 50 public: | 50 public: |
| 51 WorkerMessagingProxy(Worker*, PassOwnPtrWillBeRawPtr<WorkerClients>); | 51 WorkerMessagingProxy(Worker*, PassOwnPtrWillBeRawPtr<WorkerClients>); |
| 52 | 52 |
| 53 // Implementations of WorkerGlobalScopeProxy. | 53 // Implementations of WorkerGlobalScopeProxy. |
| 54 // (Only use these methods in the worker object thread.) | 54 // (Only use these methods in the worker object thread.) |
| 55 virtual void startWorkerGlobalScope(const KURL& scriptURL, const String&
userAgent, const String& sourceCode, WorkerThreadStartMode) OVERRIDE; | 55 virtual void startWorkerGlobalScope(const KURL& scriptURL, const String& use
rAgent, const String& sourceCode, WorkerThreadStartMode) OVERRIDE; |
| 56 virtual void terminateWorkerGlobalScope() OVERRIDE; | 56 virtual void terminateWorkerGlobalScope() OVERRIDE; |
| 57 virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptV
alue>, PassOwnPtr<MessagePortChannelArray>) OVERRIDE; | 57 virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue
>, PassOwnPtr<MessagePortChannelArray>) OVERRIDE; |
| 58 virtual bool hasPendingActivity() const OVERRIDE; | 58 virtual bool hasPendingActivity() const OVERRIDE; |
| 59 virtual void workerObjectDestroyed() OVERRIDE; | 59 virtual void workerObjectDestroyed() OVERRIDE; |
| 60 virtual void connectToInspector(WorkerGlobalScopeProxy::PageInspector*)
OVERRIDE; | 60 virtual void connectToInspector(WorkerGlobalScopeProxy::PageInspector*) OVER
RIDE; |
| 61 virtual void disconnectFromInspector() OVERRIDE; | 61 virtual void disconnectFromInspector() OVERRIDE; |
| 62 virtual void sendMessageToInspector(const String&) OVERRIDE; | 62 virtual void sendMessageToInspector(const String&) OVERRIDE; |
| 63 | 63 |
| 64 // These methods come from worker context thread via WorkerObjectProxy | 64 // These methods come from worker context thread via WorkerObjectProxy |
| 65 // and are called on the worker object thread (e.g. main thread). | 65 // and are called on the worker object thread (e.g. main thread). |
| 66 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOw
nPtr<MessagePortChannelArray>); | 66 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr
<MessagePortChannelArray>); |
| 67 void reportException(const String& errorMessage, int lineNumber, int col
umnNumber, const String& sourceURL); | 67 void reportException(const String& errorMessage, int lineNumber, int columnN
umber, const String& sourceURL); |
| 68 void reportConsoleMessage(MessageSource, MessageLevel, const String& mes
sage, int lineNumber, const String& sourceURL); | 68 void reportConsoleMessage(MessageSource, MessageLevel, const String& message
, int lineNumber, const String& sourceURL); |
| 69 void postMessageToPageInspector(const String&); | 69 void postMessageToPageInspector(const String&); |
| 70 void confirmMessageFromWorkerObject(bool hasPendingActivity); | 70 void confirmMessageFromWorkerObject(bool hasPendingActivity); |
| 71 void reportPendingActivity(bool hasPendingActivity); | 71 void reportPendingActivity(bool hasPendingActivity); |
| 72 void workerGlobalScopeClosed(); | 72 void workerGlobalScopeClosed(); |
| 73 void workerGlobalScopeDestroyed(); | 73 void workerGlobalScopeDestroyed(); |
| 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 WorkerGlobalScope. | 77 // requests and to send callbacks back to WorkerGlobalScope. |
| 78 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) OVERRIDE
; | 78 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) OVERRIDE; |
| 79 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask
>) OVERRIDE; | 79 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) O
VERRIDE; |
| 80 | 80 |
| 81 void workerThreadCreated(PassRefPtr<DedicatedWorkerThread>); | 81 void workerThreadCreated(PassRefPtr<DedicatedWorkerThread>); |
| 82 | 82 |
| 83 protected: | 83 protected: |
| 84 virtual ~WorkerMessagingProxy(); | 84 virtual ~WorkerMessagingProxy(); |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 static void workerObjectDestroyedInternal(ExecutionContext*, WorkerMessa
gingProxy*); | 87 static void workerObjectDestroyedInternal(ExecutionContext*, WorkerMessaging
Proxy*); |
| 88 | 88 |
| 89 RefPtrWillBePersistent<ExecutionContext> m_executionContext; | 89 RefPtrWillBePersistent<ExecutionContext> m_executionContext; |
| 90 OwnPtr<WorkerObjectProxy> m_workerObjectProxy; | 90 OwnPtr<WorkerObjectProxy> m_workerObjectProxy; |
| 91 Worker* m_workerObject; | 91 Worker* m_workerObject; |
| 92 bool m_mayBeDestroyed; | 92 bool m_mayBeDestroyed; |
| 93 RefPtr<DedicatedWorkerThread> m_workerThread; | 93 RefPtr<DedicatedWorkerThread> m_workerThread; |
| 94 | 94 |
| 95 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker
object to worker thread. | 95 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker obje
ct to worker thread. |
| 96 bool m_workerThreadHadPendingActivity; // The latest confirmation from w
orker thread reported that it was still active. | 96 bool m_workerThreadHadPendingActivity; // The latest confirmation from worke
r thread reported that it was still active. |
| 97 | 97 |
| 98 bool m_askedToTerminate; | 98 bool m_askedToTerminate; |
| 99 | 99 |
| 100 Vector<OwnPtr<ExecutionContextTask> > m_queuedEarlyTasks; // Tasks are q
ueued here until there's a thread object created. | 100 Vector<OwnPtr<ExecutionContextTask> > m_queuedEarlyTasks; // Tasks are queue
d here until there's a thread object created. |
| 101 WorkerGlobalScopeProxy::PageInspector* m_pageInspector; | 101 WorkerGlobalScopeProxy::PageInspector* m_pageInspector; |
| 102 | 102 |
| 103 OwnPtrWillBePersistent<WorkerClients> m_workerClients; | 103 OwnPtrWillBePersistent<WorkerClients> m_workerClients; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 } // namespace WebCore | 106 } // namespace WebCore |
| 107 | 107 |
| 108 #endif // WorkerMessagingProxy_h | 108 #endif // WorkerMessagingProxy_h |
| OLD | NEW |