Index: third_party/WebKit/Source/modules/worklet/WorkletThread.h |
diff --git a/third_party/WebKit/Source/modules/worklet/WorkletThread.h b/third_party/WebKit/Source/modules/worklet/WorkletThread.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b6bff1d4e5779cec96393bb1a6744545e428cf6b |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/worklet/WorkletThread.h |
@@ -0,0 +1,72 @@ |
+// Copyright 2016 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 WorkletThread_h |
+#define WorkletThread_h |
+ |
+#include "core/dom/ExecutionContextTask.h" |
+#include "platform/heap/Handle.h" |
+#include "platform/weborigin/KURL.h" |
+#include "wtf/Forward.h" |
+#include "wtf/Functional.h" |
+#include "wtf/ThreadingPrimitives.h" |
+#include "wtf/text/WTFString.h" |
+#include <v8.h> |
+ |
+namespace blink { |
+ |
+class SecurityOrigin; |
+class WebTraceLocation; |
+class WorkerBackingThread; |
+class WorkletGlobalScope; |
+class WorkletThreadStartupData; |
+ |
+class WorkletThread { |
+public: |
+ virtual ~WorkletThread(); |
+ |
+ // Called on the main thread. |
+ void initialize(PassOwnPtr<WorkletThreadStartupData>); |
+ void terminate(); |
+ |
+ virtual WorkerBackingThread& workerBackingThread() = 0; |
+ v8::Isolate* isolate(); |
+ |
+ bool isCurrentThread(); |
+ |
+ void postTask(const WebTraceLocation&, std::unique_ptr<ExecutionContextTask>); |
+ |
+ // Can be called only on the worklet thread, WorkletGlobalScope is not thread |
+ // safe. |
+ WorkletGlobalScope* workletGlobalScope(); |
+ |
+protected: |
+ WorkletThread();/*WorkletReportingProxy&*/ |
+ |
+ // Factory method for creating a new worklet context for the thread. |
+ // Called on the worklet thread. |
+ virtual WorkletGlobalScope* createWorkletGlobalScope(const KURL&, const String& userAgent, PassRefPtr<SecurityOrigin>) = 0; |
+ |
+private: |
+ // Called on the worklet thread. |
+ void initializeInternal(PassOwnPtr<WorkletThreadStartupData>); |
+ void terminateInternal(); |
+ |
+ std::unique_ptr<CrossThreadClosure> createWorkletThreadTask(std::unique_ptr<ExecutionContextTask>, bool isInstrumented); |
+ void performTask(std::unique_ptr<ExecutionContextTask>, bool isInstrumented); |
+ |
+ bool m_terminated; |
+ bool m_shutdown; |
+ |
+ // TODO figure out reporting proxy. |
+ // WorkerReportingProxy& m_workerReportingProxy; |
+ |
+ Mutex m_threadStateMutex; |
+ |
+ Persistent<WorkletGlobalScope> m_workletGlobalScope; |
+}; |
+ |
+} // namespace blink |
+ |
+#endif // WorkletThread_h |