Commit 46a8cfcd authored by tzik's avatar tzik Committed by Commit bot

Expose base::Callback::IsCancelled as WTF::Function::isCancelled

Review-Url: https://codereview.chromium.org/2327793002
Cr-Commit-Position: refs/heads/master@{#419113}
parent f0055a24
...@@ -203,6 +203,11 @@ public: ...@@ -203,6 +203,11 @@ public:
return m_callback.Run(std::forward<Args>(args)...); return m_callback.Run(std::forward<Args>(args)...);
} }
bool isCancelled() const
{
return m_callback.IsCancelled();
}
friend base::Callback<R(Args...)> convertToBaseCallback(std::unique_ptr<Function> function) friend base::Callback<R(Args...)> convertToBaseCallback(std::unique_ptr<Function> function)
{ {
return std::move(function->m_callback); return std::move(function->m_callback);
......
...@@ -589,9 +589,11 @@ TEST(FunctionalTest, WeakPtr) ...@@ -589,9 +589,11 @@ TEST(FunctionalTest, WeakPtr)
std::unique_ptr<WTF::Closure> bound = WTF::bind(&HasWeakPtrSupport::increment, obj.createWeakPtr(), WTF::unretained(&counter)); std::unique_ptr<WTF::Closure> bound = WTF::bind(&HasWeakPtrSupport::increment, obj.createWeakPtr(), WTF::unretained(&counter));
(*bound)(); (*bound)();
EXPECT_FALSE(bound->isCancelled());
EXPECT_EQ(1, counter); EXPECT_EQ(1, counter);
obj.revokeAll(); obj.revokeAll();
EXPECT_TRUE(bound->isCancelled());
(*bound)(); (*bound)();
EXPECT_EQ(1, counter); EXPECT_EQ(1, counter);
} }
......
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