Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1084)

Unified Diff: Source/core/workers/InProcessWorkerBase.h

Issue 1075603003: workers: Move core worker functionality into InProcessWorkerBase. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/workers/DedicatedWorkerMessagingProxy.cpp ('k') | Source/core/workers/InProcessWorkerBase.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d6e7d8ac05a5985eb26eb12d5d7b4e39c08fade4
--- /dev/null
+++ b/Source/core/workers/InProcessWorkerBase.h
@@ -0,0 +1,63 @@
+// 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. InProcessWorkerBase does not take ownership of the
+ // created proxy. The proxy is expected to manage its own lifetime, and delete itself in response to terminateWorkerGlobalScope().
+ 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
« no previous file with comments | « Source/core/workers/DedicatedWorkerMessagingProxy.cpp ('k') | Source/core/workers/InProcessWorkerBase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698