Commit 844e4a30 authored by Findit's avatar Findit

Revert "Replace WTF::Function with base::OnceCallback."

This reverts commit d298a4dd.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 521649 as the
culprit for failures in the build cycles as shown on:
https://findit-for-me.appspot.com/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtL2QyOThhNGRkNzMyZjA5YzlhMWMzMDZhMjA2NTA3YzEyM2EzNzYxZTIM

Sample Failed Build: https://ci.chromium.org/buildbot/chromium.chrome/Google%20Chrome%20Linux%20x64/24801

Original change's description:
> Replace WTF::Function with base::OnceCallback.
> 
> This patch makes WTF::Function an alias of base::OnceCallback. After
> this, all the single-threaded callbacks in Blink will become base
> callbacks.
> 
> This patch doesn't remove the WTF::Funtion type nor ConvertToBase-
> Callback() function. The use sites of those names will be removed
> individually.
> 
> Bug: 771087
> Change-Id: I15e7758c29bb9f63b7db7ad7aba6c9cb2d9ae7d1
> Reviewed-on: https://chromium-review.googlesource.com/807672
> Reviewed-by: Kentaro Hara <haraken@chromium.org>
> Reviewed-by: Taiju Tsuiki <tzik@chromium.org>
> Commit-Queue: Yuta Kitamura <yutak@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#521649}

Change-Id: I60fec5e188923122bb3b090acc49cfd0f0363df1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 771087
Reviewed-on: https://chromium-review.googlesource.com/808224
Cr-Commit-Position: refs/heads/master@{#521653}
parent 16ac914c
...@@ -137,6 +137,13 @@ void WebTaskRunner::PostTask(const WebTraceLocation& location, ...@@ -137,6 +137,13 @@ void WebTaskRunner::PostTask(const WebTraceLocation& location,
base::TimeDelta()); base::TimeDelta());
} }
void WebTaskRunner::PostDelayedTask(const WebTraceLocation& location,
WTF::Closure task,
TimeDelta delay) {
DCHECK(RunsTasksInCurrentSequence());
PostDelayedTask(location, ConvertToBaseCallback(std::move(task)), delay);
}
TaskHandle WebTaskRunner::PostCancellableTask(const WebTraceLocation& location, TaskHandle WebTaskRunner::PostCancellableTask(const WebTraceLocation& location,
WTF::Closure task) { WTF::Closure task) {
DCHECK(RunsTasksInCurrentSequence()); DCHECK(RunsTasksInCurrentSequence());
......
...@@ -78,6 +78,7 @@ class BLINK_PLATFORM_EXPORT WebTaskRunner ...@@ -78,6 +78,7 @@ class BLINK_PLATFORM_EXPORT WebTaskRunner
// For same-thread posting. Must be called from the associated WebThread. // For same-thread posting. Must be called from the associated WebThread.
void PostTask(const WebTraceLocation&, WTF::Closure); void PostTask(const WebTraceLocation&, WTF::Closure);
void PostDelayedTask(const WebTraceLocation&, WTF::Closure, TimeDelta delay);
// For same-thread cancellable task posting. Returns a TaskHandle object for // For same-thread cancellable task posting. Returns a TaskHandle object for
// cancellation. // cancellation.
......
...@@ -327,13 +327,44 @@ namespace WTF { ...@@ -327,13 +327,44 @@ namespace WTF {
#endif #endif
template <typename Signature> template <typename Signature>
using Function = base::OnceCallback<Signature>; class Function;
template <typename Signature> template <typename R, typename... Args>
base::OnceCallback<Signature> ConvertToBaseCallback( class Function<R(Args...)> {
Function<Signature> function) { USING_FAST_MALLOC(Function);
return function;
} public:
Function() {}
Function(base::Callback<R(Args...)> callback)
: callback_(std::move(callback)) {}
~Function() {}
Function(const Function&) = delete;
Function& operator=(const Function&) = delete;
Function(Function&& other) : callback_(std::move(other.callback_)) {}
Function& operator=(Function&& other) {
callback_ = std::move(other.callback_);
return *this;
}
R Run(Args... args) && {
return std::move(callback_).Run(std::forward<Args>(args)...);
}
bool IsCancelled() const { return callback_.IsCancelled(); }
void Reset() { callback_.Reset(); }
explicit operator bool() const { return static_cast<bool>(callback_); }
friend base::OnceCallback<R(Args...)> ConvertToBaseCallback(
Function function) {
return std::move(function.callback_);
}
private:
base::Callback<R(Args...)> callback_;
};
template <typename Signature> template <typename Signature>
class CrossThreadFunction; class CrossThreadFunction;
...@@ -387,15 +418,15 @@ Function<base::MakeUnboundRunType<FunctionType, BoundParameters...>> Bind( ...@@ -387,15 +418,15 @@ Function<base::MakeUnboundRunType<FunctionType, BoundParameters...>> Bind(
"A bound argument uses a bad pattern."); "A bound argument uses a bad pattern.");
using UnboundRunType = using UnboundRunType =
base::MakeUnboundRunType<FunctionType, BoundParameters...>; base::MakeUnboundRunType<FunctionType, BoundParameters...>;
auto cb = base::BindOnce(function, auto cb =
std::forward<BoundParameters>(bound_parameters)...); base::Bind(function, std::forward<BoundParameters>(bound_parameters)...);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
using WrapperType = using WrapperType =
ThreadCheckingCallbackWrapper<base::OnceCallback<UnboundRunType>>; ThreadCheckingCallbackWrapper<base::Callback<UnboundRunType>>;
cb = base::BindOnce(&WrapperType::Run, cb = base::Bind(&WrapperType::Run,
std::make_unique<WrapperType>(std::move(cb))); std::make_unique<WrapperType>(std::move(cb)));
#endif #endif
return cb; return Function<UnboundRunType>(std::move(cb));
} }
template <typename FunctionType, typename... BoundParameters> template <typename FunctionType, typename... BoundParameters>
...@@ -470,6 +501,4 @@ using WTF::Function; ...@@ -470,6 +501,4 @@ using WTF::Function;
using WTF::CrossThreadFunction; using WTF::CrossThreadFunction;
using WTF::CrossThreadClosure; using WTF::CrossThreadClosure;
using WTF::ConvertToBaseCallback;
#endif // WTF_Functional_h #endif // WTF_Functional_h
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment