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

Unified Diff: third_party/WebKit/Source/core/loader/NavigationScheduler.cpp

Issue 2507673002: Scheduler: Deprecate CancellableTaskFactory in favor of WebTaskRunner::postCancellableTask (2) (Closed)
Patch Set: address review comments Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/core/loader/NavigationScheduler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/loader/NavigationScheduler.cpp
diff --git a/third_party/WebKit/Source/core/loader/NavigationScheduler.cpp b/third_party/WebKit/Source/core/loader/NavigationScheduler.cpp
index 923e203a1bb4345eba76d38ebc0c295585e49cf5..993b7831dd8e2e0d003f5c4b00b8050040e9ceeb 100644
--- a/third_party/WebKit/Source/core/loader/NavigationScheduler.cpp
+++ b/third_party/WebKit/Source/core/loader/NavigationScheduler.cpp
@@ -51,7 +51,6 @@
#include "platform/Histogram.h"
#include "platform/SharedBuffer.h"
#include "platform/UserGestureIndicator.h"
-#include "platform/scheduler/CancellableTaskFactory.h"
#include "public/platform/Platform.h"
#include "public/platform/WebCachePolicy.h"
#include "public/platform/WebScheduler.h"
@@ -343,15 +342,12 @@ class ScheduledFormSubmission final : public ScheduledNavigation {
NavigationScheduler::NavigationScheduler(LocalFrame* frame)
: m_frame(frame),
- m_navigateTaskFactory(
- CancellableTaskFactory::create(this,
- &NavigationScheduler::navigateTask)),
m_frameType(m_frame->isMainFrame()
? WebScheduler::NavigatingFrameType::kMainFrame
: WebScheduler::NavigatingFrameType::kChildFrame) {}
NavigationScheduler::~NavigationScheduler() {
- if (m_navigateTaskFactory->isPending()) {
+ if (m_navigateTaskHandle.isActive()) {
Platform::current()->currentThread()->scheduler()->removePendingNavigation(
m_frameType);
}
@@ -525,28 +521,33 @@ void NavigationScheduler::startTimer() {
return;
DCHECK(m_frame->page());
- if (m_navigateTaskFactory->isPending())
+ if (m_navigateTaskHandle.isActive())
return;
if (!m_redirect->shouldStartTimer(m_frame))
return;
WebScheduler* scheduler = Platform::current()->currentThread()->scheduler();
scheduler->addPendingNavigation(m_frameType);
- scheduler->loadingTaskRunner()->postDelayedTask(
- BLINK_FROM_HERE, m_navigateTaskFactory->cancelAndCreate(),
- m_redirect->delay() * 1000.0);
+
+ // wrapWeakPersistent(this) is safe because a posted task is canceled when the
+ // task handle is destroyed on the dtor of this NavigationScheduler.
+ m_navigateTaskHandle =
+ scheduler->loadingTaskRunner()->postDelayedCancellableTask(
+ BLINK_FROM_HERE, WTF::bind(&NavigationScheduler::navigateTask,
+ wrapWeakPersistent(this)),
+ m_redirect->delay() * 1000.0);
InspectorInstrumentation::frameScheduledNavigation(m_frame,
m_redirect->delay());
}
void NavigationScheduler::cancel() {
- if (m_navigateTaskFactory->isPending()) {
+ if (m_navigateTaskHandle.isActive()) {
Platform::current()->currentThread()->scheduler()->removePendingNavigation(
m_frameType);
InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
}
- m_navigateTaskFactory->cancel();
+ m_navigateTaskHandle.cancel();
m_redirect.clear();
}
« no previous file with comments | « third_party/WebKit/Source/core/loader/NavigationScheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698