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

Unified Diff: Source/platform/WebThreadRunner.h

Issue 469683002: Implement WebThreadSupportingGC, which wraps a WebThread attached to Oilpan's GC (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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: Source/platform/WebThreadRunner.h
diff --git a/Source/platform/WebThreadRunner.h b/Source/platform/WebThreadRunner.h
new file mode 100644
index 0000000000000000000000000000000000000000..0d7c207d4bf6a86ed7f8416de906477fdd01434b
--- /dev/null
+++ b/Source/platform/WebThreadRunner.h
@@ -0,0 +1,83 @@
+// Copyright 2014 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 WebThreadRunner_h
+#define WebThreadRunner_h
+
+#include "platform/heap/glue/MessageLoopInterruptor.h"
+#include "platform/heap/glue/PendingGCRunner.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebThread.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace blink {
+
+class WebThreadRunner {
Mads Ager (chromium) 2014/08/13 07:26:20 WebThreadSupportingGC? Should we add a comment al
haraken 2014/08/13 08:03:09 Renamed to WebThreadSupportingGC & added the comme
+ WTF_MAKE_NONCOPYABLE(WebThreadRunner);
+public:
+ static PassOwnPtr<WebThreadRunner> create(const char*);
+
+ void postTask(WebThread::Task* task)
+ {
+ m_thread->postTask(task);
+ }
+
+ void postDelayedTask(WebThread::Task* task, long long delayMs)
+ {
+ m_thread->postDelayedTask(task, delayMs);
+ }
+
+ bool isCurrentThread() const
+ {
+ return m_thread->isCurrentThread();
+ }
+
+ void addTaskObserver(WebThread::TaskObserver* observer)
+ {
+ m_thread->addTaskObserver(observer);
+ }
+
+ void removeTaskObserver(WebThread::TaskObserver* observer)
+ {
+ m_thread->removeTaskObserver(observer);
+ }
+
+ void enterRunLoop()
+ {
+ m_thread->enterRunLoop();
+ }
+
+ void exitRunLoop()
+ {
+ m_thread->exitRunLoop();
+ }
+
+ void attachGC();
+ void detachGC();
+
+ WebThread& platformThread() const
+ {
+ ASSERT(m_thread);
+ return *m_thread;
+ }
+
+private:
+ explicit WebThreadRunner(const char*);
+
+ OwnPtr<PendingGCRunner> m_pendingGCRunner;
+ OwnPtr<MessageLoopInterruptor> m_messageLoopInterruptor;
+
+ // FIXME: This has to be last because of crbug.com/401397.
+ // A WorkerThread might get deleted before it had a chance to properly
+ // shut down. By deleting the WebThread first, we can guarantee that
+ // no pending tasks on the thread might want to access any of the other
+ // members during the WorkerThread's destruction.
+ OwnPtr<WebThread> m_thread;
+};
+
+}
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698