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

Unified Diff: third_party/WebKit/Source/platform/WebTaskRunner.cpp

Issue 2266443002: Optimize posting of WTF::Closure and improve scheduler test mocks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cut back to just the WTF::Closure fix plus the scheduler test mock refactor. Created 4 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: third_party/WebKit/Source/platform/WebTaskRunner.cpp
diff --git a/third_party/WebKit/Source/platform/WebTaskRunner.cpp b/third_party/WebKit/Source/platform/WebTaskRunner.cpp
index 40c83ae2580fb76b841d3234d864c9dd932a2bb1..97a082a01fb7605c0d2c35f979a8608786b6dfbb 100644
--- a/third_party/WebKit/Source/platform/WebTaskRunner.cpp
+++ b/third_party/WebKit/Source/platform/WebTaskRunner.cpp
@@ -6,60 +6,24 @@
namespace blink {
-class SameThreadTask : public WebTaskRunner::Task {
- USING_FAST_MALLOC(SameThreadTask);
- WTF_MAKE_NONCOPYABLE(SameThreadTask);
-public:
- explicit SameThreadTask(std::unique_ptr<WTF::Closure> closure)
- : m_closure(std::move(closure))
- {
- }
-
- void run() override
- {
- (*m_closure)();
- }
-
-private:
- std::unique_ptr<WTF::Closure> m_closure;
-};
-
-class CrossThreadTask : public WebTaskRunner::Task {
- USING_FAST_MALLOC(CrossThreadTask);
- WTF_MAKE_NONCOPYABLE(CrossThreadTask);
-public:
- explicit CrossThreadTask(std::unique_ptr<CrossThreadClosure> closure)
- : m_closure(std::move(closure))
- {
- }
-
- void run() override
- {
- (*m_closure)();
- }
-
-private:
- std::unique_ptr<CrossThreadClosure> m_closure;
-};
-
void WebTaskRunner::postTask(const WebTraceLocation& location, std::unique_ptr<CrossThreadClosure> task)
{
- postTask(location, new CrossThreadTask(std::move(task)));
+ toSingleThreadTaskRunner()->PostTask(location, convertToBaseCallback(std::move(task)));
}
void WebTaskRunner::postDelayedTask(const WebTraceLocation& location, std::unique_ptr<CrossThreadClosure> task, long long delayMs)
{
- postDelayedTask(location, new CrossThreadTask(std::move(task)), delayMs);
+ toSingleThreadTaskRunner()->PostDelayedTask(location, convertToBaseCallback(std::move(task)), base::TimeDelta::FromMilliseconds(delayMs));
}
void WebTaskRunner::postTask(const WebTraceLocation& location, std::unique_ptr<WTF::Closure> task)
{
- postTask(location, new SameThreadTask(std::move(task)));
+ toSingleThreadTaskRunner()->PostTask(location, convertToBaseCallback(std::move(task)));
}
void WebTaskRunner::postDelayedTask(const WebTraceLocation& location, std::unique_ptr<WTF::Closure> task, long long delayMs)
{
- postDelayedTask(location, new SameThreadTask(std::move(task)), delayMs);
+ toSingleThreadTaskRunner()->PostDelayedTask(location, convertToBaseCallback(std::move(task)), base::TimeDelta::FromMilliseconds(delayMs));
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/TimerTest.cpp ('k') | third_party/WebKit/Source/platform/blink_platform.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698