Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef InProcessWorkerBase_h | |
| 6 #define InProcessWorkerBase_h | |
| 7 | |
| 8 #include "core/CoreExport.h" | |
| 9 #include "core/dom/ActiveDOMObject.h" | |
| 10 #include "core/dom/MessagePort.h" | |
| 11 #include "core/events/EventListener.h" | |
| 12 #include "core/events/EventTarget.h" | |
| 13 #include "core/workers/AbstractWorker.h" | |
| 14 #include "core/workers/WorkerScriptLoaderClient.h" | |
| 15 #include "platform/heap/Handle.h" | |
| 16 #include "wtf/Forward.h" | |
| 17 #include "wtf/PassRefPtr.h" | |
| 18 #include "wtf/RefPtr.h" | |
| 19 #include "wtf/text/AtomicStringHash.h" | |
| 20 | |
| 21 namespace blink { | |
| 22 | |
| 23 class ExceptionState; | |
| 24 class ExecutionContext; | |
| 25 class WorkerGlobalScopeProxy; | |
| 26 class WorkerScriptLoader; | |
| 27 | |
| 28 // Base class for workers that operate in the same process as the document that creates them. | |
| 29 class CORE_EXPORT InProcessWorkerBase : public AbstractWorker, private WorkerScr iptLoaderClient { | |
| 30 public: | |
| 31 virtual ~InProcessWorkerBase(); | |
| 32 | |
| 33 void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> messag e, const MessagePortArray*, ExceptionState&); | |
| 34 void terminate(); | |
| 35 | |
| 36 // ActiveDOMObject | |
| 37 void stop() override; | |
| 38 bool hasPendingActivity() const override; | |
| 39 | |
| 40 DEFINE_ATTRIBUTE_EVENT_LISTENER(message); | |
| 41 | |
| 42 DECLARE_VIRTUAL_TRACE(); | |
| 43 | |
| 44 protected: | |
| 45 explicit InProcessWorkerBase(ExecutionContext*); | |
| 46 bool initialize(ExecutionContext*, const String&, ExceptionState&); | |
| 47 | |
| 48 // Creates a proxy to allow communicating with the worker's global scope. | |
|
kinuko
2015/04/13 05:55:52
Hmm, ok, sorry, may not be very informative as the
sadrul
2015/04/13 16:50:03
Good point. Updated the comment to document the li
| |
| 49 virtual WorkerGlobalScopeProxy* createWorkerGlobalScopeProxy(ExecutionContex t*) = 0; | |
| 50 | |
| 51 private: | |
| 52 // WorkerScriptLoaderClient callbacks | |
| 53 void didReceiveResponse(unsigned long identifier, const ResourceResponse&) o verride; | |
| 54 void notifyFinished() override; | |
| 55 | |
| 56 RefPtr<WorkerScriptLoader> m_scriptLoader; | |
| 57 WorkerGlobalScopeProxy* m_contextProxy; // The proxy outlives the worker to perform thread shutdown. | |
| 58 }; | |
| 59 | |
| 60 } // namespace blink | |
| 61 | |
| 62 #endif // InProcessWorkerBase_h | |
| OLD | NEW |