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

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

Issue 1268453003: Remove GetPendingSiteInstance from NavigationControllerDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Mk1 Created 5 years, 4 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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 806
807 // Save the previous state before we clobber it. 807 // Save the previous state before we clobber it.
808 if (GetLastCommittedEntry()) { 808 if (GetLastCommittedEntry()) {
809 details->previous_url = GetLastCommittedEntry()->GetURL(); 809 details->previous_url = GetLastCommittedEntry()->GetURL();
810 details->previous_entry_index = GetLastCommittedEntryIndex(); 810 details->previous_entry_index = GetLastCommittedEntryIndex();
811 } else { 811 } else {
812 details->previous_url = GURL(); 812 details->previous_url = GURL();
813 details->previous_entry_index = -1; 813 details->previous_entry_index = -1;
814 } 814 }
815 815
816 // If we have a pending entry at this point, it should have a SiteInstance. 816 // If there is a pending entry at this point, it should have a SiteInstance,
817 // Restored entries start out with a null SiteInstance, but we should have 817 // except for restored entries.
818 // assigned one in NavigateToPendingEntry. 818 DCHECK(pending_entry_index_ == -1 ||
819 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); 819 pending_entry_->site_instance() != nullptr ||
820 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE);
821 if (pending_entry_index_ != -1 &&
822 pending_entry_->site_instance() == nullptr &&
823 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE)
Charlie Reis 2015/07/30 16:55:14 Let's simplify these to: DCHECK(!pending_entry_ |
Fabrice (no longer in Chrome) 2015/07/30 17:18:41 Done. I find the explicit nullptr comparison to be
824 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE);
820 825
821 // If we are doing a cross-site reload, we need to replace the existing 826 // If we are doing a cross-site reload, we need to replace the existing
822 // navigation entry, not add another entry to the history. This has the side 827 // navigation entry, not add another entry to the history. This has the side
823 // effect of removing forward browsing history, if such existed. Or if we are 828 // effect of removing forward browsing history, if such existed. Or if we are
824 // doing a cross-site redirect navigation, we will do a similar thing. 829 // doing a cross-site redirect navigation, we will do a similar thing.
825 // 830 //
826 // If this is an error load, we may have already removed the pending entry 831 // If this is an error load, we may have already removed the pending entry
827 // when we got the notice of the load failure. If so, look at the copy of the 832 // when we got the notice of the load failure. If so, look at the copy of the
828 // pending parameters that were saved. 833 // pending parameters that were saved.
829 if (params.url_is_unreachable && failed_pending_entry_id_ != 0) { 834 if (params.url_is_unreachable && failed_pending_entry_id_ != 0) {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 if (entry->update_virtual_url_with_url()) 1155 if (entry->update_virtual_url_with_url())
1151 UpdateVirtualURLToURL(entry, params.url); 1156 UpdateVirtualURLToURL(entry, params.url);
1152 1157
1153 // The redirected to page should not inherit the favicon from the previous 1158 // The redirected to page should not inherit the favicon from the previous
1154 // page. 1159 // page.
1155 if (ui::PageTransitionIsRedirect(params.transition)) 1160 if (ui::PageTransitionIsRedirect(params.transition))
1156 entry->GetFavicon() = FaviconStatus(); 1161 entry->GetFavicon() = FaviconStatus();
1157 1162
1158 // The site instance will normally be the same except during session restore, 1163 // The site instance will normally be the same except during session restore,
1159 // when no site instance will be assigned. 1164 // when no site instance will be assigned.
1160 DCHECK(entry->site_instance() == NULL || 1165 DCHECK(entry->site_instance() == nullptr ||
1161 entry->site_instance() == rfh->GetSiteInstance()); 1166 entry->site_instance() == rfh->GetSiteInstance());
1162 entry->set_site_instance( 1167 entry->set_site_instance(
1163 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance())); 1168 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance()));
1164 1169
1165 entry->SetHasPostData(params.is_post); 1170 entry->SetHasPostData(params.is_post);
1166 entry->SetPostID(params.post_id); 1171 entry->SetPostID(params.post_id);
1167 1172
1168 // The entry we found in the list might be pending if the user hit 1173 // The entry we found in the list might be pending if the user hit
1169 // back/forward/reload. This load should commit it (since it's already in the 1174 // back/forward/reload. This load should commit it (since it's already in the
1170 // list, we can just discard the pending pointer). We should also discard the 1175 // list, we can just discard the pending pointer). We should also discard the
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 } 1721 }
1717 1722
1718 // This call does not support re-entrancy. See http://crbug.com/347742. 1723 // This call does not support re-entrancy. See http://crbug.com/347742.
1719 CHECK(!in_navigate_to_pending_entry_); 1724 CHECK(!in_navigate_to_pending_entry_);
1720 in_navigate_to_pending_entry_ = true; 1725 in_navigate_to_pending_entry_ = true;
1721 bool success = NavigateToPendingEntryInternal(reload_type); 1726 bool success = NavigateToPendingEntryInternal(reload_type);
1722 in_navigate_to_pending_entry_ = false; 1727 in_navigate_to_pending_entry_ = false;
1723 1728
1724 if (!success) 1729 if (!success)
1725 DiscardNonCommittedEntries(); 1730 DiscardNonCommittedEntries();
1726
1727 // If the entry is being restored and doesn't have a SiteInstance yet, fill
1728 // it in now that we know. This allows us to find the entry when it commits.
1729 if (pending_entry_ && !pending_entry_->site_instance() &&
1730 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) {
1731 pending_entry_->set_site_instance(static_cast<SiteInstanceImpl*>(
1732 delegate_->GetPendingSiteInstance()));
1733 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE);
1734 }
1735 } 1731 }
1736 1732
1737 bool NavigationControllerImpl::NavigateToPendingEntryInternal( 1733 bool NavigationControllerImpl::NavigateToPendingEntryInternal(
1738 ReloadType reload_type) { 1734 ReloadType reload_type) {
1739 DCHECK(pending_entry_); 1735 DCHECK(pending_entry_);
1740 FrameTreeNode* root = delegate_->GetFrameTree()->root(); 1736 FrameTreeNode* root = delegate_->GetFrameTree()->root();
1741 1737
1742 // In default Chrome, there are no subframe FrameNavigationEntries. Either 1738 // In default Chrome, there are no subframe FrameNavigationEntries. Either
1743 // navigate the main frame or use the main frame's FrameNavigationEntry to 1739 // navigate the main frame or use the main frame's FrameNavigationEntry to
1744 // tell the indicated frame where to go. 1740 // tell the indicated frame where to go.
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 } 1975 }
1980 } 1976 }
1981 } 1977 }
1982 1978
1983 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1979 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1984 const base::Callback<base::Time()>& get_timestamp_callback) { 1980 const base::Callback<base::Time()>& get_timestamp_callback) {
1985 get_timestamp_callback_ = get_timestamp_callback; 1981 get_timestamp_callback_ = get_timestamp_callback;
1986 } 1982 }
1987 1983
1988 } // namespace content 1984 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698