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

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

Issue 1415603018: OOPIF: Support session restore by combining/splitting frame states. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up and fix bugs Created 5 years 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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 743
744 // Update the FTN ID to use below in case we found a named frame. 744 // Update the FTN ID to use below in case we found a named frame.
745 frame_tree_node_id = node->frame_tree_node_id(); 745 frame_tree_node_id = node->frame_tree_node_id();
746 746
747 // In --site-per-process, create an identical NavigationEntry with a 747 // In --site-per-process, create an identical NavigationEntry with a
748 // new FrameNavigationEntry for the target subframe. 748 // new FrameNavigationEntry for the target subframe.
749 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 749 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
750 entry = GetLastCommittedEntry()->Clone(); 750 entry = GetLastCommittedEntry()->Clone();
751 entry->SetPageID(-1); 751 entry->SetPageID(-1);
752 entry->AddOrUpdateFrameEntry(node, "", -1, -1, nullptr, params.url, 752 entry->AddOrUpdateFrameEntry(node, "", -1, -1, nullptr, params.url,
753 params.referrer, PageState()); 753 params.referrer, ExplodedFrameState());
754 } 754 }
755 } 755 }
756 } 756 }
757 757
758 // Otherwise, create a pending entry for the main frame. 758 // Otherwise, create a pending entry for the main frame.
759 if (!entry) { 759 if (!entry) {
760 entry = NavigationEntryImpl::FromNavigationEntry(CreateNavigationEntry( 760 entry = NavigationEntryImpl::FromNavigationEntry(CreateNavigationEntry(
761 params.url, params.referrer, params.transition_type, 761 params.url, params.referrer, params.transition_type,
762 params.is_renderer_initiated, params.extra_headers, browser_context_)); 762 params.is_renderer_initiated, params.extra_headers, browser_context_));
763 } 763 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 time_smoother_.GetSmoothedTime(get_timestamp_callback_.Run()); 893 time_smoother_.GetSmoothedTime(get_timestamp_callback_.Run());
894 DVLOG(1) << "Navigation finished at (smoothed) timestamp " 894 DVLOG(1) << "Navigation finished at (smoothed) timestamp "
895 << timestamp.ToInternalValue(); 895 << timestamp.ToInternalValue();
896 896
897 // We should not have a pending entry anymore. Clear it again in case any 897 // We should not have a pending entry anymore. Clear it again in case any
898 // error cases above forgot to do so. 898 // error cases above forgot to do so.
899 DiscardNonCommittedEntriesInternal(); 899 DiscardNonCommittedEntriesInternal();
900 900
901 // All committed entries should have nonempty content state so WebKit doesn't 901 // All committed entries should have nonempty content state so WebKit doesn't
902 // get confused when we go back to them (see the function for details). 902 // get confused when we go back to them (see the function for details).
903 DCHECK(params.page_state.IsValid()); 903 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
904 DCHECK(params.frame_state.item_sequence_number);
905 else
906 DCHECK(params.page_state.IsValid());
904 NavigationEntryImpl* active_entry = GetLastCommittedEntry(); 907 NavigationEntryImpl* active_entry = GetLastCommittedEntry();
905 active_entry->SetTimestamp(timestamp); 908 active_entry->SetTimestamp(timestamp);
906 active_entry->SetHttpStatusCode(params.http_status_code); 909 active_entry->SetHttpStatusCode(params.http_status_code);
907 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 910 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
908 // Update the frame-specific PageState. 911 // Update the frame-specific PageState.
909 FrameNavigationEntry* frame_entry = 912 FrameNavigationEntry* frame_entry =
910 active_entry->GetFrameEntry(rfh->frame_tree_node()); 913 active_entry->GetFrameEntry(rfh->frame_tree_node());
911 // We may not find a frame_entry in some cases; ignore the PageState if so. 914 // We may not find a frame_entry in some cases; ignore the PageState if so.
912 // TODO(creis): Remove the "if" once https://crbug.com/522193 is fixed. 915 // TODO(creis): Remove the "if" once https://crbug.com/522193 is fixed.
913 if (frame_entry) 916 if (frame_entry) {
914 frame_entry->set_page_state(params.page_state); 917 frame_entry->set_frame_state(params.frame_state);
918 active_entry->UpdatePageState();
919 }
915 } else { 920 } else {
916 active_entry->SetPageState(params.page_state); 921 active_entry->SetPageState(params.page_state);
917 } 922 }
918 active_entry->SetRedirectChain(params.redirects); 923 active_entry->SetRedirectChain(params.redirects);
919 924
920 // Use histogram to track memory impact of redirect chain because it's now 925 // Use histogram to track memory impact of redirect chain because it's now
921 // not cleared for committed entries. 926 // not cleared for committed entries.
922 size_t redirect_chain_size = 0; 927 size_t redirect_chain_size = 0;
923 for (size_t i = 0; i < params.redirects.size(); ++i) { 928 for (size_t i = 0; i < params.redirects.size(); ++i) {
924 redirect_chain_size += params.redirects[i].spec().length(); 929 redirect_chain_size += params.redirects[i].spec().length();
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 } 1322 }
1318 } 1323 }
1319 1324
1320 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 1325 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1321 // This may be a "new auto" case where we add a new FrameNavigationEntry, or 1326 // This may be a "new auto" case where we add a new FrameNavigationEntry, or
1322 // it may be a "history auto" case where we update an existing one. 1327 // it may be a "history auto" case where we update an existing one.
1323 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); 1328 NavigationEntryImpl* last_committed = GetLastCommittedEntry();
1324 last_committed->AddOrUpdateFrameEntry( 1329 last_committed->AddOrUpdateFrameEntry(
1325 rfh->frame_tree_node(), params.frame_unique_name, 1330 rfh->frame_tree_node(), params.frame_unique_name,
1326 params.item_sequence_number, params.document_sequence_number, 1331 params.item_sequence_number, params.document_sequence_number,
1327 rfh->GetSiteInstance(), params.url, params.referrer, params.page_state); 1332 rfh->GetSiteInstance(), params.url, params.referrer,
1333 params.frame_state);
1328 1334
1329 // Cross-process subframe navigations may leave a pending entry around. 1335 // Cross-process subframe navigations may leave a pending entry around.
1330 // Clear it if it's actually for the subframe. 1336 // Clear it if it's actually for the subframe.
1331 // TODO(creis): Don't use pending entries for subframe navigations. 1337 // TODO(creis): Don't use pending entries for subframe navigations.
1332 // See https://crbug.com/495161. 1338 // See https://crbug.com/495161.
1333 if (pending_entry_ && 1339 if (pending_entry_ &&
1334 pending_entry_->frame_tree_node_id() == 1340 pending_entry_->frame_tree_node_id() ==
1335 rfh->frame_tree_node()->frame_tree_node_id()) { 1341 rfh->frame_tree_node()->frame_tree_node_id()) {
1336 DiscardPendingEntry(false); 1342 DiscardPendingEntry(false);
1337 } 1343 }
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 FrameLoadVector* different_document_loads) { 1846 FrameLoadVector* different_document_loads) {
1841 DCHECK(pending_entry_); 1847 DCHECK(pending_entry_);
1842 DCHECK_GE(last_committed_entry_index_, 0); 1848 DCHECK_GE(last_committed_entry_index_, 0);
1843 FrameNavigationEntry* new_item = pending_entry_->GetFrameEntry(frame); 1849 FrameNavigationEntry* new_item = pending_entry_->GetFrameEntry(frame);
1844 FrameNavigationEntry* old_item = 1850 FrameNavigationEntry* old_item =
1845 GetLastCommittedEntry()->GetFrameEntry(frame); 1851 GetLastCommittedEntry()->GetFrameEntry(frame);
1846 if (!new_item) 1852 if (!new_item)
1847 return; 1853 return;
1848 1854
1849 // Schedule a load in this frame if the new item isn't for the same item 1855 // Schedule a load in this frame if the new item isn't for the same item
1850 // sequence number in the same SiteInstance. 1856 // sequence number in the same SiteInstance. Newly restored items may not have
1851 // TODO(creis): Handle null SiteInstances during session restore. 1857 // SiteInstances yet, in which case it will be assigned on first commit.
1852 if (!old_item || 1858 if (!old_item ||
1853 new_item->item_sequence_number() != old_item->item_sequence_number() || 1859 new_item->item_sequence_number() != old_item->item_sequence_number() ||
1854 new_item->site_instance() != old_item->site_instance()) { 1860 (new_item->site_instance() != nullptr &&
1861 new_item->site_instance() != old_item->site_instance())) {
1855 if (old_item && 1862 if (old_item &&
1856 new_item->document_sequence_number() == 1863 new_item->document_sequence_number() ==
1857 old_item->document_sequence_number()) { 1864 old_item->document_sequence_number()) {
1858 same_document_loads->push_back(std::make_pair(frame, new_item)); 1865 same_document_loads->push_back(std::make_pair(frame, new_item));
1859 } else { 1866 } else {
1860 different_document_loads->push_back(std::make_pair(frame, new_item)); 1867 different_document_loads->push_back(std::make_pair(frame, new_item));
1861 } 1868 }
1862 return; 1869 return;
1863 } 1870 }
1864 1871
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 } 2038 }
2032 } 2039 }
2033 } 2040 }
2034 2041
2035 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2042 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2036 const base::Callback<base::Time()>& get_timestamp_callback) { 2043 const base::Callback<base::Time()>& get_timestamp_callback) {
2037 get_timestamp_callback_ = get_timestamp_callback; 2044 get_timestamp_callback_ = get_timestamp_callback;
2038 } 2045 }
2039 2046
2040 } // namespace content 2047 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_navigation_entry.cc ('k') | content/browser/frame_host/navigation_entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698