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

Unified Diff: third_party/WebKit/Source/platform/Task.h

Issue 1549143002: Add thread affinity and ASSERT() for same-thread restriction to WTF::Function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@TRV_ThreadSafeBindByVariadicTemplate
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/platform/Task.h
diff --git a/third_party/WebKit/Source/platform/Task.h b/third_party/WebKit/Source/platform/Task.h
index 64b656c7374f14261d098c250be6bdc7c1f009db..141a2824367cf48af55d14ed374a14bd9b4c0009 100644
--- a/third_party/WebKit/Source/platform/Task.h
+++ b/third_party/WebKit/Source/platform/Task.h
@@ -40,11 +40,16 @@
namespace blink {
-class Task : public WebTaskRunner::Task {
- USING_FAST_MALLOC(Task);
- WTF_MAKE_NONCOPYABLE(Task);
+// Please use WTF::Closure and WTF::CrossThreadClosure directly, instead of
haraken 2016/03/02 09:27:35 Nit: I might prefer renaming WTF::Closure to WTF::
hiroshige 2016/03/03 02:21:07 Should we also rename bind() to sameThreadBind()?
haraken 2016/03/03 02:38:06 I'd prefer having sameThreadBind & sameThreadCallb
tzik 2016/03/03 04:49:30 It's up to you. :p Since bind() in Blink is mostly
hiroshige 2016/03/04 02:02:46 Thanks for suggestions! I renamed WTF::Closure to
+// wrapping them by blink::SameThreadTask/CrossThreadTask here.
+
+// TODO(hiroshige): Make these classes internal to
+// Source/platform/WebTaskRunner.cpp.
+class SameThreadTask : public WebTaskRunner::Task {
+ USING_FAST_MALLOC(SameThreadTask);
+ WTF_MAKE_NONCOPYABLE(SameThreadTask);
public:
- explicit Task(PassOwnPtr<Closure> closure)
+ explicit SameThreadTask(PassOwnPtr<Closure> closure)
: m_closure(std::move(closure))
{
}
@@ -58,6 +63,24 @@ private:
OwnPtr<Closure> m_closure;
};
+class CrossThreadTask : public WebTaskRunner::Task {
+ USING_FAST_MALLOC(CrossThreadTask);
+ WTF_MAKE_NONCOPYABLE(CrossThreadTask);
+public:
+ explicit CrossThreadTask(PassOwnPtr<CrossThreadClosure> closure)
+ : m_closure(std::move(closure))
+ {
+ }
+
+ void run() override
+ {
+ (*m_closure)();
+ }
+
+private:
+ OwnPtr<CrossThreadClosure> m_closure;
+};
+
} // namespace blink
#endif // Task_h

Powered by Google App Engine
This is Rietveld 408576698