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

Unified Diff: third_party/WebKit/Source/core/workers/WorkletBackingThreadHolder.cpp

Issue 2389193003: Refactor BackingThreadHolder to WorkletBackingThreadHolder (Closed)
Patch Set: Fixing compilation error for try bots Created 4 years, 2 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/WorkletBackingThreadHolder.cpp
diff --git a/third_party/WebKit/Source/core/workers/WorkletBackingThreadHolder.cpp b/third_party/WebKit/Source/core/workers/WorkletBackingThreadHolder.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..95acbfb5196940f49a73e4d3d2dd463f94ce9613
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/WorkletBackingThreadHolder.cpp
@@ -0,0 +1,40 @@
+// 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.
+
+#include "core/workers/WorkletBackingThreadHolder.h"
+
+#include "core/workers/WorkerBackingThread.h"
+#include "platform/WaitableEvent.h"
+#include "platform/WebThreadSupportingGC.h"
+
+namespace blink {
+
+WorkletBackingThreadHolder::WorkletBackingThreadHolder(
+ std::unique_ptr<WorkerBackingThread> backingThread)
+ : m_thread(std::move(backingThread)), m_initialized(false) {
+ DCHECK(isMainThread());
+ m_thread->backingThread().postTask(
+ BLINK_FROM_HERE,
+ crossThreadBind(&WorkletBackingThreadHolder::initializeOnThread,
+ crossThreadUnretained(this)));
+}
+
+void WorkletBackingThreadHolder::shutdownAndWait() {
+ DCHECK(isMainThread());
+ WaitableEvent waitableEvent;
+ m_thread->backingThread().postTask(
+ BLINK_FROM_HERE,
+ crossThreadBind(&WorkletBackingThreadHolder::shutdownOnThread,
+ crossThreadUnretained(this),
+ crossThreadUnretained(&waitableEvent)));
+ waitableEvent.wait();
+}
+
+void WorkletBackingThreadHolder::shutdownOnThread(
+ WaitableEvent* waitableEvent) {
+ m_thread->shutdown();
+ waitableEvent->signal();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698