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