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

Unified Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2661743002: PlzNavigate: Invoke didStartProvisionalLoad() when the renderer initiates a navigation in startLoad( (Closed)
Patch Set: Fix test failures. 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/loader/FrameLoader.cpp
diff --git a/third_party/WebKit/Source/core/loader/FrameLoader.cpp b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
index f90f72cb79180c0490f90689f16dfc61b73f5469..1730efe2502ec34df17c6a8cfafbf611d0748b5e 100644
--- a/third_party/WebKit/Source/core/loader/FrameLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
@@ -1737,19 +1737,35 @@ void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest,
!frameLoadRequest.resourceRequest().checkForBrowserSideNavigation()) {
m_isNavigationHandledByClient = false;
}
+ if (m_isNavigationHandledByClient) {
+ DocumentLoader* loader = createDocumentLoader(
+ resourceRequest, frameLoadRequest, type, navigationType);
+ // PlzNavigate: If the navigation is handled by the client, then the
+ // didFinishDocumentLoad() event occurs before the
+ // didStartProvisionalLoad() notification which occurs after the
+ // navigation
+ // is committed. This causes a number of layout tests to fail. We
+ // workaround this by invoking the didStartProvisionalLoad() notification
+ // here. Consumers of the didStartProvisionalLoad() notification rely on
+ // the provisional loader and save navigation state in it. We want to
+ // avoid
+ // this dependency on the provisional loader. For now we create a
+ // temporary
+ // loader and pass it to the didStartProvisionalLoad() function.
+ // TODO(ananta)
+ // We should get rid of the dependency on the DocumentLoader in consumers
+ // of
+ // the didStartProvisionalLoad() notification.
+ client()->dispatchDidStartProvisionalLoad(loader);
+ DCHECK(loader);
+ loader->setSentDidFinishLoad();
+ loader->detachFromFrame();
+ }
return;
}
- m_provisionalDocumentLoader = client()->createDocumentLoader(
- m_frame, resourceRequest,
- frameLoadRequest.substituteData().isValid()
- ? frameLoadRequest.substituteData()
- : defaultSubstituteDataForURL(resourceRequest.url()),
- frameLoadRequest.clientRedirect());
- m_provisionalDocumentLoader->setLoadType(type);
- m_provisionalDocumentLoader->setNavigationType(navigationType);
- m_provisionalDocumentLoader->setReplacesCurrentHistoryItem(
- type == FrameLoadTypeReplaceCurrentItem);
+ m_provisionalDocumentLoader = createDocumentLoader(
+ resourceRequest, frameLoadRequest, type, navigationType);
// PlzNavigate: We need to ensure that script initiated navigations are
// honored.
@@ -1771,8 +1787,12 @@ void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest,
m_provisionalDocumentLoader->appendRedirect(
m_provisionalDocumentLoader->getRequest().url());
- client()->dispatchDidStartProvisionalLoad();
+ // TODO(ananta)
+ // We should get rid of the dependency on the DocumentLoader in consumers of
+ // the didStartProvisionalLoad() notification.
+ client()->dispatchDidStartProvisionalLoad(m_provisionalDocumentLoader);
Nate Chapin 2017/02/03 19:35:22 Why did this move back here? No objections, just c
ananta 2017/02/03 20:42:00 Sending the provisional load notification early ca
DCHECK(m_provisionalDocumentLoader);
+
m_provisionalDocumentLoader->startLoadingMainResource();
takeObjectSnapshot();
@@ -1963,4 +1983,22 @@ inline void FrameLoader::takeObjectSnapshot() const {
toTracedValue());
}
+DocumentLoader* FrameLoader::createDocumentLoader(
+ const ResourceRequest& request,
+ const FrameLoadRequest& frameLoadRequest,
+ FrameLoadType loadType,
+ NavigationType navigationType) {
+ DocumentLoader* loader = client()->createDocumentLoader(
+ m_frame, request, frameLoadRequest.substituteData().isValid()
+ ? frameLoadRequest.substituteData()
+ : defaultSubstituteDataForURL(request.url()),
+ frameLoadRequest.clientRedirect());
+
+ loader->setLoadType(loadType);
+ loader->setNavigationType(navigationType);
+ loader->setReplacesCurrentHistoryItem(loadType ==
+ FrameLoadTypeReplaceCurrentItem);
+ return loader;
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameLoader.h ('k') | third_party/WebKit/Source/core/loader/FrameLoaderClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698