Index: third_party/WebKit/Source/core/dom/ExecutionContextTask.h |
diff --git a/third_party/WebKit/Source/core/dom/ExecutionContextTask.h b/third_party/WebKit/Source/core/dom/ExecutionContextTask.h |
index 3567f0f37a86a73e1666018d57de0971b70f916c..4efe57675fa8104272b1a1efe92af62dce83d033 100644 |
--- a/third_party/WebKit/Source/core/dom/ExecutionContextTask.h |
+++ b/third_party/WebKit/Source/core/dom/ExecutionContextTask.h |
@@ -50,63 +50,49 @@ public: |
namespace internal { |
-template<typename T, WTF::FunctionThreadAffinity threadAffinity> |
-class CallClosureTaskBase : public ExecutionContextTask { |
-protected: |
- explicit CallClosureTaskBase(std::unique_ptr<Function<T, threadAffinity>> closure) |
- : m_closure(std::move(closure)) |
- { |
- } |
- |
- std::unique_ptr<Function<T, threadAffinity>> m_closure; |
-}; |
+template<WTF::FunctionThreadAffinity threadAffinity> |
+void runCallClosureTask(std::unique_ptr<Function<void(), threadAffinity>> closure, ExecutionContext*) |
+{ |
+ (*closure)(); |
+} |
template<WTF::FunctionThreadAffinity threadAffinity> |
-class CallClosureTask final : public CallClosureTaskBase<void(), threadAffinity> { |
-public: |
- // Do not use |create| other than in createCrossThreadTask and |
- // createSameThreadTask. |
- // See http://crbug.com/390851 |
- static std::unique_ptr<CallClosureTask<threadAffinity>> create(std::unique_ptr<Function<void(), threadAffinity>> closure) |
- { |
- return wrapUnique(new CallClosureTask<threadAffinity>(std::move(closure))); |
- } |
+void runCallClosureTask(std::unique_ptr<Function<void(ExecutionContext*), threadAffinity>> closure, ExecutionContext* executionContext) |
+{ |
+ (*closure)(executionContext); |
+} |
- void performTask(ExecutionContext*) override |
+template<typename T, WTF::FunctionThreadAffinity threadAffinity> |
+class CallClosureTask final : public ExecutionContextTask { |
+public: |
+ static std::unique_ptr<CallClosureTask> create(std::unique_ptr<Function<T, threadAffinity>> closure) |
{ |
- (*this->m_closure)(); |
+ return wrapUnique(new CallClosureTask(std::move(closure))); |
} |
private: |
- explicit CallClosureTask(std::unique_ptr<Function<void(), threadAffinity>> closure) |
- : CallClosureTaskBase<void(), threadAffinity>(std::move(closure)) |
- { |
- } |
-}; |
- |
-template<WTF::FunctionThreadAffinity threadAffinity> |
-class CallClosureWithExecutionContextTask final : public CallClosureTaskBase<void(ExecutionContext*), threadAffinity> { |
-public: |
- // Do not use |create| other than in createCrossThreadTask and |
- // createSameThreadTask. |
- // See http://crbug.com/390851 |
- static std::unique_ptr<CallClosureWithExecutionContextTask> create(std::unique_ptr<Function<void(ExecutionContext*), threadAffinity>> closure) |
+ explicit CallClosureTask(std::unique_ptr<Function<T, threadAffinity>> closure) |
+ : m_closure(std::move(closure)) |
{ |
- return wrapUnique(new CallClosureWithExecutionContextTask(std::move(closure))); |
} |
- void performTask(ExecutionContext* context) override |
+ void performTask(ExecutionContext* executionContext) override |
{ |
- (*this->m_closure)(context); |
+ runCallClosureTask(std::move(m_closure), executionContext); |
} |
-private: |
- explicit CallClosureWithExecutionContextTask(std::unique_ptr<Function<void(ExecutionContext*), threadAffinity>> closure) |
- : CallClosureTaskBase<void(ExecutionContext*), threadAffinity>(std::move(closure)) |
- { |
- } |
+ std::unique_ptr<Function<T, threadAffinity>> m_closure; |
}; |
+// Do not use |create| other than in createCrossThreadTask and |
+// createSameThreadTask. |
+// See http://crbug.com/390851 |
+template<typename T, WTF::FunctionThreadAffinity threadAffinity> |
+std::unique_ptr<CallClosureTask<T, threadAffinity>> createCallClosureTask(std::unique_ptr<Function<T, threadAffinity>> closure) |
+{ |
+ return CallClosureTask<T, threadAffinity>::create(std::move(closure)); |
+} |
+ |
} // namespace internal |
// Create tasks passed within a single thread. |
@@ -118,7 +104,7 @@ template<typename FunctionType, typename... P> |
std::unique_ptr<ExecutionContextTask> createSameThreadTask( |
FunctionType function, P&&... parameters) |
{ |
- return internal::CallClosureTask<WTF::SameThreadAffinity>::create(bind(function, std::forward<P>(parameters)...)); |
+ return internal::createCallClosureTask(bind(function, std::forward<P>(parameters)...)); |
} |
} // namespace blink |