Commit 04bf4e52 authored by Dmitry Gozman's avatar Dmitry Gozman Committed by Commit Bot

FrameLoader: split start and commit code paths pt1

This splits LoadInternal and removes it.

Bug: 789577
Change-Id: I4931659a1f50890fcda489e74591d12a2d2c4419
Reviewed-on: https://chromium-review.googlesource.com/1083823Reviewed-by: default avatarCamille Lamy <clamy@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565696}
parent 7ffe8277
...@@ -854,35 +854,13 @@ void FrameLoader::StartNavigation(const FrameLoadRequest& passed_request, ...@@ -854,35 +854,13 @@ void FrameLoader::StartNavigation(const FrameLoadRequest& passed_request,
FrameLoadType frame_load_type, FrameLoadType frame_load_type,
HistoryItem* history_item) { HistoryItem* history_item) {
CHECK(!passed_request.GetSubstituteData().IsValid()); CHECK(!passed_request.GetSubstituteData().IsValid());
CHECK(frame_load_type != kFrameLoadTypeBackForward); CHECK(!IsBackForwardLoadType(frame_load_type));
CHECK(!history_item); CHECK(!history_item);
return LoadInternal(passed_request, frame_load_type, history_item,
true /* check_with_client */);
}
void FrameLoader::CommitNavigation(const FrameLoadRequest& passed_request,
FrameLoadType frame_load_type,
HistoryItem* history_item) {
CHECK(!passed_request.OriginDocument());
CHECK(passed_request.FrameName().IsEmpty());
CHECK(!passed_request.TriggeringEvent());
CHECK(!passed_request.Form());
return LoadInternal(passed_request, frame_load_type, history_item,
false /* check_with_client */);
}
void FrameLoader::LoadInternal(const FrameLoadRequest& passed_request,
FrameLoadType frame_load_type,
HistoryItem* history_item,
bool check_with_client) {
DCHECK(frame_->GetDocument()); DCHECK(frame_->GetDocument());
if (HTMLFrameOwnerElement* element = frame_->DeprecatedLocalOwner()) if (HTMLFrameOwnerElement* element = frame_->DeprecatedLocalOwner())
element->CancelPendingLazyLoad(); element->CancelPendingLazyLoad();
if (IsBackForwardLoadType(frame_load_type) && !frame_->IsNavigationAllowed())
return;
if (in_stop_all_loaders_) if (in_stop_all_loaders_)
return; return;
...@@ -937,26 +915,63 @@ void FrameLoader::LoadInternal(const FrameLoadRequest& passed_request, ...@@ -937,26 +915,63 @@ void FrameLoader::LoadInternal(const FrameLoadRequest& passed_request,
return; return;
const KURL& url = request.GetResourceRequest().Url(); const KURL& url = request.GetResourceRequest().Url();
FrameLoadType new_load_type = (frame_load_type == kFrameLoadTypeStandard) if (frame_load_type == kFrameLoadTypeStandard)
? DetermineFrameLoadType(request) frame_load_type = DetermineFrameLoadType(request);
: frame_load_type;
bool same_document_navigation = bool same_document_navigation =
policy == kNavigationPolicyCurrentTab && policy == kNavigationPolicyCurrentTab &&
ShouldPerformFragmentNavigation(request.Form(), ShouldPerformFragmentNavigation(request.Form(),
request.GetResourceRequest().HttpMethod(), request.GetResourceRequest().HttpMethod(),
new_load_type, url); frame_load_type, url);
// Perform same document navigation. // Perform same document navigation.
if (same_document_navigation) { if (same_document_navigation) {
CommitSameDocumentNavigation( CommitSameDocumentNavigation(
request.GetResourceRequest().Url(), new_load_type, history_item, request.GetResourceRequest().Url(), frame_load_type, nullptr,
request.ClientRedirect(), request.OriginDocument(), request.ClientRedirect(), request.OriginDocument(),
request.TriggeringEvent()); request.TriggeringEvent());
return; return;
} }
StartLoad(request, new_load_type, policy, history_item, check_with_client); StartLoad(request, frame_load_type, policy, nullptr,
true /* check_with_client */);
}
void FrameLoader::CommitNavigation(const FrameLoadRequest& passed_request,
FrameLoadType frame_load_type,
HistoryItem* history_item) {
CHECK(!passed_request.OriginDocument());
CHECK(passed_request.FrameName().IsEmpty());
CHECK(!passed_request.TriggeringEvent());
CHECK(!passed_request.Form());
DCHECK(frame_->GetDocument());
DCHECK(!in_stop_all_loaders_);
DCHECK(frame_->IsNavigationAllowed());
// TODO(dgozman): figure out the better place for this check
// to cancel lazy load both on start and commit. Perhaps
// CreateDocumentLoader() is a good one.
if (HTMLFrameOwnerElement* element = frame_->DeprecatedLocalOwner())
element->CancelPendingLazyLoad();
FrameLoadRequest request(passed_request);
request.GetResourceRequest().SetHasUserGesture(
Frame::HasTransientUserActivation(frame_));
if (frame_load_type == kFrameLoadTypeStandard)
frame_load_type = DetermineFrameLoadType(request);
// Note: we might actually classify this navigation as same document
// right here in the following circumstances:
// - the loader has already committed a navigation and notified the browser
// process which did not receive a message about that just yet;
// - meanwhile, the browser process sent us a command to commit this new
// "cross-document" navigation, while it's actually same-document
// with regards to the last commit.
// In this rare case, we intentionally proceed as cross-document.
StartLoad(request, frame_load_type, kNavigationPolicyCurrentTab, history_item,
false /* check_with_client */);
} }
mojom::CommitResult FrameLoader::CommitSameDocumentNavigation( mojom::CommitResult FrameLoader::CommitSameDocumentNavigation(
......
...@@ -266,10 +266,6 @@ class CORE_EXPORT FrameLoader final { ...@@ -266,10 +266,6 @@ class CORE_EXPORT FrameLoader final {
NavigationPolicy, NavigationPolicy,
NavigationType, NavigationType,
bool check_with_client); bool check_with_client);
void LoadInternal(const FrameLoadRequest&,
FrameLoadType,
HistoryItem*,
bool check_with_client);
void StartLoad(FrameLoadRequest&, void StartLoad(FrameLoadRequest&,
FrameLoadType, FrameLoadType,
NavigationPolicy, NavigationPolicy,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment