| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef InProcessWorkerBase_h | 5 #ifndef InProcessWorkerBase_h |
| 6 #define InProcessWorkerBase_h | 6 #define InProcessWorkerBase_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ActiveScriptWrappable.h" | 8 #include "bindings/core/v8/ActiveScriptWrappable.h" |
| 9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
| 10 #include "core/dom/ActiveDOMObject.h" | 10 #include "core/dom/ActiveDOMObject.h" |
| 11 #include "core/dom/MessagePort.h" | 11 #include "core/dom/MessagePort.h" |
| 12 #include "core/events/EventListener.h" | 12 #include "core/events/EventListener.h" |
| 13 #include "core/events/EventTarget.h" | 13 #include "core/events/EventTarget.h" |
| 14 #include "core/workers/AbstractWorker.h" | 14 #include "core/workers/AbstractWorker.h" |
| 15 #include "platform/heap/Handle.h" | 15 #include "platform/heap/Handle.h" |
| 16 #include "wtf/Forward.h" | 16 #include "wtf/Forward.h" |
| 17 #include "wtf/PassRefPtr.h" | 17 #include "wtf/PassRefPtr.h" |
| 18 #include "wtf/RefPtr.h" | 18 #include "wtf/RefPtr.h" |
| 19 #include "wtf/text/AtomicStringHash.h" | 19 #include "wtf/text/AtomicStringHash.h" |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 | 22 |
| 23 class ExceptionState; | 23 class ExceptionState; |
| 24 class ExecutionContext; | 24 class ExecutionContext; |
| 25 class InProcessWorkerGlobalScopeProxy; | 25 class InProcessWorkerMessagingProxy; |
| 26 class WorkerScriptLoader; | 26 class WorkerScriptLoader; |
| 27 | 27 |
| 28 // Base class for workers that operate in the same process as the document that | 28 // Base class for workers that operate in the same process as the document that |
| 29 // creates them. | 29 // creates them. |
| 30 class CORE_EXPORT InProcessWorkerBase : public AbstractWorker, public ActiveScri
ptWrappable { | 30 class CORE_EXPORT InProcessWorkerBase : public AbstractWorker, public ActiveScri
ptWrappable { |
| 31 public: | 31 public: |
| 32 ~InProcessWorkerBase() override; | 32 ~InProcessWorkerBase() override; |
| 33 | 33 |
| 34 void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> messag
e, const MessagePortArray&, ExceptionState&); | 34 void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> messag
e, const MessagePortArray&, ExceptionState&); |
| 35 void terminate(); | 35 void terminate(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 47 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | 47 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
| 48 | 48 |
| 49 DECLARE_VIRTUAL_TRACE(); | 49 DECLARE_VIRTUAL_TRACE(); |
| 50 | 50 |
| 51 protected: | 51 protected: |
| 52 explicit InProcessWorkerBase(ExecutionContext*); | 52 explicit InProcessWorkerBase(ExecutionContext*); |
| 53 bool initialize(ExecutionContext*, const String&, ExceptionState&); | 53 bool initialize(ExecutionContext*, const String&, ExceptionState&); |
| 54 | 54 |
| 55 // Creates a proxy to allow communicating with the worker's global scope. In
ProcessWorkerBase does not take ownership of the | 55 // Creates a proxy to allow communicating with the worker's global scope. In
ProcessWorkerBase does not take ownership of the |
| 56 // created proxy. The proxy is expected to manage its own lifetime, and dele
te itself in response to terminateWorkerGlobalScope(). | 56 // created proxy. The proxy is expected to manage its own lifetime, and dele
te itself in response to terminateWorkerGlobalScope(). |
| 57 virtual InProcessWorkerGlobalScopeProxy* createInProcessWorkerGlobalScopePro
xy(ExecutionContext*) = 0; | 57 virtual InProcessWorkerMessagingProxy* createInProcessWorkerMessagingProxy(E
xecutionContext*) = 0; |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 // Callbacks for m_scriptLoader. | 60 // Callbacks for m_scriptLoader. |
| 61 void onResponse(); | 61 void onResponse(); |
| 62 void onFinished(); | 62 void onFinished(); |
| 63 | 63 |
| 64 RefPtr<WorkerScriptLoader> m_scriptLoader; | 64 RefPtr<WorkerScriptLoader> m_scriptLoader; |
| 65 Member<ContentSecurityPolicy> m_contentSecurityPolicy; | 65 Member<ContentSecurityPolicy> m_contentSecurityPolicy; |
| 66 String m_referrerPolicy; | 66 String m_referrerPolicy; |
| 67 InProcessWorkerGlobalScopeProxy* m_contextProxy; // The proxy outlives the w
orker to perform thread shutdown. | 67 InProcessWorkerMessagingProxy* m_contextProxy; // The proxy outlives the wor
ker to perform thread shutdown. |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace blink | 70 } // namespace blink |
| 71 | 71 |
| 72 #endif // InProcessWorkerBase_h | 72 #endif // InProcessWorkerBase_h |
| OLD | NEW |