| 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 22 matching lines...) Expand all Loading... |
| 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 blink { | 40 namespace blink { |
| 41 | 41 |
| 42 class WorkerObjectProxy; | 42 class WorkerObjectProxy; |
| 43 class DedicatedWorkerThread; | 43 class WorkerThread; |
| 44 class ExecutionContext; | 44 class ExecutionContext; |
| 45 class Worker; | 45 class Worker; |
| 46 class WorkerClients; | 46 class WorkerClients; |
| 47 class WorkerInspectorProxy; | 47 class WorkerInspectorProxy; |
| 48 | 48 |
| 49 class WorkerMessagingProxy final | 49 class WorkerMessagingProxy |
| 50 : public WorkerGlobalScopeProxy | 50 : public WorkerGlobalScopeProxy |
| 51 , private WorkerLoaderProxyProvider { | 51 , private WorkerLoaderProxyProvider { |
| 52 WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy); | 52 WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy); |
| 53 WTF_MAKE_FAST_ALLOCATED(WorkerMessagingProxy); | 53 WTF_MAKE_FAST_ALLOCATED(WorkerMessagingProxy); |
| 54 public: | 54 public: |
| 55 WorkerMessagingProxy(Worker*, PassOwnPtrWillBeRawPtr<WorkerClients>); | 55 WorkerMessagingProxy(Worker*, PassOwnPtrWillBeRawPtr<WorkerClients>); |
| 56 | 56 |
| 57 // Implementations of WorkerGlobalScopeProxy. | 57 // Implementations of WorkerGlobalScopeProxy. |
| 58 // (Only use these methods in the worker object thread.) | 58 // (Only use these methods in the worker object thread.) |
| 59 virtual void startWorkerGlobalScope(const KURL& scriptURL, const String& use
rAgent, const String& sourceCode, WorkerThreadStartMode) override; | 59 virtual void startWorkerGlobalScope(const KURL& scriptURL, const String& use
rAgent, const String& sourceCode, WorkerThreadStartMode) override; |
| 60 virtual void terminateWorkerGlobalScope() override; | 60 virtual void terminateWorkerGlobalScope() override; |
| 61 virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue
>, PassOwnPtr<MessagePortChannelArray>) override; | 61 virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue
>, PassOwnPtr<MessagePortChannelArray>) override; |
| 62 virtual bool hasPendingActivity() const override; | 62 virtual bool hasPendingActivity() const override; |
| 63 virtual void workerObjectDestroyed() override; | 63 virtual void workerObjectDestroyed() override; |
| 64 | 64 |
| 65 // These methods come from worker context thread via WorkerObjectProxy | 65 // These methods come from worker context thread via WorkerObjectProxy |
| 66 // and are called on the worker object thread (e.g. main thread). | 66 // and are called on the worker object thread (e.g. main thread). |
| 67 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr
<MessagePortChannelArray>); | 67 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr
<MessagePortChannelArray>); |
| 68 void reportException(const String& errorMessage, int lineNumber, int columnN
umber, const String& sourceURL, int exceptionId); | 68 void reportException(const String& errorMessage, int lineNumber, int columnN
umber, const String& sourceURL, int exceptionId); |
| 69 void reportConsoleMessage(MessageSource, MessageLevel, const String& message
, int lineNumber, const String& sourceURL); | 69 void reportConsoleMessage(MessageSource, MessageLevel, const String& message
, int lineNumber, const String& sourceURL); |
| 70 void postMessageToPageInspector(const String&); | 70 void postMessageToPageInspector(const String&); |
| 71 void postWorkerConsoleAgentEnabled(); | 71 void postWorkerConsoleAgentEnabled(); |
| 72 WorkerInspectorProxy* workerInspectorProxy(); | 72 WorkerInspectorProxy* workerInspectorProxy(); |
| 73 void confirmMessageFromWorkerObject(bool hasPendingActivity); | 73 void confirmMessageFromWorkerObject(bool hasPendingActivity); |
| 74 void reportPendingActivity(bool hasPendingActivity); | 74 void reportPendingActivity(bool hasPendingActivity); |
| 75 void workerGlobalScopeClosed(); | 75 void workerGlobalScopeClosed(); |
| 76 void workerThreadTerminated(); | 76 void workerThreadTerminated(); |
| 77 | 77 |
| 78 void workerThreadCreated(PassRefPtr<DedicatedWorkerThread>); | 78 void workerThreadCreated(PassRefPtr<WorkerThread>); |
| 79 | 79 |
| 80 protected: | 80 protected: |
| 81 virtual ~WorkerMessagingProxy(); | 81 virtual ~WorkerMessagingProxy(); |
| 82 | 82 |
| 83 virtual PassRefPtr<WorkerThread> createWorkerThread(double originTime, PassO
wnPtrWillBeRawPtr<WorkerThreadStartupData>); |
| 84 |
| 85 PassRefPtr<WorkerLoaderProxy> loaderProxy() { return m_loaderProxy; } |
| 86 WorkerObjectProxy& workerObjectProxy() { return *m_workerObjectProxy.get();
} |
| 87 |
| 83 private: | 88 private: |
| 84 static void workerObjectDestroyedInternal(ExecutionContext*, WorkerMessaging
Proxy*); | 89 static void workerObjectDestroyedInternal(ExecutionContext*, WorkerMessaging
Proxy*); |
| 85 void terminateInternally(); | 90 void terminateInternally(); |
| 86 | 91 |
| 87 // WorkerLoaderProxyProvider | 92 // WorkerLoaderProxyProvider |
| 88 // These methods are called on different threads to schedule loading | 93 // These methods are called on different threads to schedule loading |
| 89 // requests and to send callbacks back to WorkerGlobalScope. | 94 // requests and to send callbacks back to WorkerGlobalScope. |
| 90 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override; | 95 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override; |
| 91 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) o
verride; | 96 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) o
verride; |
| 92 | 97 |
| 93 RefPtrWillBePersistent<ExecutionContext> m_executionContext; | 98 RefPtrWillBePersistent<ExecutionContext> m_executionContext; |
| 94 OwnPtr<WorkerObjectProxy> m_workerObjectProxy; | 99 OwnPtr<WorkerObjectProxy> m_workerObjectProxy; |
| 95 Worker* m_workerObject; | 100 Worker* m_workerObject; |
| 96 bool m_mayBeDestroyed; | 101 bool m_mayBeDestroyed; |
| 97 RefPtr<DedicatedWorkerThread> m_workerThread; | 102 RefPtr<WorkerThread> m_workerThread; |
| 98 | 103 |
| 99 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker obje
ct to worker thread. | 104 unsigned m_unconfirmedMessageCount; // Unconfirmed messages from worker obje
ct to worker thread. |
| 100 bool m_workerThreadHadPendingActivity; // The latest confirmation from worke
r thread reported that it was still active. | 105 bool m_workerThreadHadPendingActivity; // The latest confirmation from worke
r thread reported that it was still active. |
| 101 | 106 |
| 102 bool m_askedToTerminate; | 107 bool m_askedToTerminate; |
| 103 | 108 |
| 104 Vector<OwnPtr<ExecutionContextTask>> m_queuedEarlyTasks; // Tasks are queued
here until there's a thread object created. | 109 Vector<OwnPtr<ExecutionContextTask>> m_queuedEarlyTasks; // Tasks are queued
here until there's a thread object created. |
| 105 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; | 110 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; |
| 106 | 111 |
| 107 OwnPtrWillBePersistent<WorkerClients> m_workerClients; | 112 OwnPtrWillBePersistent<WorkerClients> m_workerClients; |
| 108 | 113 |
| 109 RefPtr<WorkerLoaderProxy> m_loaderProxy; | 114 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
| 110 }; | 115 }; |
| 111 | 116 |
| 112 } // namespace blink | 117 } // namespace blink |
| 113 | 118 |
| 114 #endif // WorkerMessagingProxy_h | 119 #endif // WorkerMessagingProxy_h |
| OLD | NEW |