| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, std::
unique_ptr<MessagePortChannelArray>) override; | 64 void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, std::
unique_ptr<MessagePortChannelArray>) override; |
| 65 bool hasPendingActivity() const final; | 65 bool hasPendingActivity() const final; |
| 66 void workerObjectDestroyed() override; | 66 void workerObjectDestroyed() override; |
| 67 | 67 |
| 68 // These methods come from worker context thread via | 68 // These methods come from worker context thread via |
| 69 // InProcessWorkerObjectProxy and are called on the parent context thread. | 69 // InProcessWorkerObjectProxy and are called on the parent context thread. |
| 70 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, std::uniqu
e_ptr<MessagePortChannelArray>); | 70 void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, std::uniqu
e_ptr<MessagePortChannelArray>); |
| 71 void dispatchErrorEvent(const String& errorMessage, std::unique_ptr<SourceLo
cation>, int exceptionId); | 71 void dispatchErrorEvent(const String& errorMessage, std::unique_ptr<SourceLo
cation>, int exceptionId); |
| 72 void reportConsoleMessage(MessageSource, MessageLevel, const String& message
, std::unique_ptr<SourceLocation>); | 72 void reportConsoleMessage(MessageSource, MessageLevel, const String& message
, std::unique_ptr<SourceLocation>); |
| 73 void postMessageToPageInspector(const String&); | 73 void postMessageToPageInspector(const String&); |
| 74 void confirmMessageFromWorkerObject(bool hasPendingActivity); | 74 |
| 75 void reportPendingActivity(bool hasPendingActivity); | 75 // 'virtual' for testing. |
| 76 void workerThreadTerminated(); | 76 virtual void confirmMessageFromWorkerObject(); |
| 77 virtual void pendingActivityFinished(); |
| 78 virtual void workerThreadTerminated(); |
| 79 |
| 77 void workerThreadCreated(); | 80 void workerThreadCreated(); |
| 78 | 81 |
| 79 ExecutionContext* getExecutionContext() const { return m_executionContext.ge
t(); } | 82 ExecutionContext* getExecutionContext() const { return m_executionContext.ge
t(); } |
| 80 | 83 |
| 81 ParentFrameTaskRunners* getParentFrameTaskRunners() { return m_parentFrameTa
skRunners.get(); } | 84 ParentFrameTaskRunners* getParentFrameTaskRunners() { return m_parentFrameTa
skRunners.get(); } |
| 82 | 85 |
| 83 // Number of live messaging proxies, used by leak detection. | 86 // Number of live messaging proxies, used by leak detection. |
| 84 static int proxyCount(); | 87 static int proxyCount(); |
| 85 | 88 |
| 86 protected: | 89 protected: |
| 87 InProcessWorkerMessagingProxy(InProcessWorkerBase*, WorkerClients*); | 90 InProcessWorkerMessagingProxy(InProcessWorkerBase*, WorkerClients*); |
| 88 ~InProcessWorkerMessagingProxy() override; | 91 ~InProcessWorkerMessagingProxy() override; |
| 89 | 92 |
| 90 virtual std::unique_ptr<WorkerThread> createWorkerThread(double originTime)
= 0; | 93 virtual std::unique_ptr<WorkerThread> createWorkerThread(double originTime)
= 0; |
| 91 | 94 |
| 92 PassRefPtr<WorkerLoaderProxy> loaderProxy() { return m_loaderProxy; } | 95 PassRefPtr<WorkerLoaderProxy> loaderProxy() { return m_loaderProxy; } |
| 93 InProcessWorkerObjectProxy& workerObjectProxy() { return *m_workerObjectProx
y.get(); } | 96 InProcessWorkerObjectProxy& workerObjectProxy() { return *m_workerObjectProx
y.get(); } |
| 94 | 97 |
| 95 private: | 98 private: |
| 99 friend class InProcessWorkerMessagingProxyForTest; |
| 100 InProcessWorkerMessagingProxy(ExecutionContext*, InProcessWorkerBase*, Worke
rClients*); |
| 101 |
| 96 void workerObjectDestroyedInternal(); | 102 void workerObjectDestroyedInternal(); |
| 97 | 103 |
| 98 // WorkerLoaderProxyProvider | 104 // WorkerLoaderProxyProvider |
| 99 // These methods are called on different threads to schedule loading | 105 // These methods are called on different threads to schedule loading |
| 100 // requests and to send callbacks back to WorkerGlobalScope. | 106 // requests and to send callbacks back to WorkerGlobalScope. |
| 101 void postTaskToLoader(const WebTraceLocation&, std::unique_ptr<ExecutionCont
extTask>) override; | 107 void postTaskToLoader(const WebTraceLocation&, std::unique_ptr<ExecutionCont
extTask>) override; |
| 102 bool postTaskToWorkerGlobalScope(const WebTraceLocation&, std::unique_ptr<Ex
ecutionContextTask>) override; | 108 bool postTaskToWorkerGlobalScope(const WebTraceLocation&, std::unique_ptr<Ex
ecutionContextTask>) override; |
| 103 | 109 |
| 104 // Returns true if this is called on the parent context thread. | 110 // Returns true if this is called on the parent context thread. |
| 105 bool isParentContextThread() const; | 111 bool isParentContextThread() const; |
| 106 | 112 |
| 107 Persistent<ExecutionContext> m_executionContext; | 113 Persistent<ExecutionContext> m_executionContext; |
| 108 std::unique_ptr<InProcessWorkerObjectProxy> m_workerObjectProxy; | 114 std::unique_ptr<InProcessWorkerObjectProxy> m_workerObjectProxy; |
| 109 WeakPersistent<InProcessWorkerBase> m_workerObject; | 115 WeakPersistent<InProcessWorkerBase> m_workerObject; |
| 110 bool m_mayBeDestroyed; | 116 bool m_mayBeDestroyed; |
| 111 std::unique_ptr<WorkerThread> m_workerThread; | 117 std::unique_ptr<WorkerThread> m_workerThread; |
| 112 | 118 |
| 113 // Unconfirmed messages from the parent context thread to the worker thread. | 119 // Unconfirmed messages from the parent context thread to the worker thread. |
| 114 unsigned m_unconfirmedMessageCount; | 120 unsigned m_unconfirmedMessageCount; |
| 115 | 121 |
| 116 // The latest confirmation from worker thread reported that it was still | 122 bool m_workerGlobalScopeMayHavePendingActivity; |
| 117 // active. | |
| 118 bool m_workerThreadHadPendingActivity; | |
| 119 | |
| 120 bool m_askedToTerminate; | 123 bool m_askedToTerminate; |
| 121 | 124 |
| 122 // Tasks are queued here until there's a thread object created. | 125 // Tasks are queued here until there's a thread object created. |
| 123 Vector<std::unique_ptr<ExecutionContextTask>> m_queuedEarlyTasks; | 126 Vector<std::unique_ptr<ExecutionContextTask>> m_queuedEarlyTasks; |
| 124 | 127 |
| 125 Persistent<WorkerInspectorProxy> m_workerInspectorProxy; | 128 Persistent<WorkerInspectorProxy> m_workerInspectorProxy; |
| 126 | 129 |
| 127 Persistent<WorkerClients> m_workerClients; | 130 Persistent<WorkerClients> m_workerClients; |
| 128 | 131 |
| 129 Persistent<ParentFrameTaskRunners> m_parentFrameTaskRunners; | 132 Persistent<ParentFrameTaskRunners> m_parentFrameTaskRunners; |
| 130 | 133 |
| 131 RefPtr<WorkerLoaderProxy> m_loaderProxy; | 134 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
| 132 }; | 135 }; |
| 133 | 136 |
| 134 } // namespace blink | 137 } // namespace blink |
| 135 | 138 |
| 136 #endif // InProcessWorkerMessagingProxy_h | 139 #endif // InProcessWorkerMessagingProxy_h |
| OLD | NEW |