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

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: Remove CHECK for redirect chain as the redirects may not be populated for provisional loads for ren… Created 3 years, 10 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 66aa1f2aeaf50bff4420f900c6186943fb9d8b15..f773065636dfe57d0ae6fe63423fc7970a3b896d 100644
--- a/third_party/WebKit/Source/core/loader/FrameLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
@@ -1730,26 +1730,44 @@ void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest,
if (!checkLoadCanStart(frameLoadRequest, type, navigationPolicy,
navigationType)) {
- // PlzNavigate: if the navigation is a commit of a client-handled
- // navigation, record that there is no longer a navigation handled by the
- // client.
- if (m_isNavigationHandledByClient &&
- !frameLoadRequest.resourceRequest().checkForBrowserSideNavigation()) {
- m_isNavigationHandledByClient = false;
+ if (m_isNavigationHandledByClient) {
+ // PlzNavigate: if the navigation is a commit of a client-handled
+ // navigation, record that there is no longer a navigation handled by the
+ // client.
+ if (!frameLoadRequest.resourceRequest().checkForBrowserSideNavigation()) {
+ m_isNavigationHandledByClient = false;
+ } else {
+ 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 +1789,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);
DCHECK(m_provisionalDocumentLoader);
+
m_provisionalDocumentLoader->startLoadingMainResource();
takeObjectSnapshot();
@@ -1963,4 +1985,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