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

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

Issue 2487403002: Allow navigations to frames that aren't being unloaded in the unload handler. (Closed)
Patch Set: early return on back/forward navigations Created 3 years, 11 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 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 double navigationStart = 98 double navigationStart =
99 frame->loader().provisionalDocumentLoader()->timing().navigationStart(); 99 frame->loader().provisionalDocumentLoader()->timing().navigationStart();
100 if (navigationStart) { 100 if (navigationStart) {
101 scheduledClobberAbortTimeHistogram.count(monotonicallyIncreasingTime() - 101 scheduledClobberAbortTimeHistogram.count(monotonicallyIncreasingTime() -
102 navigationStart); 102 navigationStart);
103 } 103 }
104 } 104 }
105 105
106 } // namespace 106 } // namespace
107 107
108 unsigned NavigationDisablerForUnload::s_navigationDisableCount = 0; 108 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0;
109 109
110 class ScheduledNavigation 110 class ScheduledNavigation
111 : public GarbageCollectedFinalized<ScheduledNavigation> { 111 : public GarbageCollectedFinalized<ScheduledNavigation> {
112 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); 112 WTF_MAKE_NONCOPYABLE(ScheduledNavigation);
113 113
114 public: 114 public:
115 ScheduledNavigation(double delay, 115 ScheduledNavigation(double delay,
116 Document* originDocument, 116 Document* originDocument,
117 bool replacesCurrentItem, 117 bool replacesCurrentItem,
118 bool isLocationChange) 118 bool isLocationChange)
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 return m_redirect && m_redirect->isLocationChange(); 353 return m_redirect && m_redirect->isLocationChange();
354 } 354 }
355 355
356 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const { 356 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const {
357 return m_redirect && m_redirect->delay() <= interval; 357 return m_redirect && m_redirect->delay() <= interval;
358 } 358 }
359 359
360 // TODO(dcheng): There are really two different load blocking concepts at work 360 // TODO(dcheng): There are really two different load blocking concepts at work
361 // here and they have been incorrectly tangled together. 361 // here and they have been incorrectly tangled together.
362 // 362 //
363 // 1. NavigationDisablerForUnload is for blocking navigation scheduling during 363 // 1. NavigationDisablerForBeforeUnload is for blocking navigation scheduling
364 // a beforeunload or unload events. Scheduled navigations during 364 // during a beforeunload events. Scheduled navigations during beforeunload
365 // beforeunload would make it possible to get trapped in an endless loop of 365 // would make it possible to get trapped in an endless loop of beforeunload
366 // beforeunload dialogs. Scheduled navigations during the unload handler 366 // dialogs.
367 // makes is possible to cancel a navigation that was initiated right before
368 // it commits.
369 // 367 //
370 // Checking Frame::isNavigationAllowed() doesn't make sense in this context: 368 // Checking Frame::isNavigationAllowed() doesn't make sense in this context:
371 // NavigationScheduler is always cleared when a new load commits, so it's 369 // NavigationScheduler is always cleared when a new load commits, so it's
372 // impossible for a scheduled navigation to clobber a navigation that just 370 // impossible for a scheduled navigation to clobber a navigation that just
373 // committed. 371 // committed.
374 // 372 //
375 // 2. FrameNavigationDisabler / LocalFrame::isNavigationAllowed() are intended 373 // 2. FrameNavigationDisabler / LocalFrame::isNavigationAllowed() are intended
376 // to prevent Documents from being reattached during destruction, since it 374 // to prevent Documents from being reattached during destruction, since it
377 // can cause bugs with security origin confusion. This is primarily intended 375 // can cause bugs with security origin confusion. This is primarily intended
378 // to block /synchronous/ navigations during things lke 376 // to block /synchronous/ navigations during things lke
379 // Document::detachLayoutTree(). 377 // Document::detachLayoutTree().
380 inline bool NavigationScheduler::shouldScheduleReload() const { 378 inline bool NavigationScheduler::shouldScheduleReload() const {
381 return m_frame->page() && m_frame->isNavigationAllowed() && 379 return m_frame->page() && m_frame->isNavigationAllowed() &&
382 NavigationDisablerForUnload::isNavigationAllowed(); 380 NavigationDisablerForBeforeUnload::isNavigationAllowed();
383 } 381 }
384 382
385 inline bool NavigationScheduler::shouldScheduleNavigation( 383 inline bool NavigationScheduler::shouldScheduleNavigation(
386 const String& url) const { 384 const String& url) const {
387 return m_frame->page() && m_frame->isNavigationAllowed() && 385 return m_frame->page() && m_frame->isNavigationAllowed() &&
388 (protocolIsJavaScript(url) || 386 (protocolIsJavaScript(url) ||
389 NavigationDisablerForUnload::isNavigationAllowed()); 387 NavigationDisablerForBeforeUnload::isNavigationAllowed());
390 } 388 }
391 389
392 void NavigationScheduler::scheduleRedirect(double delay, const String& url) { 390 void NavigationScheduler::scheduleRedirect(double delay, const String& url) {
393 if (!shouldScheduleNavigation(url)) 391 if (!shouldScheduleNavigation(url))
394 return; 392 return;
395 if (delay < 0 || delay > INT_MAX / 1000) 393 if (delay < 0 || delay > INT_MAX / 1000)
396 return; 394 return;
397 if (url.isEmpty()) 395 if (url.isEmpty())
398 return; 396 return;
399 397
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 m_navigateTaskHandle.cancel(); 544 m_navigateTaskHandle.cancel();
547 m_redirect.clear(); 545 m_redirect.clear();
548 } 546 }
549 547
550 DEFINE_TRACE(NavigationScheduler) { 548 DEFINE_TRACE(NavigationScheduler) {
551 visitor->trace(m_frame); 549 visitor->trace(m_frame);
552 visitor->trace(m_redirect); 550 visitor->trace(m_redirect);
553 } 551 }
554 552
555 } // namespace blink 553 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698