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

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

Issue 1944013003: Move ownership of source SiteInstance to the FrameNavigationEntry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 DCHECK(GetLastCommittedEntry()); 729 DCHECK(GetLastCommittedEntry());
730 730
731 // Update the FTN ID to use below in case we found a named frame. 731 // Update the FTN ID to use below in case we found a named frame.
732 frame_tree_node_id = node->frame_tree_node_id(); 732 frame_tree_node_id = node->frame_tree_node_id();
733 733
734 // In --site-per-process, create an identical NavigationEntry with a 734 // In --site-per-process, create an identical NavigationEntry with a
735 // new FrameNavigationEntry for the target subframe. 735 // new FrameNavigationEntry for the target subframe.
736 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 736 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
737 entry = GetLastCommittedEntry()->Clone(); 737 entry = GetLastCommittedEntry()->Clone();
738 entry->SetPageID(-1); 738 entry->SetPageID(-1);
739 entry->AddOrUpdateFrameEntry(node, -1, -1, nullptr, params.url, 739 entry->AddOrUpdateFrameEntry(
740 params.referrer, PageState(), "GET", -1); 740 node, -1, -1,
741 static_cast<SiteInstanceImpl*>(params.source_site_instance.get()),
742 nullptr, params.url, params.referrer, PageState(), "GET", -1);
741 } 743 }
742 } 744 }
743 } 745 }
744 746
745 // Otherwise, create a pending entry for the main frame. 747 // Otherwise, create a pending entry for the main frame.
746 if (!entry) { 748 if (!entry) {
747 entry = NavigationEntryImpl::FromNavigationEntry(CreateNavigationEntry( 749 entry = NavigationEntryImpl::FromNavigationEntry(CreateNavigationEntry(
748 params.url, params.referrer, params.transition_type, 750 params.url, params.referrer, params.transition_type,
749 params.is_renderer_initiated, params.extra_headers, browser_context_)); 751 params.is_renderer_initiated, params.extra_headers, browser_context_));
752 entry->root_node()->frame_entry->set_source_site_instance(
Charlie Reis 2016/05/04 23:03:01 Hmm. I think I'd prefer to have a method on Navig
nasko 2016/05/05 17:51:33 Done.
753 static_cast<SiteInstanceImpl*>(params.source_site_instance.get()));
Charlie Reis 2016/05/04 23:03:01 Just curious-- was there a reason not to move this
nasko 2016/05/05 17:51:33 It is content/public/ API. I don't think it is wor
Charlie Reis 2016/05/05 22:20:00 Acknowledged.
750 } 754 }
755
751 // Set the FTN ID (only used in non-site-per-process, for tests). 756 // Set the FTN ID (only used in non-site-per-process, for tests).
752 entry->set_frame_tree_node_id(frame_tree_node_id); 757 entry->set_frame_tree_node_id(frame_tree_node_id);
753 entry->set_source_site_instance(
754 static_cast<SiteInstanceImpl*>(params.source_site_instance.get()));
755 if (params.redirect_chain.size() > 0) 758 if (params.redirect_chain.size() > 0)
756 entry->SetRedirectChain(params.redirect_chain); 759 entry->SetRedirectChain(params.redirect_chain);
757 // Don't allow an entry replacement if there is no entry to replace. 760 // Don't allow an entry replacement if there is no entry to replace.
758 // http://crbug.com/457149 761 // http://crbug.com/457149
759 if (params.should_replace_current_entry && entries_.size() > 0) 762 if (params.should_replace_current_entry && entries_.size() > 0)
760 entry->set_should_replace_entry(true); 763 entry->set_should_replace_entry(true);
761 entry->set_should_clear_history_list(params.should_clear_history_list); 764 entry->set_should_clear_history_list(params.should_clear_history_list);
762 entry->SetIsOverridingUserAgent(override); 765 entry->SetIsOverridingUserAgent(override);
763 entry->set_transferred_global_request_id( 766 entry->set_transferred_global_request_id(
764 params.transferred_global_request_id); 767 params.transferred_global_request_id);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 // We should not have a pending entry anymore. Clear it again in case any 884 // We should not have a pending entry anymore. Clear it again in case any
882 // error cases above forgot to do so. 885 // error cases above forgot to do so.
883 DiscardNonCommittedEntriesInternal(); 886 DiscardNonCommittedEntriesInternal();
884 887
885 // All committed entries should have nonempty content state so WebKit doesn't 888 // All committed entries should have nonempty content state so WebKit doesn't
886 // get confused when we go back to them (see the function for details). 889 // get confused when we go back to them (see the function for details).
887 DCHECK(params.page_state.IsValid()); 890 DCHECK(params.page_state.IsValid());
888 NavigationEntryImpl* active_entry = GetLastCommittedEntry(); 891 NavigationEntryImpl* active_entry = GetLastCommittedEntry();
889 active_entry->SetTimestamp(timestamp); 892 active_entry->SetTimestamp(timestamp);
890 active_entry->SetHttpStatusCode(params.http_status_code); 893 active_entry->SetHttpStatusCode(params.http_status_code);
894
895 // Update the frame-specific PageState.
Charlie Reis 2016/05/04 23:03:01 This comment belongs inside the conditional, since
nasko 2016/05/05 17:51:33 Done.
896 FrameNavigationEntry* frame_entry =
897 active_entry->GetFrameEntry(rfh->frame_tree_node());
891 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 898 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
892 // Update the frame-specific PageState.
893 FrameNavigationEntry* frame_entry =
894 active_entry->GetFrameEntry(rfh->frame_tree_node());
895 // We may not find a frame_entry in some cases; ignore the PageState if so. 899 // We may not find a frame_entry in some cases; ignore the PageState if so.
896 // TODO(creis): Remove the "if" once https://crbug.com/522193 is fixed. 900 // TODO(creis): Remove the "if" once https://crbug.com/522193 is fixed.
897 if (frame_entry) 901 if (frame_entry)
898 frame_entry->set_page_state(params.page_state); 902 frame_entry->set_page_state(params.page_state);
899 } else { 903 } else {
900 active_entry->SetPageState(params.page_state); 904 active_entry->SetPageState(params.page_state);
901 } 905 }
902 active_entry->SetRedirectChain(params.redirects); 906 active_entry->SetRedirectChain(params.redirects);
903 907
904 // Use histogram to track memory impact of redirect chain because it's now 908 // Use histogram to track memory impact of redirect chain because it's now
905 // not cleared for committed entries. 909 // not cleared for committed entries.
906 size_t redirect_chain_size = 0; 910 size_t redirect_chain_size = 0;
907 for (size_t i = 0; i < params.redirects.size(); ++i) { 911 for (size_t i = 0; i < params.redirects.size(); ++i) {
908 redirect_chain_size += params.redirects[i].spec().length(); 912 redirect_chain_size += params.redirects[i].spec().length();
909 } 913 }
910 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size); 914 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size);
911 915
912 // Once it is committed, we no longer need to track several pieces of state on 916 // Once it is committed, we no longer need to track several pieces of state on
913 // the entry. 917 // the entry.
914 active_entry->ResetForCommit(); 918 active_entry->ResetForCommit(frame_entry);
915 919
916 // The active entry's SiteInstance should match our SiteInstance. 920 // The active entry's SiteInstance should match our SiteInstance.
917 // TODO(creis): This check won't pass for subframes until we create entries 921 // TODO(creis): This check won't pass for subframes until we create entries
918 // for subframe navigations. 922 // for subframe navigations.
919 if (!rfh->GetParent()) 923 if (!rfh->GetParent())
920 CHECK_EQ(active_entry->site_instance(), rfh->GetSiteInstance()); 924 CHECK_EQ(active_entry->site_instance(), rfh->GetSiteInstance());
921 925
922 // Remember the bindings the renderer process has at this point, so that 926 // Remember the bindings the renderer process has at this point, so that
923 // we do not grant this entry additional bindings if we come back to it. 927 // we do not grant this entry additional bindings if we come back to it.
924 active_entry->SetBindings(rfh->GetEnabledBindings()); 928 active_entry->SetBindings(rfh->GetEnabledBindings());
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 return true; 1336 return true;
1333 } 1337 }
1334 } 1338 }
1335 1339
1336 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 1340 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1337 // This may be a "new auto" case where we add a new FrameNavigationEntry, or 1341 // This may be a "new auto" case where we add a new FrameNavigationEntry, or
1338 // it may be a "history auto" case where we update an existing one. 1342 // it may be a "history auto" case where we update an existing one.
1339 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); 1343 NavigationEntryImpl* last_committed = GetLastCommittedEntry();
1340 last_committed->AddOrUpdateFrameEntry( 1344 last_committed->AddOrUpdateFrameEntry(
1341 rfh->frame_tree_node(), params.item_sequence_number, 1345 rfh->frame_tree_node(), params.item_sequence_number,
1342 params.document_sequence_number, rfh->GetSiteInstance(), params.url, 1346 params.document_sequence_number, nullptr, rfh->GetSiteInstance(),
1343 params.referrer, params.page_state, params.method, params.post_id); 1347 params.url, params.referrer, params.page_state, params.method,
1348 params.post_id);
1344 1349
1345 // Cross-process subframe navigations may leave a pending entry around. 1350 // Cross-process subframe navigations may leave a pending entry around.
1346 // Clear it if it's actually for the subframe. 1351 // Clear it if it's actually for the subframe.
1347 // TODO(creis): Don't use pending entries for subframe navigations. 1352 // TODO(creis): Don't use pending entries for subframe navigations.
1348 // See https://crbug.com/495161. 1353 // See https://crbug.com/495161.
1349 if (pending_entry_ && 1354 if (pending_entry_ &&
1350 pending_entry_->frame_tree_node_id() == 1355 pending_entry_->frame_tree_node_id() ==
1351 rfh->frame_tree_node()->frame_tree_node_id()) { 1356 rfh->frame_tree_node()->frame_tree_node_id()) {
1352 DiscardPendingEntry(false); 1357 DiscardPendingEntry(false);
1353 } 1358 }
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 } 2058 }
2054 } 2059 }
2055 } 2060 }
2056 2061
2057 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2062 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2058 const base::Callback<base::Time()>& get_timestamp_callback) { 2063 const base::Callback<base::Time()>& get_timestamp_callback) {
2059 get_timestamp_callback_ = get_timestamp_callback; 2064 get_timestamp_callback_ = get_timestamp_callback;
2060 } 2065 }
2061 2066
2062 } // namespace content 2067 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698