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

Side by Side Diff: third_party/WebKit/Source/core/loader/NavigationScheduler.cpp

Issue 2507673002: Scheduler: Deprecate CancellableTaskFactory in favor of WebTaskRunner::postCancellableTask (2) (Closed)
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
5 * (http://www.torchmobile.com/) 5 * (http://www.torchmobile.com/)
6 * Copyright (C) 2009 Adam Barth. All rights reserved. 6 * Copyright (C) 2009 Adam Barth. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "core/loader/DocumentLoader.h" 44 #include "core/loader/DocumentLoader.h"
45 #include "core/loader/FormSubmission.h" 45 #include "core/loader/FormSubmission.h"
46 #include "core/loader/FrameLoadRequest.h" 46 #include "core/loader/FrameLoadRequest.h"
47 #include "core/loader/FrameLoader.h" 47 #include "core/loader/FrameLoader.h"
48 #include "core/loader/FrameLoaderClient.h" 48 #include "core/loader/FrameLoaderClient.h"
49 #include "core/loader/FrameLoaderStateMachine.h" 49 #include "core/loader/FrameLoaderStateMachine.h"
50 #include "core/page/Page.h" 50 #include "core/page/Page.h"
51 #include "platform/Histogram.h" 51 #include "platform/Histogram.h"
52 #include "platform/SharedBuffer.h" 52 #include "platform/SharedBuffer.h"
53 #include "platform/UserGestureIndicator.h" 53 #include "platform/UserGestureIndicator.h"
54 #include "platform/scheduler/CancellableTaskFactory.h"
55 #include "public/platform/Platform.h" 54 #include "public/platform/Platform.h"
56 #include "public/platform/WebCachePolicy.h" 55 #include "public/platform/WebCachePolicy.h"
57 #include "public/platform/WebScheduler.h" 56 #include "public/platform/WebScheduler.h"
58 #include "wtf/CurrentTime.h" 57 #include "wtf/CurrentTime.h"
59 #include "wtf/PtrUtil.h" 58 #include "wtf/PtrUtil.h"
60 #include <memory> 59 #include <memory>
61 60
62 namespace blink { 61 namespace blink {
63 62
64 namespace { 63 namespace {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 : ScheduledNavigation(0, document, replacesCurrentItem, true), 335 : ScheduledNavigation(0, document, replacesCurrentItem, true),
337 m_submission(submission) { 336 m_submission(submission) {
338 DCHECK(m_submission->form()); 337 DCHECK(m_submission->form());
339 } 338 }
340 339
341 Member<FormSubmission> m_submission; 340 Member<FormSubmission> m_submission;
342 }; 341 };
343 342
344 NavigationScheduler::NavigationScheduler(LocalFrame* frame) 343 NavigationScheduler::NavigationScheduler(LocalFrame* frame)
345 : m_frame(frame), 344 : m_frame(frame),
346 m_navigateTaskFactory(
347 CancellableTaskFactory::create(this,
348 &NavigationScheduler::navigateTask)),
349 m_frameType(m_frame->isMainFrame() 345 m_frameType(m_frame->isMainFrame()
350 ? WebScheduler::NavigatingFrameType::kMainFrame 346 ? WebScheduler::NavigatingFrameType::kMainFrame
351 : WebScheduler::NavigatingFrameType::kChildFrame) {} 347 : WebScheduler::NavigatingFrameType::kChildFrame) {}
352 348
353 NavigationScheduler::~NavigationScheduler() { 349 NavigationScheduler::~NavigationScheduler() {
354 if (m_navigateTaskFactory->isPending()) { 350 if (m_navigateTaskHandle.isActive()) {
355 Platform::current()->currentThread()->scheduler()->removePendingNavigation( 351 Platform::current()->currentThread()->scheduler()->removePendingNavigation(
356 m_frameType); 352 m_frameType);
357 } 353 }
358 } 354 }
359 355
360 bool NavigationScheduler::locationChangePending() { 356 bool NavigationScheduler::locationChangePending() {
361 return m_redirect && m_redirect->isLocationChange(); 357 return m_redirect && m_redirect->isLocationChange();
362 } 358 }
363 359
364 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const { 360 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 cancel(); 514 cancel();
519 m_redirect = redirect; 515 m_redirect = redirect;
520 startTimer(); 516 startTimer();
521 } 517 }
522 518
523 void NavigationScheduler::startTimer() { 519 void NavigationScheduler::startTimer() {
524 if (!m_redirect) 520 if (!m_redirect)
525 return; 521 return;
526 522
527 DCHECK(m_frame->page()); 523 DCHECK(m_frame->page());
528 if (m_navigateTaskFactory->isPending()) 524 if (m_navigateTaskHandle.isActive())
529 return; 525 return;
530 if (!m_redirect->shouldStartTimer(m_frame)) 526 if (!m_redirect->shouldStartTimer(m_frame))
531 return; 527 return;
532 528
533 WebScheduler* scheduler = Platform::current()->currentThread()->scheduler(); 529 WebScheduler* scheduler = Platform::current()->currentThread()->scheduler();
534 scheduler->addPendingNavigation(m_frameType); 530 scheduler->addPendingNavigation(m_frameType);
nhiroki 2016/11/16 13:49:32 Question: addPendingNavigation and removePendingNa
haraken 2016/11/17 05:59:09 It is calling UpdatePolicy(), right? However, Web
nhiroki 2016/11/17 06:15:59 Are you seeing RendererScheduler::AddPendingNaviga
haraken 2016/11/17 06:35:19 ah, got it.
535 scheduler->loadingTaskRunner()->postDelayedTask( 531
536 BLINK_FROM_HERE, m_navigateTaskFactory->cancelAndCreate(), 532 // wrapWeakPersistent(this) is safe because a posted task is canceled when the
537 m_redirect->delay() * 1000.0); 533 // task handle is destroyed on the dtor of this NavigationScheduler.
534 m_navigateTaskHandle =
535 scheduler->loadingTaskRunner()->postDelayedCancellableTask(
haraken 2016/11/16 11:37:20 Nit: We should move this to TaskRunnerHelper::xxx
nhiroki 2016/11/16 13:49:32 Acknowledged. I have a question related to this cl
536 BLINK_FROM_HERE, WTF::bind(&NavigationScheduler::navigateTask,
537 wrapWeakPersistent(this)),
538 m_redirect->delay() * 1000.0);
538 539
539 InspectorInstrumentation::frameScheduledNavigation(m_frame, 540 InspectorInstrumentation::frameScheduledNavigation(m_frame,
540 m_redirect->delay()); 541 m_redirect->delay());
541 } 542 }
542 543
543 void NavigationScheduler::cancel() { 544 void NavigationScheduler::cancel() {
544 if (m_navigateTaskFactory->isPending()) { 545 if (m_navigateTaskHandle.isActive()) {
545 Platform::current()->currentThread()->scheduler()->removePendingNavigation( 546 Platform::current()->currentThread()->scheduler()->removePendingNavigation(
546 m_frameType); 547 m_frameType);
547 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame); 548 InspectorInstrumentation::frameClearedScheduledNavigation(m_frame);
548 } 549 }
549 m_navigateTaskFactory->cancel(); 550 m_navigateTaskHandle.cancel();
550 m_redirect.clear(); 551 m_redirect.clear();
551 } 552 }
552 553
553 DEFINE_TRACE(NavigationScheduler) { 554 DEFINE_TRACE(NavigationScheduler) {
554 visitor->trace(m_frame); 555 visitor->trace(m_frame);
555 visitor->trace(m_redirect); 556 visitor->trace(m_redirect);
556 } 557 }
557 558
558 } // namespace blink 559 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698