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

Unified Diff: third_party/WebKit/Source/core/workers/WorkerBackingThread.h

Issue 1733353004: Introduce WorkerBackingThread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
Index: third_party/WebKit/Source/core/workers/WorkerBackingThread.h
diff --git a/third_party/WebKit/Source/core/workers/WorkerBackingThread.h b/third_party/WebKit/Source/core/workers/WorkerBackingThread.h
new file mode 100644
index 0000000000000000000000000000000000000000..d62badccae4db6ac896ea88ce16e4986c4d36fff
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/WorkerBackingThread.h
@@ -0,0 +1,65 @@
+// 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 WorkerBackingThread_h
+#define WorkerBackingThread_h
+
+#include "core/CoreExport.h"
+#include "wtf/Forward.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/ThreadSafeRefCounted.h"
+#include "wtf/ThreadingPrimitives.h"
+#include <v8.h>
+
+namespace blink {
+
+class WaitableEvent;
+class WebThread;
+class WebThreadSupportingGC;
+
+class CORE_EXPORT WorkerBackingThread final : public ThreadSafeRefCounted<WorkerBackingThread> {
+public:
+ static PassRefPtr<WorkerBackingThread> create(const char* name) { return adoptRef(new WorkerBackingThread(name)); }
+ static PassRefPtr<WorkerBackingThread> create(WebThread* thread) { return adoptRef(new WorkerBackingThread(thread)); }
+
+ ~WorkerBackingThread();
+
+ void attach();
+ void detach();
+ unsigned workerScriptCount()
+ {
+ MutexLocker locker(m_mutex);
+ return m_workerScriptCount;
+ }
+
+ WebThreadSupportingGC& backingThread()
+ {
+ ASSERT(m_backingThread);
+ return *m_backingThread;
+ }
+
+ v8::Isolate* isolate() const { return m_isolate; }
+
+ void setInitializationEventForTest();
+ WaitableEvent* initializationEventForTest() { return m_initializationEventForTest.get(); }
kinuko 2016/02/29 09:32:53 Hmm could we not have these?
yhirano 2016/02/29 23:47:32 Done.
+
+private:
+ explicit WorkerBackingThread(const char* name);
+ explicit WorkerBackingThread(WebThread*);
+ void initialize();
+ void shutdown();
+
+ Mutex m_mutex;
+ OwnPtr<WebThreadSupportingGC> m_backingThread;
+ OwnPtr<WaitableEvent> m_initializationEventForTest;
+ v8::Isolate* m_isolate = nullptr;
+ unsigned m_workerScriptCount = 0;
+ bool m_isOwningThread;
+};
+
+} // namespace blink
+
+#endif // WorkerBackingThread_h

Powered by Google App Engine
This is Rietveld 408576698