2009-10-01 Adam Barth <abarth@webkit.org>
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Oct 2009 07:57:48 +0000 (07:57 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Oct 2009 07:57:48 +0000 (07:57 +0000)
        Reviewed by Darin Adler.

        Move RedirectScheduler to its own file
        https://bugs.webkit.org/show_bug.cgi?id=29952

        This change is purely code motion.

        No behavior change.

        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * WebCoreSources.bkl:
        * loader/FrameLoader.cpp:
        * loader/FrameLoader.h:
        * loader/RedirectScheduler.cpp: Added.
        (WebCore::ScheduledRedirection::):
        (WebCore::ScheduledRedirection::ScheduledRedirection):
        (WebCore::RedirectScheduler::RedirectScheduler):
        (WebCore::RedirectScheduler::~RedirectScheduler):
        (WebCore::RedirectScheduler::redirectScheduledDuringLoad):
        (WebCore::RedirectScheduler::clear):
        (WebCore::RedirectScheduler::scheduleRedirect):
        (WebCore::RedirectScheduler::mustLockBackForwardList):
        (WebCore::RedirectScheduler::scheduleLocationChange):
        (WebCore::RedirectScheduler::scheduleFormSubmission):
        (WebCore::RedirectScheduler::scheduleRefresh):
        (WebCore::RedirectScheduler::locationChangePending):
        (WebCore::RedirectScheduler::scheduleHistoryNavigation):
        (WebCore::RedirectScheduler::timerFired):
        (WebCore::RedirectScheduler::schedule):
        (WebCore::RedirectScheduler::startTimer):
        (WebCore::RedirectScheduler::cancel):
        * loader/RedirectScheduler.h: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@49012 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.gypi
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/WebCoreSources.bkl
WebCore/loader/FrameLoader.cpp
WebCore/loader/FrameLoader.h

index e9ce08f9535aa1afe30e474fc902726fd66e6c54..4526e58a77f7a52d3b08a00316f1541a2847ea66 100644 (file)
@@ -1,3 +1,42 @@
+2009-10-01  Adam Barth  <abarth@webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Move RedirectScheduler to its own file
+        https://bugs.webkit.org/show_bug.cgi?id=29952
+
+        This change is purely code motion.
+
+        No behavior change.
+
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * WebCoreSources.bkl:
+        * loader/FrameLoader.cpp:
+        * loader/FrameLoader.h:
+        * loader/RedirectScheduler.cpp: Added.
+        (WebCore::ScheduledRedirection::):
+        (WebCore::ScheduledRedirection::ScheduledRedirection):
+        (WebCore::RedirectScheduler::RedirectScheduler):
+        (WebCore::RedirectScheduler::~RedirectScheduler):
+        (WebCore::RedirectScheduler::redirectScheduledDuringLoad):
+        (WebCore::RedirectScheduler::clear):
+        (WebCore::RedirectScheduler::scheduleRedirect):
+        (WebCore::RedirectScheduler::mustLockBackForwardList):
+        (WebCore::RedirectScheduler::scheduleLocationChange):
+        (WebCore::RedirectScheduler::scheduleFormSubmission):
+        (WebCore::RedirectScheduler::scheduleRefresh):
+        (WebCore::RedirectScheduler::locationChangePending):
+        (WebCore::RedirectScheduler::scheduleHistoryNavigation):
+        (WebCore::RedirectScheduler::timerFired):
+        (WebCore::RedirectScheduler::schedule):
+        (WebCore::RedirectScheduler::startTimer):
+        (WebCore::RedirectScheduler::cancel):
+        * loader/RedirectScheduler.h: Added.
+
 2009-10-02  Dave MacLachlan  <dmaclach@gmail.com>
 
         Reviewed by David Levin.
 
         * WebCore.xcodeproj/project.pbxproj:
 
-2009-10-01  Adam Barth  <abarth@webkit.org>
+2009-09-30  Adam Barth  <abarth@webkit.org>
 
         Reviewed by Darin Adler.
 
index 1d0c656d40391726e026f40d0e536300ee2d0aad..c8f8ced53a10ecf75a2daeb869f2cab1f678b2f8 100644 (file)
@@ -1244,6 +1244,8 @@ webcore_sources += \
        WebCore/loader/PluginDocument.h \
        WebCore/loader/ProgressTracker.cpp \
        WebCore/loader/ProgressTracker.h \
+       WebCore/loader/RedirectScheduler.cpp \
+       WebCore/loader/RedirectScheduler.h \
        WebCore/loader/Request.cpp \
        WebCore/loader/Request.h \
        WebCore/loader/ResourceLoader.cpp \
index 7766af1732902aaf72ba3f34f1f45387f20bd127..d5ed68094533e6bb744d40f80115561d5e5b6d00 100644 (file)
             'loader/PluginDocument.h',
             'loader/ProgressTracker.cpp',
             'loader/ProgressTracker.h',
+            'loader/RedirectScheduler.cpp',
+            'loader/RedirectScheduler.h',
             'loader/Request.cpp',
             'loader/Request.h',
             'loader/ResourceLoader.cpp',
index 003974c7473a7605f92c81f9c7b455e3e2d4105f..1684de23d9e07e197c9c88ace8eaf051c2f404e6 100644 (file)
@@ -1107,6 +1107,7 @@ SOURCES += \
     loader/PlaceholderDocument.cpp \
     loader/PluginDocument.cpp \
     loader/ProgressTracker.cpp \
+    loader/RedirectScheduler.cpp \
     loader/Request.cpp \
     loader/ResourceLoader.cpp \
     loader/SubresourceLoader.cpp \
index 97bb753e9c7c8a3e57f6f6db7cd31ce66287c953..a8f3bfd3a39c1387a90c16b990a75f4b3b9cb816 100644 (file)
                                RelativePath="..\loader\ProgressTracker.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\loader\RedirectScheduler.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\loader\RedirectScheduler.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\loader\Request.cpp"\r
                                >\r
index d40e38cbf48930eece0c7184f741dc6a94f364d3..155f82a57ec45d94c954c0c05d9fe4995d498482 100644 (file)
                93F9B7A00BA6032600854064 /* JSCDATASection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F9B79E0BA6032600854064 /* JSCDATASection.cpp */; };
                93F9B7A10BA6032600854064 /* JSCDATASection.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F9B79F0BA6032600854064 /* JSCDATASection.h */; };
                93FDAFCA0B11307400E2746F /* EditorInsertAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 93FDAFC90B11307400E2746F /* EditorInsertAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               979F43D31075E44A0000F83B /* RedirectScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 979F43D11075E44A0000F83B /* RedirectScheduler.cpp */; };
