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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl.cc

Issue 2368183004: Move redirect_chain from NavigationEntry to FrameNavigationEntry. (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /* 5 /*
6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 frame_tree_node_id = node->frame_tree_node_id(); 697 frame_tree_node_id = node->frame_tree_node_id();
698 698
699 // In --site-per-process, create an identical NavigationEntry with a 699 // In --site-per-process, create an identical NavigationEntry with a
700 // new FrameNavigationEntry for the target subframe. 700 // new FrameNavigationEntry for the target subframe.
701 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 701 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
702 entry = GetLastCommittedEntry()->Clone(); 702 entry = GetLastCommittedEntry()->Clone();
703 entry->SetPageID(-1); 703 entry->SetPageID(-1);
704 entry->AddOrUpdateFrameEntry( 704 entry->AddOrUpdateFrameEntry(
705 node, -1, -1, nullptr, 705 node, -1, -1, nullptr,
706 static_cast<SiteInstanceImpl*>(params.source_site_instance.get()), 706 static_cast<SiteInstanceImpl*>(params.source_site_instance.get()),
707 params.url, params.referrer, PageState(), "GET", -1); 707 params.redirect_chain, params.url, params.referrer, PageState(),
708 "GET", -1);
708 } 709 }
709 } 710 }
710 } 711 }
711 712
712 // Otherwise, create a pending entry for the main frame. 713 // Otherwise, create a pending entry for the main frame.
713 if (!entry) { 714 if (!entry) {
714 entry = NavigationEntryImpl::FromNavigationEntry(CreateNavigationEntry( 715 entry = NavigationEntryImpl::FromNavigationEntry(CreateNavigationEntry(
715 params.url, params.referrer, params.transition_type, 716 params.url, params.referrer, params.transition_type,
716 params.is_renderer_initiated, params.extra_headers, browser_context_)); 717 params.is_renderer_initiated, params.extra_headers, browser_context_));
717 entry->set_source_site_instance( 718 entry->set_source_site_instance(
718 static_cast<SiteInstanceImpl*>(params.source_site_instance.get())); 719 static_cast<SiteInstanceImpl*>(params.source_site_instance.get()));
720 if (params.redirect_chain.size() > 0)
721 entry->SetMainFrameRedirectChain(params.redirect_chain);
arthursonzogni 2016/09/27 12:56:20 I don't know the reasons why the main frame redire
Charlie Reis 2016/09/28 04:13:17 Let's remove the size check. Originally, calling
arthursonzogni 2016/09/28 16:36:14 Done.
719 } 722 }
720 723
721 // Set the FTN ID (only used in non-site-per-process, for tests). 724 // Set the FTN ID (only used in non-site-per-process, for tests).
722 entry->set_frame_tree_node_id(frame_tree_node_id); 725 entry->set_frame_tree_node_id(frame_tree_node_id);
723 if (params.redirect_chain.size() > 0)
724 entry->SetRedirectChain(params.redirect_chain);
725 // Don't allow an entry replacement if there is no entry to replace. 726 // Don't allow an entry replacement if there is no entry to replace.
726 // http://crbug.com/457149 727 // http://crbug.com/457149
727 if (params.should_replace_current_entry && entries_.size() > 0) 728 if (params.should_replace_current_entry && entries_.size() > 0)
728 entry->set_should_replace_entry(true); 729 entry->set_should_replace_entry(true);
729 entry->set_should_clear_history_list(params.should_clear_history_list); 730 entry->set_should_clear_history_list(params.should_clear_history_list);
730 entry->SetIsOverridingUserAgent(override); 731 entry->SetIsOverridingUserAgent(override);
731 entry->set_transferred_global_request_id( 732 entry->set_transferred_global_request_id(
732 params.transferred_global_request_id); 733 params.transferred_global_request_id);
733 734
734 #if defined(OS_ANDROID) 735 #if defined(OS_ANDROID)
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 base::debug::DumpWithoutCrashing(); 864 base::debug::DumpWithoutCrashing();
864 NOTREACHED() << "Shouldn't see an empty PageState at commit."; 865 NOTREACHED() << "Shouldn't see an empty PageState at commit.";
865 } 866 }
866 NavigationEntryImpl* active_entry = GetLastCommittedEntry(); 867 NavigationEntryImpl* active_entry = GetLastCommittedEntry();
867 active_entry->SetTimestamp(timestamp); 868 active_entry->SetTimestamp(timestamp);
868 active_entry->SetHttpStatusCode(params.http_status_code); 869 active_entry->SetHttpStatusCode(params.http_status_code);
869 870
870 FrameNavigationEntry* frame_entry = 871 FrameNavigationEntry* frame_entry =
871 active_entry->GetFrameEntry(rfh->frame_tree_node()); 872 active_entry->GetFrameEntry(rfh->frame_tree_node());
872 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 873 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
873 // Update the frame-specific PageState. 874 // Update the frame-specific PageState and RedirectChain
874 // We may not find a frame_entry in some cases; ignore the PageState if so. 875 // We may not find a frame_entry in some cases; ignore the PageState if so.
875 // TODO(creis): Remove the "if" once https://crbug.com/522193 is fixed. 876 // TODO(creis): Remove the "if" once https://crbug.com/522193 is fixed.
876 if (frame_entry) 877 if (frame_entry) {
877 frame_entry->SetPageState(params.page_state); 878 frame_entry->SetPageState(params.page_state);
879 frame_entry->set_redirect_chain(params.redirects);
880 }
878 } else { 881 } else {
879 active_entry->SetPageState(params.page_state); 882 active_entry->SetPageState(params.page_state);
883 active_entry->SetMainFrameRedirectChain(params.redirects);
880 } 884 }
881 active_entry->SetRedirectChain(params.redirects);
882 885
883 // Use histogram to track memory impact of redirect chain because it's now 886 // Use histogram to track memory impact of redirect chain because it's now
884 // not cleared for committed entries. 887 // not cleared for committed entries.
885 size_t redirect_chain_size = 0; 888 size_t redirect_chain_size = 0;
886 for (size_t i = 0; i < params.redirects.size(); ++i) { 889 for (size_t i = 0; i < params.redirects.size(); ++i) {
887 redirect_chain_size += params.redirects[i].spec().length(); 890 redirect_chain_size += params.redirects[i].spec().length();
888 } 891 }
889 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size); 892 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size);
890 893
891 // Once it is committed, we no longer need to track several pieces of state on 894 // Once it is committed, we no longer need to track several pieces of state on
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 // The site instance will normally be the same except during session restore, 1206 // The site instance will normally be the same except during session restore,
1204 // when no site instance will be assigned. 1207 // when no site instance will be assigned.
1205 DCHECK(entry->site_instance() == nullptr || 1208 DCHECK(entry->site_instance() == nullptr ||
1206 entry->site_instance() == rfh->GetSiteInstance()); 1209 entry->site_instance() == rfh->GetSiteInstance());
1207 1210
1208 // Update the existing FrameNavigationEntry to ensure all of its members 1211 // Update the existing FrameNavigationEntry to ensure all of its members
1209 // reflect the parameters coming from the renderer process. 1212 // reflect the parameters coming from the renderer process.
1210 entry->AddOrUpdateFrameEntry( 1213 entry->AddOrUpdateFrameEntry(
1211 rfh->frame_tree_node(), params.item_sequence_number, 1214 rfh->frame_tree_node(), params.item_sequence_number,
1212 params.document_sequence_number, rfh->GetSiteInstance(), nullptr, 1215 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1213 params.url, params.referrer, params.page_state, params.method, 1216 params.redirects, params.url, params.referrer, params.page_state,
1214 params.post_id); 1217 params.method, params.post_id);
arthursonzogni 2016/09/27 12:56:20 I want to warn that previously, params.redirects w
Charlie Reis 2016/09/28 04:13:17 This case and the SamePage one were covered by the
arthursonzogni 2016/09/28 16:36:14 I'm glad that it fix a new bug! Thanks for the rep
1215 1218
1216 // The redirected to page should not inherit the favicon from the previous 1219 // The redirected to page should not inherit the favicon from the previous
1217 // page. 1220 // page.
1218 if (ui::PageTransitionIsRedirect(params.transition) && !is_in_page) 1221 if (ui::PageTransitionIsRedirect(params.transition) && !is_in_page)
1219 entry->GetFavicon() = FaviconStatus(); 1222 entry->GetFavicon() = FaviconStatus();
1220 1223
1221 // The entry we found in the list might be pending if the user hit 1224 // The entry we found in the list might be pending if the user hit
1222 // back/forward/reload. This load should commit it (since it's already in the 1225 // back/forward/reload. This load should commit it (since it's already in the
1223 // list, we can just discard the pending pointer). We should also discard the 1226 // list, we can just discard the pending pointer). We should also discard the
1224 // pending entry if it corresponds to a different navigation, since that one 1227 // pending entry if it corresponds to a different navigation, since that one
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 // If a user presses enter in the omnibox and the server redirects, the URL 1264 // If a user presses enter in the omnibox and the server redirects, the URL
1262 // might change (but it's still considered a SAME_PAGE navigation). So we must 1265 // might change (but it's still considered a SAME_PAGE navigation). So we must
1263 // update the SSL status. 1266 // update the SSL status.
1264 existing_entry->GetSSL() = rfh->navigation_handle()->ssl_status(); 1267 existing_entry->GetSSL() = rfh->navigation_handle()->ssl_status();
1265 1268
1266 // Update the existing FrameNavigationEntry to ensure all of its members 1269 // Update the existing FrameNavigationEntry to ensure all of its members
1267 // reflect the parameters coming from the renderer process. 1270 // reflect the parameters coming from the renderer process.
1268 existing_entry->AddOrUpdateFrameEntry( 1271 existing_entry->AddOrUpdateFrameEntry(
1269 rfh->frame_tree_node(), params.item_sequence_number, 1272 rfh->frame_tree_node(), params.item_sequence_number,
1270 params.document_sequence_number, rfh->GetSiteInstance(), nullptr, 1273 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1271 params.url, params.referrer, params.page_state, params.method, 1274 params.redirects, params.url, params.referrer, params.page_state,
1272 params.post_id); 1275 params.method, params.post_id);
1273 1276
1274 DiscardNonCommittedEntries(); 1277 DiscardNonCommittedEntries();
1275 } 1278 }
1276 1279
1277 void NavigationControllerImpl::RendererDidNavigateNewSubframe( 1280 void NavigationControllerImpl::RendererDidNavigateNewSubframe(
1278 RenderFrameHostImpl* rfh, 1281 RenderFrameHostImpl* rfh,
1279 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 1282 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1280 bool is_in_page, 1283 bool is_in_page,
1281 bool replace_entry) { 1284 bool replace_entry) {
1282 DCHECK(ui::PageTransitionCoreTypeIs(params.transition, 1285 DCHECK(ui::PageTransitionCoreTypeIs(params.transition,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 } 1363 }
1361 } 1364 }
1362 1365
1363 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 1366 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1364 // This may be a "new auto" case where we add a new FrameNavigationEntry, or 1367 // This may be a "new auto" case where we add a new FrameNavigationEntry, or
1365 // it may be a "history auto" case where we update an existing one. 1368 // it may be a "history auto" case where we update an existing one.
1366 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); 1369 NavigationEntryImpl* last_committed = GetLastCommittedEntry();
1367 last_committed->AddOrUpdateFrameEntry( 1370 last_committed->AddOrUpdateFrameEntry(
1368 rfh->frame_tree_node(), params.item_sequence_number, 1371 rfh->frame_tree_node(), params.item_sequence_number,
1369 params.document_sequence_number, rfh->GetSiteInstance(), nullptr, 1372 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1370 params.url, params.referrer, params.page_state, params.method, 1373 params.redirects, params.url, params.referrer, params.page_state,
1371 params.post_id); 1374 params.method, params.post_id);
1372 } 1375 }
1373 1376
1374 return send_commit_notification; 1377 return send_commit_notification;
1375 } 1378 }
1376 1379
1377 int NavigationControllerImpl::GetIndexOfEntry( 1380 int NavigationControllerImpl::GetIndexOfEntry(
1378 const NavigationEntryImpl* entry) const { 1381 const NavigationEntryImpl* entry) const {
1379 for (size_t i = 0; i < entries_.size(); ++i) { 1382 for (size_t i = 0; i < entries_.size(); ++i) {
1380 if (entries_[i].get() == entry) 1383 if (entries_[i].get() == entry)
1381 return i; 1384 return i;
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 } 2107 }
2105 } 2108 }
2106 } 2109 }
2107 2110
2108 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2111 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2109 const base::Callback<base::Time()>& get_timestamp_callback) { 2112 const base::Callback<base::Time()>& get_timestamp_callback) {
2110 get_timestamp_callback_ = get_timestamp_callback; 2113 get_timestamp_callback_ = get_timestamp_callback;
2111 } 2114 }
2112 2115
2113 } // namespace content 2116 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698