Chromium Code Reviews| Index: Source/core/workers/InProcessWorkerBase.h |
| diff --git a/Source/core/workers/InProcessWorkerBase.h b/Source/core/workers/InProcessWorkerBase.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4dff0492f5f8836f1d0df4cf821a9fcb3efbe46e |
| --- /dev/null |
| +++ b/Source/core/workers/InProcessWorkerBase.h |
| @@ -0,0 +1,62 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef InProcessWorkerBase_h |
| +#define InProcessWorkerBase_h |
| + |
| +#include "core/CoreExport.h" |
| +#include "core/dom/ActiveDOMObject.h" |
| +#include "core/dom/MessagePort.h" |
| +#include "core/events/EventListener.h" |
| +#include "core/events/EventTarget.h" |
| +#include "core/workers/AbstractWorker.h" |
| +#include "core/workers/WorkerScriptLoaderClient.h" |
| +#include "platform/heap/Handle.h" |
| +#include "wtf/Forward.h" |
| +#include "wtf/PassRefPtr.h" |
| +#include "wtf/RefPtr.h" |
| +#include "wtf/text/AtomicStringHash.h" |
| + |
| +namespace blink { |
| + |
| +class ExceptionState; |
| +class ExecutionContext; |
| +class WorkerGlobalScopeProxy; |
| +class WorkerScriptLoader; |
| + |
| +// Base class for workers that operate in the same process as the document that creates them. |
| +class CORE_EXPORT InProcessWorkerBase : public AbstractWorker, private WorkerScriptLoaderClient { |
| +public: |
| + virtual ~InProcessWorkerBase(); |
| + |
| + void postMessage(ExecutionContext*, PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, ExceptionState&); |
| + void terminate(); |
| + |
| + // ActiveDOMObject |
| + void stop() override; |
| + bool hasPendingActivity() const override; |
| + |
| + DEFINE_ATTRIBUTE_EVENT_LISTENER(message); |
| + |
| + DECLARE_VIRTUAL_TRACE(); |
| + |
| +protected: |
| + explicit InProcessWorkerBase(ExecutionContext*); |
| + bool initialize(ExecutionContext*, const String&, ExceptionState&); |
| + |
| + // 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
|
| + virtual WorkerGlobalScopeProxy* createWorkerGlobalScopeProxy(ExecutionContext*) = 0; |
| + |
| +private: |
| + // WorkerScriptLoaderClient callbacks |
| + void didReceiveResponse(unsigned long identifier, const ResourceResponse&) override; |
| + void notifyFinished() override; |
| + |
| + RefPtr<WorkerScriptLoader> m_scriptLoader; |
| + WorkerGlobalScopeProxy* m_contextProxy; // The proxy outlives the worker to perform thread shutdown. |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // InProcessWorkerBase_h |