+               979F43D41075E44A0000F83B /* RedirectScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 979F43D21075E44A0000F83B /* RedirectScheduler.h */; };
                97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97DD4D840FDF4D6D00ECF9A4 /* XSSAuditor.cpp */; };
                97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */ = {isa = PBXBuildFile; fileRef = 97DD4D850FDF4D6E00ECF9A4 /* XSSAuditor.h */; };
                A17C81220F2A5CF7005DAAEB /* HTMLElementFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */; };
                93F9B79E0BA6032600854064 /* JSCDATASection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCDATASection.cpp; sourceTree = "<group>"; };
                93F9B79F0BA6032600854064 /* JSCDATASection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCDATASection.h; sourceTree = "<group>"; };
                93FDAFC90B11307400E2746F /* EditorInsertAction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EditorInsertAction.h; sourceTree = "<group>"; };
+               979F43D11075E44A0000F83B /* RedirectScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RedirectScheduler.cpp; sourceTree = "<group>"; };
+               979F43D21075E44A0000F83B /* RedirectScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RedirectScheduler.h; sourceTree = "<group>"; };
                97DD4D840FDF4D6D00ECF9A4 /* XSSAuditor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSSAuditor.cpp; sourceTree = "<group>"; };
                97DD4D850FDF4D6E00ECF9A4 /* XSSAuditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSSAuditor.h; sourceTree = "<group>"; };
                A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLElementFactory.cpp; sourceTree = "<group>"; };
                                1AC694C60A3B1676003F5049 /* PluginDocument.h */,
                                1A2A68210B5BEDE70002A480 /* ProgressTracker.cpp */,
                                1A2A68220B5BEDE70002A480 /* ProgressTracker.h */,
