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

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

Issue 2621193004: Allow navigations to frames that aren't being unloaded in the unload handler. (Closed)
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/core/loader/NavigationScheduler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 double navigationStart = 99 double navigationStart =
100 frame->loader().provisionalDocumentLoader()->timing().navigationStart(); 100 frame->loader().provisionalDocumentLoader()->timing().navigationStart();
101 if (navigationStart) { 101 if (navigationStart) {
102 scheduledClobberAbortTimeHistogram.count(monotonicallyIncreasingTime() - 102 scheduledClobberAbortTimeHistogram.count(monotonicallyIncreasingTime() -
103 navigationStart); 103 navigationStart);
104 } 104 }
105 } 105 }
106 106
107 } // namespace 107 } // namespace
108 108
109 unsigned NavigationDisablerForUnload::s_navigationDisableCount = 0; 109 unsigned NavigationDisablerForBeforeUnload::s_navigationDisableCount = 0;
110 110
111 class ScheduledNavigation 111 class ScheduledNavigation
112 : public GarbageCollectedFinalized<ScheduledNavigation> { 112 : public GarbageCollectedFinalized<ScheduledNavigation> {
113 WTF_MAKE_NONCOPYABLE(ScheduledNavigation); 113 WTF_MAKE_NONCOPYABLE(ScheduledNavigation);
114 114
115 public: 115 public:
116 ScheduledNavigation(double delay, 116 ScheduledNavigation(double delay,
117 Document* originDocument, 117 Document* originDocument,
118 bool replacesCurrentItem, 118 bool replacesCurrentItem,
119 bool isLocationChange) 119 bool isLocationChange)
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 return m_redirect && m_redirect->isLocationChange(); 361 return m_redirect && m_redirect->isLocationChange();
362 } 362 }
363 363
364 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const { 364 bool NavigationScheduler::isNavigationScheduledWithin(double interval) const {
365 return m_redirect && m_redirect->delay() <= interval; 365 return m_redirect && m_redirect->delay() <= interval;
366 } 366 }
367 367
368 // TODO(dcheng): There are really two different load blocking concepts at work 368 // TODO(dcheng): There are really two different load blocking concepts at work
369 // here and they have been incorrectly tangled together. 369 // here and they have been incorrectly tangled together.
370 // 370 //
371 // 1. NavigationDisablerForUnload is for blocking navigation scheduling during 371 // 1. NavigationDisablerForBeforeUnload is for blocking navigation scheduling
372 // a beforeunload or unload events. Scheduled navigations during 372 // during a beforeunload events. Scheduled navigations during beforeunload
373 // beforeunload would make it possible to get trapped in an endless loop of 373 // would make it possible to get trapped in an endless loop of beforeunload
374 // beforeunload dialogs. Scheduled navigations during the unload handler 374 // dialogs.
375 // makes is possible to cancel a navigation that was initiated right before
376 // it commits.
377 // 375 //
378 // Checking Frame::isNavigationAllowed() doesn't make sense in this context: 376 // Checking Frame::isNavigationAllowed() doesn't make sense in this context:
379 // NavigationScheduler is always cleared when a new load commits, so it's 377 // NavigationScheduler is always cleared when a new load commits, so it's
380 // impossible for a scheduled navigation to clobber a navigation that just 378 // impossible for a scheduled navigation to clobber a navigation that just
381 // committed. 379 // committed.
382 // 380 //
383 // 2. FrameNavigationDisabler / LocalFrame::isNavigationAllowed() are intended 381 // 2. FrameNavigationDisabler / LocalFrame::isNavigationAllowed() are intended
384 // to prevent Documents from being reattached during destruction, since it 382 // to prevent Documents from being reattached during destruction, since it
385 // can cause bugs with security origin confusion. This is primarily intended 383 // can cause bugs with security origin confusion. This is primarily intended
386 // to block /synchronous/ navigations during things lke 384 // to block /synchronous/ navigations during things lke
387 // Document::detachLayoutTree(). 385 // Document::detachLayoutTree().
388 inline bool NavigationScheduler::shouldScheduleReload() const { 386 inline bool NavigationScheduler::shouldScheduleReload() const {
389 return m_frame->page() && m_frame->isNavigationAllowed() && 387 return m_frame->page() && m_frame->isNavigationAllowed() &&
390 NavigationDisablerForUnload::isNavigationAllowed(); 388 NavigationDisablerForBeforeUnload::isNavigationAllowed();
391 } 389 }
392 390
393 inline bool NavigationScheduler::shouldScheduleNavigation( 391 inline bool NavigationScheduler::shouldScheduleNavigation(
394 const String& url) const { 392 const String& url) const {
395 return m_frame->page() && m_frame->isNavigationAllowed() && 393 return m_frame->page() && m_frame->isNavigationAllowed() &&
396 (protocolIsJavaScript(url) || 394 (protocolIsJavaScript(url) ||
397 NavigationDisablerForUnload::isNavigationAllowed()); 395 NavigationDisablerForBeforeUnload::isNavigationAllowed());
398 } 396 }
399 397
400 void NavigationScheduler::scheduleRedirect(double delay, const String& url) { 398 void NavigationScheduler::scheduleRedirect(double delay, const String& url) {
401 if (!shouldScheduleNavigation(url)) 399 if (!shouldScheduleNavigation(url))
402 return; 400 return;
403 if (delay < 0 || delay > INT_MAX / 1000) 401 if (delay < 0 || delay > INT_MAX / 1000)
404 return; 402 return;
405 if (url.isEmpty()) 403 if (url.isEmpty())
406 return; 404 return;
407 405
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 m_navigateTaskFactory->cancel(); 547 m_navigateTaskFactory->cancel();
550 m_redirect.clear(); 548 m_redirect.clear();
551 } 549 }
552 550
553 DEFINE_TRACE(NavigationScheduler) { 551 DEFINE_TRACE(NavigationScheduler) {
554 visitor->trace(m_frame); 552 visitor->trace(m_frame);
555 visitor->trace(m_redirect); 553 visitor->trace(m_redirect);
556 } 554 }
557 555
558 } // namespace blink 556 } // namespace blink
OLDNEW
« 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