OLD | NEW |
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 #include "content/browser/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // water marks. | 219 // water marks. |
220 low_water_mark_ = high_water_mark_ = t; | 220 low_water_mark_ = high_water_mark_ = t; |
221 return t; | 221 return t; |
222 } | 222 } |
223 | 223 |
224 NavigationControllerImpl::NavigationControllerImpl( | 224 NavigationControllerImpl::NavigationControllerImpl( |
225 NavigationControllerDelegate* delegate, | 225 NavigationControllerDelegate* delegate, |
226 BrowserContext* browser_context) | 226 BrowserContext* browser_context) |
227 : browser_context_(browser_context), | 227 : browser_context_(browser_context), |
228 pending_entry_(NULL), | 228 pending_entry_(NULL), |
| 229 failed_pending_entry_id_(0), |
| 230 failed_pending_entry_should_replace_(false), |
229 last_committed_entry_index_(-1), | 231 last_committed_entry_index_(-1), |
230 pending_entry_index_(-1), | 232 pending_entry_index_(-1), |
231 transient_entry_index_(-1), | 233 transient_entry_index_(-1), |
232 delegate_(delegate), | 234 delegate_(delegate), |
233 max_restored_page_id_(-1), | 235 max_restored_page_id_(-1), |
234 ssl_manager_(this), | 236 ssl_manager_(this), |
235 needs_reload_(false), | 237 needs_reload_(false), |
236 is_initial_navigation_(true), | 238 is_initial_navigation_(true), |
237 in_navigate_to_pending_entry_(false), | 239 in_navigate_to_pending_entry_(false), |
238 pending_reload_(NO_RELOAD), | 240 pending_reload_(NO_RELOAD), |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 details->previous_entry_index = -1; | 791 details->previous_entry_index = -1; |
790 } | 792 } |
791 | 793 |
792 // If we have a pending entry at this point, it should have a SiteInstance. | 794 // If we have a pending entry at this point, it should have a SiteInstance. |
793 // Restored entries start out with a null SiteInstance, but we should have | 795 // Restored entries start out with a null SiteInstance, but we should have |
794 // assigned one in NavigateToPendingEntry. | 796 // assigned one in NavigateToPendingEntry. |
795 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); | 797 DCHECK(pending_entry_index_ == -1 || pending_entry_->site_instance()); |
796 | 798 |
797 // If we are doing a cross-site reload, we need to replace the existing | 799 // If we are doing a cross-site reload, we need to replace the existing |
798 // navigation entry, not add another entry to the history. This has the side | 800 // navigation entry, not add another entry to the history. This has the side |
799 // effect of removing forward browsing history, if such existed. | 801 // effect of removing forward browsing history, if such existed. Or if we are |
800 // Or if we are doing a cross-site redirect navigation, | 802 // doing a cross-site redirect navigation, we will do a similar thing. |
801 // we will do a similar thing. | 803 // |
802 details->did_replace_entry = | 804 // If this is an error load, we may have already removed the pending entry |
803 pending_entry_ && pending_entry_->should_replace_entry(); | 805 // when we got the notice of the load failure. If so, look at the copy of the |
| 806 // pending parameters that were saved. |
| 807 if (params.url_is_unreachable && failed_pending_entry_id_ != 0) { |
| 808 details->did_replace_entry = failed_pending_entry_should_replace_; |
| 809 } else { |
| 810 details->did_replace_entry = pending_entry_ && |
| 811 pending_entry_->should_replace_entry(); |
| 812 } |
804 | 813 |
805 // Do navigation-type specific actions. These will make and commit an entry. | 814 // Do navigation-type specific actions. These will make and commit an entry. |
806 details->type = ClassifyNavigation(rfh, params); | 815 details->type = ClassifyNavigation(rfh, params); |
807 | 816 |
808 // is_in_page must be computed before the entry gets committed. | 817 // is_in_page must be computed before the entry gets committed. |
809 details->is_in_page = AreURLsInPageNavigation(rfh->GetLastCommittedURL(), | 818 details->is_in_page = AreURLsInPageNavigation(rfh->GetLastCommittedURL(), |
810 params.url, params.was_within_same_page, rfh); | 819 params.url, params.was_within_same_page, rfh); |
811 | 820 |
812 switch (details->type) { | 821 switch (details->type) { |
813 case NAVIGATION_TYPE_NEW_PAGE: | 822 case NAVIGATION_TYPE_NEW_PAGE: |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 RestoreType type) { | 1760 RestoreType type) { |
1752 DCHECK(selected_index >= 0 && selected_index < GetEntryCount()); | 1761 DCHECK(selected_index >= 0 && selected_index < GetEntryCount()); |
1753 ConfigureEntriesForRestore(&entries_, type); | 1762 ConfigureEntriesForRestore(&entries_, type); |
1754 | 1763 |
1755 SetMaxRestoredPageID(static_cast<int32>(GetEntryCount())); | 1764 SetMaxRestoredPageID(static_cast<int32>(GetEntryCount())); |
1756 | 1765 |
1757 last_committed_entry_index_ = selected_index; | 1766 last_committed_entry_index_ = selected_index; |
1758 } | 1767 } |
1759 | 1768 |
1760 void NavigationControllerImpl::DiscardNonCommittedEntriesInternal() { | 1769 void NavigationControllerImpl::DiscardNonCommittedEntriesInternal() { |
1761 DiscardPendingEntry(); | 1770 DiscardPendingEntry(false); |
1762 DiscardTransientEntry(); | 1771 DiscardTransientEntry(); |
1763 } | 1772 } |
1764 | 1773 |
1765 void NavigationControllerImpl::DiscardPendingEntry() { | 1774 void NavigationControllerImpl::DiscardPendingEntry(bool was_failure) { |
1766 // It is not safe to call DiscardPendingEntry while NavigateToEntry is in | 1775 // It is not safe to call DiscardPendingEntry while NavigateToEntry is in |
1767 // progress, since this will cause a use-after-free. (We only allow this | 1776 // progress, since this will cause a use-after-free. (We only allow this |
1768 // when the tab is being destroyed for shutdown, since it won't return to | 1777 // when the tab is being destroyed for shutdown, since it won't return to |
1769 // NavigateToEntry in that case.) http://crbug.com/347742. | 1778 // NavigateToEntry in that case.) http://crbug.com/347742. |
1770 CHECK(!in_navigate_to_pending_entry_ || delegate_->IsBeingDestroyed()); | 1779 CHECK(!in_navigate_to_pending_entry_ || delegate_->IsBeingDestroyed()); |
1771 | 1780 |
| 1781 if (was_failure && pending_entry_) { |
| 1782 failed_pending_entry_id_ = pending_entry_->GetUniqueID(); |
| 1783 failed_pending_entry_should_replace_ = |
| 1784 pending_entry_->should_replace_entry(); |
| 1785 } else { |
| 1786 failed_pending_entry_id_ = 0; |
| 1787 } |
| 1788 |
1772 if (pending_entry_index_ == -1) | 1789 if (pending_entry_index_ == -1) |
1773 delete pending_entry_; | 1790 delete pending_entry_; |
1774 pending_entry_ = NULL; | 1791 pending_entry_ = NULL; |
1775 pending_entry_index_ = -1; | 1792 pending_entry_index_ = -1; |
1776 } | 1793 } |
1777 | 1794 |
1778 void NavigationControllerImpl::DiscardTransientEntry() { | 1795 void NavigationControllerImpl::DiscardTransientEntry() { |
1779 if (transient_entry_index_ == -1) | 1796 if (transient_entry_index_ == -1) |
1780 return; | 1797 return; |
1781 entries_.erase(entries_.begin() + transient_entry_index_); | 1798 entries_.erase(entries_.begin() + transient_entry_index_); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1830 } | 1847 } |
1831 } | 1848 } |
1832 } | 1849 } |
1833 | 1850 |
1834 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 1851 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
1835 const base::Callback<base::Time()>& get_timestamp_callback) { | 1852 const base::Callback<base::Time()>& get_timestamp_callback) { |
1836 get_timestamp_callback_ = get_timestamp_callback; | 1853 get_timestamp_callback_ = get_timestamp_callback; |
1837 } | 1854 } |
1838 | 1855 |
1839 } // namespace content | 1856 } // namespace content |
OLD | NEW |