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

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

Issue 2563423004: Always send a fail or finish notification for each navigation. (Closed)
Patch Set: fix unit tests 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, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
6 * (http://www.torchmobile.com/) 6 * (http://www.torchmobile.com/)
7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
10 * Copyright (C) 2011 Google Inc. All rights reserved. 10 * Copyright (C) 2011 Google Inc. All rights reserved.
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 initialRequest.setFrameType(m_frame->isMainFrame() 219 initialRequest.setFrameType(m_frame->isMainFrame()
220 ? WebURLRequest::FrameTypeTopLevel 220 ? WebURLRequest::FrameTypeTopLevel
221 : WebURLRequest::FrameTypeNested); 221 : WebURLRequest::FrameTypeNested);
222 m_provisionalDocumentLoader = 222 m_provisionalDocumentLoader =
223 client()->createDocumentLoader(m_frame, initialRequest, SubstituteData(), 223 client()->createDocumentLoader(m_frame, initialRequest, SubstituteData(),
224 ClientRedirectPolicy::NotClientRedirect); 224 ClientRedirectPolicy::NotClientRedirect);
225 m_provisionalDocumentLoader->startLoadingMainResource(); 225 m_provisionalDocumentLoader->startLoadingMainResource();
226 m_frame->document()->cancelParsing(); 226 m_frame->document()->cancelParsing();
227 m_stateMachine.advanceTo( 227 m_stateMachine.advanceTo(
228 FrameLoaderStateMachine::DisplayingInitialEmptyDocument); 228 FrameLoaderStateMachine::DisplayingInitialEmptyDocument);
229 // Suppress finish notifications for inital empty documents, since they don't
230 // generate start notifications.
dcheng 2016/12/14 23:01:28 Unrelated, but do you think it'd be problematic to
Nate Chapin 2016/12/14 23:59:18 Extensions might inject content scripts into initi
231 if (m_documentLoader)
232 m_documentLoader->setSentDidFinishLoad();
229 // Self-suspend if created in an already suspended Page. Note that both 233 // Self-suspend if created in an already suspended Page. Note that both
230 // startLoadingMainResource() and cancelParsing() may have already detached 234 // startLoadingMainResource() and cancelParsing() may have already detached
231 // the frame, since they both fire JS events. 235 // the frame, since they both fire JS events.
232 if (m_frame->page() && m_frame->page()->suspended()) 236 if (m_frame->page() && m_frame->page()->suspended())
233 setDefersLoading(true); 237 setDefersLoading(true);
234 takeObjectSnapshot(); 238 takeObjectSnapshot();
235 } 239 }
236 240
237 FrameLoaderClient* FrameLoader::client() const { 241 FrameLoaderClient* FrameLoader::client() const {
238 return static_cast<FrameLoaderClient*>(m_frame->client()); 242 return static_cast<FrameLoaderClient*>(m_frame->client());
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 if (!document->haveImportsLoaded()) 670 if (!document->haveImportsLoaded())
667 return false; 671 return false;
668 if (document->fetcher()->requestCount()) 672 if (document->fetcher()->requestCount())
669 return false; 673 return false;
670 if (document->isDelayingLoadEvent()) 674 if (document->isDelayingLoadEvent())
671 return false; 675 return false;
672 return allDescendantsAreComplete(document->frame()); 676 return allDescendantsAreComplete(document->frame());
673 } 677 }
674 678
675 static bool shouldSendFinishNotification(LocalFrame* frame) { 679 static bool shouldSendFinishNotification(LocalFrame* frame) {
676 // Don't send stop notifications for inital empty documents, since they don't
677 // generate start notifications.
678 if (!frame->loader().stateMachine()->committedFirstRealDocumentLoad())
Nate Chapin 2016/12/12 21:40:38 setSentDidFinishLoad() in init() instead.
679 return false;
680
681 // Don't send didFinishLoad more than once per DocumentLoader. 680 // Don't send didFinishLoad more than once per DocumentLoader.
682 if (frame->loader().documentLoader()->sentDidFinishLoad()) 681 if (frame->loader().documentLoader()->sentDidFinishLoad())
683 return false; 682 return false;
684 683
685 // We might have declined to run the load event due to an imminent 684 // We might have declined to run the load event due to an imminent
686 // content-initiated navigation. 685 // content-initiated navigation.
687 if (!frame->document()->loadEventFinished()) 686 if (!frame->document()->loadEventFinished())
688 return false; 687 return false;
689 688
690 // An event might have restarted a child frame. 689 // An event might have restarted a child frame.
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 void FrameLoader::loadFailed(DocumentLoader* loader, 1461 void FrameLoader::loadFailed(DocumentLoader* loader,
1463 const ResourceError& error) { 1462 const ResourceError& error) {
1464 if (!error.isCancellation() && m_frame->owner()) { 1463 if (!error.isCancellation() && m_frame->owner()) {
1465 // FIXME: For now, fallback content doesn't work cross process. 1464 // FIXME: For now, fallback content doesn't work cross process.
1466 if (m_frame->owner()->isLocal()) 1465 if (m_frame->owner()->isLocal())
1467 m_frame->deprecatedLocalOwner()->renderFallbackContent(); 1466 m_frame->deprecatedLocalOwner()->renderFallbackContent();
1468 } 1467 }
1469 1468
1470 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType); 1469 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType);
1471 if (loader == m_provisionalDocumentLoader) { 1470 if (loader == m_provisionalDocumentLoader) {
1471 m_provisionalDocumentLoader->setSentDidFinishLoad();
1472 client()->dispatchDidFailProvisionalLoad(error, historyCommitType); 1472 client()->dispatchDidFailProvisionalLoad(error, historyCommitType);
1473 if (loader != m_provisionalDocumentLoader) 1473 if (loader != m_provisionalDocumentLoader)
1474 return; 1474 return;
1475 detachDocumentLoader(m_provisionalDocumentLoader); 1475 detachDocumentLoader(m_provisionalDocumentLoader);
1476 m_progressTracker->progressCompleted();
Nate Chapin 2016/12/12 21:40:38 progressCompleted() should be called if appropriat
dcheng 2016/12/14 23:01:28 Seems subtle, but I agree this should work.
1477 } else { 1476 } else {
1478 DCHECK_EQ(loader, m_documentLoader); 1477 DCHECK_EQ(loader, m_documentLoader);
1479 if (m_frame->document()->parser()) 1478 if (m_frame->document()->parser())
1480 m_frame->document()->parser()->stopParsing(); 1479 m_frame->document()->parser()->stopParsing();
1481 m_documentLoader->setSentDidFinishLoad(); 1480 if (!m_documentLoader->sentDidFinishLoad()) {
1482 if (!m_provisionalDocumentLoader && m_frame->isLoading()) { 1481 m_documentLoader->setSentDidFinishLoad();
1483 client()->dispatchDidFailLoad(error, historyCommitType); 1482 client()->dispatchDidFailLoad(error, historyCommitType);
1484 m_progressTracker->progressCompleted();
1485 } 1483 }
1486 } 1484 }
1487 checkCompleted(); 1485 checkCompleted();
1488 } 1486 }
1489 1487
1490 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, 1488 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission,
1491 const String& httpMethod, 1489 const String& httpMethod,
1492 FrameLoadType loadType, 1490 FrameLoadType loadType,
1493 const KURL& url) { 1491 const KURL& url) {
1494 // We don't do this if we are submitting a form with method other than "GET", 1492 // We don't do this if we are submitting a form with method other than "GET",
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 m_documentLoader ? m_documentLoader->url() : String()); 1957 m_documentLoader ? m_documentLoader->url() : String());
1960 return tracedValue; 1958 return tracedValue;
1961 } 1959 }
1962 1960
1963 inline void FrameLoader::takeObjectSnapshot() const { 1961 inline void FrameLoader::takeObjectSnapshot() const {
1964 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, 1962 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this,
1965 toTracedValue()); 1963 toTracedValue());
1966 } 1964 }
1967 1965
1968 } // namespace blink 1966 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698