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 /* | 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 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1644 // need to keep continuity with the pending entry, so copy the pending entry's | 1644 // need to keep continuity with the pending entry, so copy the pending entry's |
1645 // unique ID to the committed entry. If the pending_entry_index_ isn't -1, | 1645 // unique ID to the committed entry. If the pending_entry_index_ isn't -1, |
1646 // then the renderer navigated on its own, independent of the pending entry, | 1646 // then the renderer navigated on its own, independent of the pending entry, |
1647 // so don't copy anything. | 1647 // so don't copy anything. |
1648 if (pending_entry_ && pending_entry_index_ == -1) | 1648 if (pending_entry_ && pending_entry_index_ == -1) |
1649 entry->set_unique_id(pending_entry_->GetUniqueID()); | 1649 entry->set_unique_id(pending_entry_->GetUniqueID()); |
1650 | 1650 |
1651 DiscardNonCommittedEntriesInternal(); | 1651 DiscardNonCommittedEntriesInternal(); |
1652 | 1652 |
1653 int current_size = static_cast<int>(entries_.size()); | 1653 int current_size = static_cast<int>(entries_.size()); |
1654 DCHECK_IMPLIES(replace, current_size > 0); | 1654 |
1655 // When replacing, don't prune the forward history. | |
1656 if (replace) { | |
1657 DCHECK_GT(current_size, 0); | |
1658 int32 page_id = entry->GetPageID(); | |
1659 | |
1660 // ScopedVectors don't automatically delete the replaced value, so make sure | |
Charlie Reis
2015/07/16 23:51:14
Nick and I took a look, and there doesn't appear t
Avi (use Gerrit)
2015/07/17 02:17:24
Yeah. As soon as we can use the C++11 library we'l
dcheng
2015/07/17 03:49:59
An alternate way of doing this which maintains the
ncarter (slow)
2015/07/17 16:54:20
reinterpret_cast<scoped_ptr<NavigationEntryImpl>&>
Charlie Reis
2015/07/17 17:00:11
Heh, I've stumbled into a fun corner case, I see.
| |
1661 // the previous value gets deleted. | |
1662 scoped_ptr<NavigationEntryImpl> old_entry( | |
1663 entries_[last_committed_entry_index_]); | |
1664 entries_[last_committed_entry_index_] = entry.release(); | |
1665 | |
1666 // This is a new page ID, so we need everybody to know about it. | |
1667 delegate_->UpdateMaxPageID(page_id); | |
1668 return; | |
1669 } | |
1655 | 1670 |
1656 if (current_size > 0) { | 1671 if (current_size > 0) { |
1657 // Prune any entries which are in front of the current entry. | 1672 // Prune any entries which are in front of the current entry. |
1658 // Also prune the current entry if we are to replace the current entry. | |
1659 // last_committed_entry_index_ must be updated here since calls to | 1673 // last_committed_entry_index_ must be updated here since calls to |
1660 // NotifyPrunedEntries() below may re-enter and we must make sure | 1674 // NotifyPrunedEntries() below may re-enter and we must make sure |
1661 // last_committed_entry_index_ is not left in an invalid state. | 1675 // last_committed_entry_index_ is not left in an invalid state. |
1662 if (replace) | |
1663 --last_committed_entry_index_; | |
1664 | |
1665 int num_pruned = 0; | 1676 int num_pruned = 0; |
1666 while (last_committed_entry_index_ < (current_size - 1)) { | 1677 while (last_committed_entry_index_ < (current_size - 1)) { |
1667 num_pruned++; | 1678 num_pruned++; |
1668 entries_.pop_back(); | 1679 entries_.pop_back(); |
1669 current_size--; | 1680 current_size--; |
1670 } | 1681 } |
1671 if (num_pruned > 0) // Only notify if we did prune something. | 1682 if (num_pruned > 0) // Only notify if we did prune something. |
1672 NotifyPrunedEntries(this, false, num_pruned); | 1683 NotifyPrunedEntries(this, false, num_pruned); |
1673 } | 1684 } |
1674 | 1685 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1997 } | 2008 } |
1998 } | 2009 } |
1999 } | 2010 } |
2000 | 2011 |
2001 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2012 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
2002 const base::Callback<base::Time()>& get_timestamp_callback) { | 2013 const base::Callback<base::Time()>& get_timestamp_callback) { |
2003 get_timestamp_callback_ = get_timestamp_callback; | 2014 get_timestamp_callback_ = get_timestamp_callback; |
2004 } | 2015 } |
2005 | 2016 |
2006 } // namespace content | 2017 } // namespace content |
OLD | NEW |