+                               979F43D11075E44A0000F83B /* RedirectScheduler.cpp */,
+                               979F43D21075E44A0000F83B /* RedirectScheduler.h */,
                                BCB16C150979C3BD00467741 /* Request.cpp */,
                                BCB16C160979C3BD00467741 /* Request.h */,
                                93E227DE0AF589AD00D48324 /* ResourceLoader.cpp */,
                                BCACF3BD1072921A00C0C8A3 /* UserContentURLPattern.h in Headers */,
                                5DB1BC6A10715A6400EFAA49 /* TransformSource.h in Headers */,
                                930FC68A1072B9280045293E /* TextRenderingMode.h in Headers */,
+                               979F43D41075E44A0000F83B /* RedirectScheduler.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                7693BAD3106C2DCA007B0823 /* PluginHalter.cpp in Sources */,
                                BCACF3BC1072921A00C0C8A3 /* UserContentURLPattern.cpp in Sources */,
                                5DB1BC6B10715A6400EFAA49 /* TransformSourceLibxslt.cpp in Sources */,
+                               979F43D31075E44A0000F83B /* RedirectScheduler.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index f4477456cf6ceaae7cff371c8052c03aaad57a10..013b4d66f06b984c0bec2d0dc4f29d454df982b7 100644 (file)
@@ -728,6 +728,7 @@ This file contains the list of files needed to build WebCore.
         loader/PlaceholderDocument.cpp
         loader/PluginDocument.cpp
         loader/ProgressTracker.cpp
+        loader/RedirectScheduler.cpp
         loader/Request.cpp
         loader/ResourceLoader.cpp
         loader/SubresourceLoader.cpp
index 5bfcc61681a91fa9574d027d9f82dc33eb1aa6e0..7addacd954886e188f18cfaa1cf41ec21a50990a 100644 (file)
@@ -123,110 +123,6 @@ using namespace SVGNames;
 #endif
 using namespace HTMLNames;
 
-struct ScheduledRedirection {
-    enum Type { redirection, locationChange, historyNavigation, formSubmission };
-
-    const Type type;
-    const double delay;
-    const String url;
-    const String referrer;
-    const FrameLoadRequest frameRequest;
-    const RefPtr<Event> event;
-    const RefPtr<FormState> formState;
-    const int historySteps;
-    const bool lockHistory;
-    const bool lockBackForwardList;
-    const bool wasUserGesture;
-    const bool wasRefresh;
-    const bool wasDuringLoad;
-    bool toldClient;
-
-    ScheduledRedirection(double delay, const String& url, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bool refresh)
-        : type(redirection)
-        , delay(delay)
-        , url(url)
-        , historySteps(0)
-        , lockHistory(lockHistory)
-        , lockBackForwardList(lockBackForwardList)
-        , wasUserGesture(wasUserGesture)
-        , wasRefresh(refresh)
-        , wasDuringLoad(false)
-        , toldClient(false)
-    {
-        ASSERT(!url.isEmpty());
-    }
-
-    ScheduledRedirection(const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bool refresh, bool duringLoad)
-        : type(locationChange)
-        , delay(0)
-        , url(url)
-        , referrer(referrer)
-        , historySteps(0)
-        , lockHistory(lockHistory)
-        , lockBackForwardList(lockBackForwardList)
-        , wasUserGesture(wasUserGesture)
-        , wasRefresh(refresh)
-        , wasDuringLoad(duringLoad)
-        , toldClient(false)
-    {
-        ASSERT(!url.isEmpty());
-    }
-
-    explicit ScheduledRedirection(int historyNavigationSteps)
-        : type(historyNavigation)
-        , delay(0)
-        , historySteps(historyNavigationSteps)
-        , lockHistory(false)
-        , lockBackForwardList(false)
-        , wasUserGesture(false)
-        , wasRefresh(false)
-        , wasDuringLoad(false)
-        , toldClient(false)
-    {
-    }
-
-    ScheduledRedirection(const FrameLoadRequest& frameRequest,
-            bool lockHistory, bool lockBackForwardList, PassRefPtr<Event> event, PassRefPtr<FormState> formState,
-            bool duringLoad)
-        : type(formSubmission)
-        , delay(0)
-        , frameRequest(frameRequest)
-        , event(event)
-        , formState(formState)
-        , historySteps(0)
-        , lockHistory(lockHistory)
-        , lockBackForwardList(lockBackForwardList)
-        , wasUserGesture(false)
-        , wasRefresh(false)
-        , wasDuringLoad(duringLoad)
-        , toldClient(false)
-    {
-        ASSERT(!frameRequest.isEmpty());
-        ASSERT(this->formState);
-    }
-};
-
-RedirectScheduler::RedirectScheduler(Frame* frame)
-    : m_frame(frame)
-    , m_timer(this, &RedirectScheduler::timerFired)
-{
-}
-
-RedirectScheduler::~RedirectScheduler()
-{
-}
-
-bool RedirectScheduler::redirectScheduledDuringLoad()
-{
-    return m_scheduledRedirection && m_scheduledRedirection->wasDuringLoad;
-}
-
-void RedirectScheduler::clear()
-{
-    m_timer.stop();
-    m_scheduledRedirection.clear();
-}
-
 #if ENABLE(XHTMLMP)
 static const char defaultAcceptHeader[] = "application/xml,application/vnd.wap.xhtml+xml,application/xhtml+xml;profile='http://www.wapforum.org/xhtml',text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
 #else
@@ -1374,117 +1270,6 @@ KURL FrameLoader::completeURL(const String& url)
     return m_frame->document()->completeURL(url);
 }
 
-void RedirectScheduler::scheduleRedirect(double delay, const String& url)
-{
-    if (delay < 0 || delay > INT_MAX / 1000)
-        return;
-        
-    if (!m_frame->page())
-        return;
-
-    if (url.isEmpty())
-        return;
-
-    // We want a new history item if the refresh timeout is > 1 second.
-    if (!m_scheduledRedirection || delay <= m_scheduledRedirection->delay)
-        schedule(new ScheduledRedirection(delay, url, true, delay <= 1, false, false));
-}
-
-bool RedirectScheduler::mustLockBackForwardList(Frame* targetFrame)
-{
-    // Navigation of a subframe during loading of an ancestor frame does not create a new back/forward item.
-    // The definition of "during load" is any time before all handlers for the load event have been run.
-    // See https://bugs.webkit.org/show_bug.cgi?id=14957 for the original motivation for this.
-    
-    for (Frame* ancestor = targetFrame->tree()->parent(); ancestor; ancestor = ancestor->tree()->parent()) {
-        Document* document = ancestor->document();
-        if (!ancestor->loader()->isComplete() || document && document->processingLoadEvent())
-            return true;
-    }
-    return false;
-}
-
-void RedirectScheduler::scheduleLocationChange(const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture)
-{
-    if (!m_frame->page())
-        return;
-
-    if (url.isEmpty())
-        return;
-
-    lockBackForwardList = lockBackForwardList || mustLockBackForwardList(m_frame);
-
-    FrameLoader* loader = m_frame->loader();
-    
-    // If the URL we're going to navigate to is the same as the current one, except for the
-    // fragment part, we don't need to schedule the location change.
-    KURL parsedURL(ParsedURLString, url);
-    if (parsedURL.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(loader->url(), parsedURL)) {
-        loader->changeLocation(loader->completeURL(url), referrer, lockHistory, lockBackForwardList, wasUserGesture);
-        return;
-    }
-
-    // Handle a location change of a page with no document as a special case.
-    // This may happen when a frame changes the location of another frame.
-    bool duringLoad = !loader->committedFirstRealDocumentLoad();
-
-    schedule(new ScheduledRedirection(url, referrer, lockHistory, lockBackForwardList, wasUserGesture, false, duringLoad));
-}
-
-void RedirectScheduler::scheduleFormSubmission(const FrameLoadRequest& frameRequest,
-    bool lockHistory, PassRefPtr<Event> event, PassRefPtr<FormState> formState)
-{
-    ASSERT(m_frame->page());
-    ASSERT(!frameRequest.isEmpty());
-
-    // FIXME: Do we need special handling for form submissions where the URL is the same
-    // as the current one except for the fragment part? See scheduleLocationChange above.
-
-    // Handle a location change of a page with no document as a special case.
-    // This may happen when a frame changes the location of another frame.
-    bool duringLoad = !m_frame->loader()->committedFirstRealDocumentLoad();
-
-    schedule(new ScheduledRedirection(frameRequest, lockHistory, mustLockBackForwardList(m_frame), event, formState, duringLoad));
-}
-
-void RedirectScheduler::scheduleRefresh(bool wasUserGesture)
-{
-    if (!m_frame->page())
-        return;
-    
-    const KURL& url = m_frame->loader()->url();
-
-    if (url.isEmpty())
-        return;
-
-    schedule(new ScheduledRedirection(url.string(), m_frame->loader()->outgoingReferrer(), true, true, wasUserGesture, true, false));
-}
-
-bool RedirectScheduler::locationChangePending()
-{
-    if (!m_scheduledRedirection)
-        return false;
-
-    switch (m_scheduledRedirection->type) {
-        case ScheduledRedirection::redirection:
-            return false;
-        case ScheduledRedirection::historyNavigation:
-        case ScheduledRedirection::locationChange:
-        case ScheduledRedirection::formSubmission:
-            return true;
-    }
-    ASSERT_NOT_REACHED();
-    return false;
-}
-
-void RedirectScheduler::scheduleHistoryNavigation(int steps)
-{
-    if (!m_frame->page())
-        return;
-
-    schedule(new ScheduledRedirection(steps));
-}
-
 void FrameLoader::goBackOrForward(int distance)
 {
     if (distance == 0)
@@ -1515,48 +1300,6 @@ void FrameLoader::goBackOrForward(int distance)
         page->goToItem(item, FrameLoadTypeIndexedBackForward);
 }
 
-void RedirectScheduler::timerFired(Timer<RedirectScheduler>*)
-{
-    ASSERT(m_frame->page());
-
-    if (m_frame->page()->defersLoading())
-        return;
-
-    OwnPtr<ScheduledRedirection> redirection(m_scheduledRedirection.release());
-    FrameLoader* loader = m_frame->loader();
-
-    switch (redirection->type) {
-        case ScheduledRedirection::redirection:
-        case ScheduledRedirection::locationChange:
-            loader->changeLocation(KURL(ParsedURLString, redirection->url), redirection->referrer,
-                redirection->lockHistory, redirection->lockBackForwardList, redirection->wasUserGesture, redirection->wasRefresh);
-            return;
-        case ScheduledRedirection::historyNavigation:
-            if (redirection->historySteps == 0) {
-                // Special case for go(0) from a frame -> reload only the frame
-                loader->urlSelected(loader->url(), "", 0, redirection->lockHistory, redirection->lockBackForwardList, redirection->wasUserGesture);
-                return;
-            }
-            // go(i!=0) from a frame navigates into the history of the frame only,
-            // in both IE and NS (but not in Mozilla). We can't easily do that.
-            if (loader->canGoBackOrForward(redirection->historySteps))
-                loader->goBackOrForward(redirection->historySteps);
-            return;
-        case ScheduledRedirection::formSubmission:
-            // The submitForm function will find a target frame before using the redirection timer.
-            // Now that the timer has fired, we need to repeat the security check which normally is done when
-            // selecting a target, in case conditions have changed. Other code paths avoid this by targeting
-            // without leaving a time window. If we fail the check just silently drop the form submission.
-            if (!redirection->formState->sourceFrame()->loader()->shouldAllowNavigation(m_frame))
-                return;
-            loader->loadFrameRequest(redirection->frameRequest, redirection->lockHistory, redirection->lockBackForwardList,
-                redirection->event, redirection->formState);
-            return;
-    }
-
-    ASSERT_NOT_REACHED();
-}
-
 void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer, Frame* childFrame)
 {
     ASSERT(childFrame);
@@ -2158,76 +1901,6 @@ bool FrameLoader::isComplete() const
     return m_isComplete;
 }
 
-void RedirectScheduler::schedule(PassOwnPtr<ScheduledRedirection> redirection)
-{
-    ASSERT(m_frame->page());
-    FrameLoader* loader = m_frame->loader();
-
-    // If a redirect was scheduled during a load, then stop the current load.
-    // Otherwise when the current load transitions from a provisional to a 
-    // committed state, pending redirects may be cancelled. 
-    if (redirection->wasDuringLoad) {
-        if (DocumentLoader* provisionalDocumentLoader = loader->provisionalDocumentLoader())
-            provisionalDocumentLoader->stopLoading();
-        loader->stopLoading(UnloadEventPolicyUnloadAndPageHide);   
-    }
-
-    cancel();
-    m_scheduledRedirection = redirection;
-    if (!loader->isComplete() && m_scheduledRedirection->type != ScheduledRedirection::redirection)
-        loader->completed();
-    startTimer();
-}
-
-void RedirectScheduler::startTimer()
-{
-    if (!m_scheduledRedirection)
-        return;
-
-    ASSERT(m_frame->page());
-    
-    FrameLoader* loader = m_frame->loader();
-
-    if (m_timer.isActive())
-        return;
-
-    if (m_scheduledRedirection->type == ScheduledRedirection::redirection && !loader->allAncestorsAreComplete())
-        return;
-
-    m_timer.startOneShot(m_scheduledRedirection->delay);
-
-    switch (m_scheduledRedirection->type) {
-        case ScheduledRedirection::locationChange:
-        case ScheduledRedirection::redirection:
-            if (m_scheduledRedirection->toldClient)
-                return;
-            m_scheduledRedirection->toldClient = true;
-            loader->clientRedirected(KURL(ParsedURLString, m_scheduledRedirection->url),
-                m_scheduledRedirection->delay,
-                currentTime() + m_timer.nextFireInterval(),
-                m_scheduledRedirection->lockBackForwardList);
-            return;
-        case ScheduledRedirection::formSubmission:
-            // FIXME: It would make sense to report form submissions as client redirects too.
-            // But we didn't do that in the past when form submission used a separate delay
-            // mechanism, so doing it will be a behavior change.
-            return;
-        case ScheduledRedirection::historyNavigation:
-            // Don't report history navigations.
-            return;
-    }
-    ASSERT_NOT_REACHED();
-}
-
-void RedirectScheduler::cancel(bool newLoadInProgress)
-{
-    m_timer.stop();
-
-    OwnPtr<ScheduledRedirection> redirection(m_scheduledRedirection.release());
-    if (redirection && redirection->toldClient)
-        m_frame->loader()->clientRedirectCancelledOrFinished(newLoadInProgress);
-}
-
 void FrameLoader::completed()
 {
     RefPtr<Frame> protect(m_frame);
index 229edfb5924afa8b8d26c0bf71cb2c303ea067c7..6fb639fe70cf61f708f9c441b742c94f6281b861 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "CachePolicy.h"
 #include "FrameLoaderTypes.h"
+#include "RedirectScheduler.h"
 #include "ResourceRequest.h"
 #include "ThreadableLoader.h"
 #include "Timer.h"
@@ -72,7 +73,6 @@ namespace WebCore {
     class Widget;
 
     struct FrameLoadRequest;
-    struct ScheduledRedirection;
     struct WindowFeatures;
 
     bool isBackForwardLoadType(FrameLoadType);
@@ -112,36 +112,6 @@ namespace WebCore {
         void* m_argument;
     };
 
-    class RedirectScheduler : public Noncopyable {
-    public:
-        RedirectScheduler(Frame*);
-        ~RedirectScheduler();
-
-        bool redirectScheduledDuringLoad();
-        bool locationChangePending();
-
-        void scheduleRedirect(double delay, const String& url);
-        void scheduleLocationChange(const String& url, const String& referrer, bool lockHistory = true, bool lockBackForwardList = true, bool userGesture = false);
-        void scheduleFormSubmission(const FrameLoadRequest&, bool lockHistory, PassRefPtr<Event>, PassRefPtr<FormState>);
-        void scheduleRefresh(bool userGesture = false);
-        void scheduleHistoryNavigation(int steps);
-
-        void startTimer();
-
-        void cancel(bool newLoadInProgress = false);
-        void clear();
-
-    private:
-        void timerFired(Timer<RedirectScheduler>*);
-        void schedule(PassOwnPtr<ScheduledRedirection> redirection);
-
-        static bool mustLockBackForwardList(Frame* targetFrame);
-
-        Frame* m_frame;
-        Timer<RedirectScheduler> m_timer;
-        OwnPtr<ScheduledRedirection> m_scheduledRedirection;
-    };
-
     class FrameLoader : public Noncopyable {
     public:
         FrameLoader(Frame*, FrameLoaderClient*);