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

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

Issue 2368183004: Move redirect_chain from NavigationEntry to FrameNavigationEntry. (Closed)
Patch Set: Addressed comments. 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.url, params.referrer, params.redirect_chain, 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 entry->SetRedirectChain(params.redirect_chain);
719 } 721 }
720 722
721 // Set the FTN ID (only used in non-site-per-process, for tests). 723 // Set the FTN ID (only used in non-site-per-process, for tests).
722 entry->set_frame_tree_node_id(frame_tree_node_id); 724 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. 725 // Don't allow an entry replacement if there is no entry to replace.
726 // http://crbug.com/457149 726 // http://crbug.com/457149
727 if (params.should_replace_current_entry && entries_.size() > 0) 727 if (params.should_replace_current_entry && entries_.size() > 0)
728 entry->set_should_replace_entry(true); 728 entry->set_should_replace_entry(true);
729 entry->set_should_clear_history_list(params.should_clear_history_list); 729 entry->set_should_clear_history_list(params.should_clear_history_list);
730 entry->SetIsOverridingUserAgent(override); 730 entry->SetIsOverridingUserAgent(override);
731 entry->set_transferred_global_request_id( 731 entry->set_transferred_global_request_id(
732 params.transferred_global_request_id); 732 params.transferred_global_request_id);
733 733
734 #if defined(OS_ANDROID) 734 #if defined(OS_ANDROID)
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 base::debug::DumpWithoutCrashing(); 863 base::debug::DumpWithoutCrashing();
864 NOTREACHED() << "Shouldn't see an empty PageState at commit."; 864 NOTREACHED() << "Shouldn't see an empty PageState at commit.";
865 } 865 }
866 NavigationEntryImpl* active_entry = GetLastCommittedEntry(); 866 NavigationEntryImpl* active_entry = GetLastCommittedEntry();
867 active_entry->SetTimestamp(timestamp); 867 active_entry->SetTimestamp(timestamp);
868 active_entry->SetHttpStatusCode(params.http_status_code); 868 active_entry->SetHttpStatusCode(params.http_status_code);
869 869
870 FrameNavigationEntry* frame_entry = 870 FrameNavigationEntry* frame_entry =
871 active_entry->GetFrameEntry(rfh->frame_tree_node()); 871 active_entry->GetFrameEntry(rfh->frame_tree_node());
872 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 872 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
873 // Update the frame-specific PageState. 873 // Update the frame-specific PageState and RedirectChain
874 // We may not find a frame_entry in some cases; ignore the PageState if so. 874 // 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. 875 // TODO(creis): Remove the "if" once https://crbug.com/522193 is fixed.
876 if (frame_entry) 876 if (frame_entry) {
877 frame_entry->SetPageState(params.page_state); 877 frame_entry->SetPageState(params.page_state);
878 frame_entry->set_redirect_chain(params.redirects);
879 }
878 } else { 880 } else {
879 active_entry->SetPageState(params.page_state); 881 active_entry->SetPageState(params.page_state);
882 active_entry->SetRedirectChain(params.redirects);
880 } 883 }
881 active_entry->SetRedirectChain(params.redirects);
882 884
883 // Use histogram to track memory impact of redirect chain because it's now 885 // Use histogram to track memory impact of redirect chain because it's now
884 // not cleared for committed entries. 886 // not cleared for committed entries.
885 size_t redirect_chain_size = 0; 887 size_t redirect_chain_size = 0;
886 for (size_t i = 0; i < params.redirects.size(); ++i) { 888 for (size_t i = 0; i < params.redirects.size(); ++i) {
887 redirect_chain_size += params.redirects[i].spec().length(); 889 redirect_chain_size += params.redirects[i].spec().length();
888 } 890 }
889 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size); 891 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size);
890 892
891 // Once it is committed, we no longer need to track several pieces of state on 893 // 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, 1205 // The site instance will normally be the same except during session restore,
1204 // when no site instance will be assigned. 1206 // when no site instance will be assigned.
1205 DCHECK(entry->site_instance() == nullptr || 1207 DCHECK(entry->site_instance() == nullptr ||
1206 entry->site_instance() == rfh->GetSiteInstance()); 1208 entry->site_instance() == rfh->GetSiteInstance());
1207 1209
1208 // Update the existing FrameNavigationEntry to ensure all of its members 1210 // Update the existing FrameNavigationEntry to ensure all of its members
1209 // reflect the parameters coming from the renderer process. 1211 // reflect the parameters coming from the renderer process.
1210 entry->AddOrUpdateFrameEntry( 1212 entry->AddOrUpdateFrameEntry(
1211 rfh->frame_tree_node(), params.item_sequence_number, 1213 rfh->frame_tree_node(), params.item_sequence_number,
1212 params.document_sequence_number, rfh->GetSiteInstance(), nullptr, 1214 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1213 params.url, params.referrer, params.page_state, params.method, 1215 params.url, params.referrer, params.redirects, params.page_state,
1214 params.post_id); 1216 params.method, params.post_id);
1215 1217
1216 // The redirected to page should not inherit the favicon from the previous 1218 // The redirected to page should not inherit the favicon from the previous
1217 // page. 1219 // page.
1218 if (ui::PageTransitionIsRedirect(params.transition) && !is_in_page) 1220 if (ui::PageTransitionIsRedirect(params.transition) && !is_in_page)
1219 entry->GetFavicon() = FaviconStatus(); 1221 entry->GetFavicon() = FaviconStatus();
1220 1222
1221 // The entry we found in the list might be pending if the user hit 1223 // 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 1224 // 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 1225 // 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 1226 // 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 1263 // 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 1264 // might change (but it's still considered a SAME_PAGE navigation). So we must
1263 // update the SSL status. 1265 // update the SSL status.
1264 existing_entry->GetSSL() = rfh->navigation_handle()->ssl_status(); 1266 existing_entry->GetSSL() = rfh->navigation_handle()->ssl_status();
1265 1267
1266 // Update the existing FrameNavigationEntry to ensure all of its members 1268 // Update the existing FrameNavigationEntry to ensure all of its members
1267 // reflect the parameters coming from the renderer process. 1269 // reflect the parameters coming from the renderer process.
1268 existing_entry->AddOrUpdateFrameEntry( 1270 existing_entry->AddOrUpdateFrameEntry(
1269 rfh->frame_tree_node(), params.item_sequence_number, 1271 rfh->frame_tree_node(), params.item_sequence_number,
1270 params.document_sequence_number, rfh->GetSiteInstance(), nullptr, 1272 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1271 params.url, params.referrer, params.page_state, params.method, 1273 params.url, params.referrer, params.redirects, params.page_state,
1272 params.post_id); 1274 params.method, params.post_id);
1273 1275
1274 DiscardNonCommittedEntries(); 1276 DiscardNonCommittedEntries();
1275 } 1277 }
1276 1278
1277 void NavigationControllerImpl::RendererDidNavigateNewSubframe( 1279 void NavigationControllerImpl::RendererDidNavigateNewSubframe(
1278 RenderFrameHostImpl* rfh, 1280 RenderFrameHostImpl* rfh,
1279 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 1281 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1280 bool is_in_page, 1282 bool is_in_page,
1281 bool replace_entry) { 1283 bool replace_entry) {
1282 DCHECK(ui::PageTransitionCoreTypeIs(params.transition, 1284 DCHECK(ui::PageTransitionCoreTypeIs(params.transition,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 } 1362 }
1361 } 1363 }
1362 1364
1363 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 1365 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1364 // This may be a "new auto" case where we add a new FrameNavigationEntry, or 1366 // 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. 1367 // it may be a "history auto" case where we update an existing one.
1366 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); 1368 NavigationEntryImpl* last_committed = GetLastCommittedEntry();
1367 last_committed->AddOrUpdateFrameEntry( 1369 last_committed->AddOrUpdateFrameEntry(
1368 rfh->frame_tree_node(), params.item_sequence_number, 1370 rfh->frame_tree_node(), params.item_sequence_number,
1369 params.document_sequence_number, rfh->GetSiteInstance(), nullptr, 1371 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1370 params.url, params.referrer, params.page_state, params.method, 1372 params.url, params.referrer, params.redirects, params.page_state,
1371 params.post_id); 1373 params.method, params.post_id);
1372 } 1374 }
1373 1375
1374 return send_commit_notification; 1376 return send_commit_notification;
1375 } 1377 }
1376 1378
1377 int NavigationControllerImpl::GetIndexOfEntry( 1379 int NavigationControllerImpl::GetIndexOfEntry(
1378 const NavigationEntryImpl* entry) const { 1380 const NavigationEntryImpl* entry) const {
1379 for (size_t i = 0; i < entries_.size(); ++i) { 1381 for (size_t i = 0; i < entries_.size(); ++i) {
1380 if (entries_[i].get() == entry) 1382 if (entries_[i].get() == entry)
1381 return i; 1383 return i;
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 } 2106 }
2105 } 2107 }
2106 } 2108 }
2107 2109
2108 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2110 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2109 const base::Callback<base::Time()>& get_timestamp_callback) { 2111 const base::Callback<base::Time()>& get_timestamp_callback) {
2110 get_timestamp_callback_ = get_timestamp_callback; 2112 get_timestamp_callback_ = get_timestamp_callback;
2111 } 2113 }
2112 2114
2113 } // namespace content 2115 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698