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

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: fix test Created 4 years 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 return m_redirect && m_redirect->isLocationChange(); 350 return m_redirect && m_redirect->isLocationChange();
351 } 351 }
352 352
353 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const { 353 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const {
354 return m_redirect && m_redirect->delay() <= interval; 354 return m_redirect && m_redirect->delay() <= interval;
355 } 355 }
356 356
357 // TODO(dcheng): There are really two different load blocking concepts at work 357 // TODO(dcheng): There are really two different load blocking concepts at work
358 // here and they have been incorrectly tangled together. 358 // here and they have been incorrectly tangled together.
359 // 359 //
360 // 1. NavigationDisablerForUnload is for blocking navigation scheduling during 360 // 1. NavigationDisablerForBeforeUnload is for blocking navigation scheduling
361 // a beforeunload or unload events. Scheduled navigations during 361 // during a beforeunload events. Scheduled navigations during beforeunload
362 // beforeunload would make it possible to get trapped in an endless loop of 362 // would make it possible to get trapped in an endless loop of beforeunload
363 // beforeunload dialogs. Scheduled navigations during the unload handler 363 // dialogs.
364 // makes is possible to cancel a navigation that was initiated right before
365 // it commits.
366 // 364 //
367 // Checking Frame::isNavigationAllowed() doesn't make sense in this context: 365 // Checking Frame::isNavigationAllowed() doesn't make sense in this context:
368 // NavigationScheduler is always cleared when a new load commits, so it's 366 // NavigationScheduler is always cleared when a new load commits, so it's
369 // impossible for a scheduled navigation to clobber a navigation that just 367 // impossible for a scheduled navigation to clobber a navigation that just
370 // committed. 368 // committed.
371 // 369 //
372 // 2. FrameNavigationDisabler / LocalFrame::isNavigationAllowed() are intended 370 // 2. FrameNavigationDisabler / LocalFrame::isNavigationAllowed() are intended
373 // to prevent Documents from being reattached during destruction, since it 371 // to prevent Documents from being reattached during destruction, since it
374 // can cause bugs with security origin confusion. This is primarily intended 372 // can cause bugs with security origin confusion. This is primarily intended
375 // to block /synchronous/ navigations during things lke 373 // to block /synchronous/ navigations during things lke
376 // Document::detachLayoutTree(). 374 // Document::detachLayoutTree().
377 inline bool NavigationScheduler::shouldScheduleReload() const { 375 inline bool NavigationScheduler::shouldScheduleReload() const {
378 return m_frame->page() && m_frame->isNavigationAllowed() && 376 return m_frame->page() && m_frame->isNavigationAllowed() &&
379 NavigationDisablerForUnload::isNavigationAllowed(); 377 NavigationDisablerForBeforeUnload::isNavigationAllowed();
380 } 378 }
381 379
382 inline bool NavigationScheduler::shouldScheduleNavigation( 380 inline bool NavigationScheduler::shouldScheduleNavigation(
383 const String& url) const { 381 const String& url) const {
384 return m_frame->page() && m_frame->isNavigationAllowed() && 382 return m_frame->page() && m_frame->isNavigationAllowed() &&
385 (protocolIsJavaScript(url) || 383 (protocolIsJavaScript(url) ||
386 NavigationDisablerForUnload::isNavigationAllowed()); 384 NavigationDisablerForBeforeUnload::isNavigationAllowed());
387 } 385 }
388 386
389 void NavigationScheduler::scheduleRedirect(double delay, const String& url) { 387 void NavigationScheduler::scheduleRedirect(double delay, const String& url) {
390 if (!shouldScheduleNavigation(url)) 388 if (!shouldScheduleNavigation(url))
391 return; 389 return;
392 if (delay < 0 || delay > INT_MAX / 1000) 390 if (delay < 0 || delay > INT_MAX / 1000)
393 return; 391 return;
394 if (url.isEmpty()) 392 if (url.isEmpty())
395 return; 393 return;
396 394
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 m_navigateTaskHandle.cancel(); 541 m_navigateTaskHandle.cancel();
544 m_redirect.clear(); 542 m_redirect.clear();
545 } 543 }
546 544
547 DEFINE_TRACE(NavigationScheduler) { 545 DEFINE_TRACE(NavigationScheduler) {
548 visitor->trace(m_frame); 546 visitor->trace(m_frame);
549 visitor->trace(m_redirect); 547 visitor->trace(m_redirect);
550 } 548 }
551 549
552 } // namespace blink 550 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698