| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 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 InProcessWorkerMessagingProxy_h |
| 28 #define WorkerMessagingProxy_h | 28 #define InProcessWorkerMessagingProxy_h |
| 29 | 29 |
| 30 #include "core/CoreExport.h" | 30 #include "core/CoreExport.h" |
| 31 #include "core/dom/ExecutionContext.h" | 31 #include "core/dom/ExecutionContext.h" |
| 32 #include "core/workers/WorkerGlobalScopeProxy.h" | 32 #include "core/workers/InProcessWorkerGlobalScopeProxy.h" |
| 33 #include "core/workers/WorkerLoaderProxy.h" | 33 #include "core/workers/WorkerLoaderProxy.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 blink { | 41 namespace blink { |
| 42 | 42 |
| 43 class WorkerObjectProxy; | 43 class WorkerObjectProxy; |
| 44 class WorkerThread; | 44 class WorkerThread; |
| 45 class ExecutionContext; | 45 class ExecutionContext; |
| 46 class InProcessWorkerBase; | 46 class InProcessWorkerBase; |
| 47 class WorkerClients; | 47 class WorkerClients; |
| 48 class WorkerInspectorProxy; | 48 class WorkerInspectorProxy; |
| 49 | 49 |
| 50 class CORE_EXPORT WorkerMessagingProxy | 50 // TODO(nhiroki): "MessagingProxy" is not well-defined term among worker |
| 51 : public WorkerGlobalScopeProxy | 51 // components. Probably we should rename this to something more suitable. |
| 52 // (http://crbug.com/603785) |
| 53 class CORE_EXPORT InProcessWorkerMessagingProxy |
| 54 : public InProcessWorkerGlobalScopeProxy |
| 52 , private WorkerLoaderProxyProvider { | 55 , private WorkerLoaderProxyProvider { |
| 53 WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy); | 56 WTF_MAKE_NONCOPYABLE(InProcessWorkerMessagingProxy); |
| 54 public: | 57 public: |
| 55 // Implementations of WorkerGlobalScopeProxy. | 58 // Implementations of InProcessWorkerGlobalScopeProxy. |
| 56 // (Only use these methods in the worker object thread.) | 59 // (Only use these methods in the worker object thread.) |
| 57 void startWorkerGlobalScope(const KURL& scriptURL, const String& userAgent,
const String& sourceCode) override; | 60 void startWorkerGlobalScope(const KURL& scriptURL, const String& userAgent,
const String& sourceCode) override; |
| 58 void terminateWorkerGlobalScope() override; | 61 void terminateWorkerGlobalScope() override; |
| 59 void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, PassO
wnPtr<MessagePortChannelArray>) override; | 62 void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, PassO
wnPtr<MessagePortChannelArray>) override; |
| 60 bool hasPendingActivity() const final; | 63 bool hasPendingActivity() const final; |
| 61 void workerObjectDestroyed() override; | 64 void workerObjectDestroyed() override; |
| 62 | 65 |
| 63 // These methods come from worker context thread via WorkerObjectProxy | 66 // These methods come from worker context thread via WorkerObjectProxy |
| 64 // and are called on the worker object thread (e.g. main thread). | 67 // and are called on the worker object thread (e.g. main thread). |
| 65 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr
<MessagePortChannelArray>); | 68 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr
<MessagePortChannelArray>); |
| 66 void reportException(const String& errorMessage, int lineNumber, int columnN
umber, const String& sourceURL, int exceptionId); | 69 void reportException(const String& errorMessage, int lineNumber, int columnN
umber, const String& sourceURL, int exceptionId); |
| 67 void reportConsoleMessage(MessageSource, MessageLevel, const String& message
, int lineNumber, const String& sourceURL); | 70 void reportConsoleMessage(MessageSource, MessageLevel, const String& message
, int lineNumber, const String& sourceURL); |
| 68 void postMessageToPageInspector(const String&); | 71 void postMessageToPageInspector(const String&); |
| 69 void postWorkerConsoleAgentEnabled(); | 72 void postWorkerConsoleAgentEnabled(); |
| 70 void confirmMessageFromWorkerObject(bool hasPendingActivity); | 73 void confirmMessageFromWorkerObject(bool hasPendingActivity); |
| 71 void reportPendingActivity(bool hasPendingActivity); | 74 void reportPendingActivity(bool hasPendingActivity); |
| 72 void workerGlobalScopeClosed(); | 75 void workerGlobalScopeClosed(); |
| 73 void workerThreadTerminated(); | 76 void workerThreadTerminated(); |
| 74 void workerThreadCreated(); | 77 void workerThreadCreated(); |
| 75 | 78 |
| 76 ExecutionContext* getExecutionContext() const { return m_executionContext.ge
t(); } | 79 ExecutionContext* getExecutionContext() const { return m_executionContext.ge
t(); } |
| 77 | 80 |
| 78 protected: | 81 protected: |
| 79 WorkerMessagingProxy(InProcessWorkerBase*, WorkerClients*); | 82 InProcessWorkerMessagingProxy(InProcessWorkerBase*, WorkerClients*); |
| 80 ~WorkerMessagingProxy() override; | 83 ~InProcessWorkerMessagingProxy() override; |
| 81 | 84 |
| 82 virtual PassOwnPtr<WorkerThread> createWorkerThread(double originTime) = 0; | 85 virtual PassOwnPtr<WorkerThread> createWorkerThread(double originTime) = 0; |
| 83 | 86 |
| 84 PassRefPtr<WorkerLoaderProxy> loaderProxy() { return m_loaderProxy; } | 87 PassRefPtr<WorkerLoaderProxy> loaderProxy() { return m_loaderProxy; } |
| 85 WorkerObjectProxy& workerObjectProxy() { return *m_workerObjectProxy.get();
} | 88 WorkerObjectProxy& workerObjectProxy() { return *m_workerObjectProxy.get();
} |
| 86 | 89 |
| 87 private: | 90 private: |
| 88 void workerObjectDestroyedInternal(); | 91 void workerObjectDestroyedInternal(); |
| 89 void terminateInternally(); | 92 void terminateInternally(); |
| 90 | 93 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 108 Vector<OwnPtr<ExecutionContextTask>> m_queuedEarlyTasks; // Tasks are queued
here until there's a thread object created. | 111 Vector<OwnPtr<ExecutionContextTask>> m_queuedEarlyTasks; // Tasks are queued
here until there's a thread object created. |
| 109 Persistent<WorkerInspectorProxy> m_workerInspectorProxy; | 112 Persistent<WorkerInspectorProxy> m_workerInspectorProxy; |
| 110 | 113 |
| 111 Persistent<WorkerClients> m_workerClients; | 114 Persistent<WorkerClients> m_workerClients; |
| 112 | 115 |
| 113 RefPtr<WorkerLoaderProxy> m_loaderProxy; | 116 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
| 114 }; | 117 }; |
| 115 | 118 |
| 116 } // namespace blink | 119 } // namespace blink |
| 117 | 120 |
| 118 #endif // WorkerMessagingProxy_h | 121 #endif // InProcessWorkerMessagingProxy_h |
| OLD | NEW |