summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-07 19:40:25 +0000
committerzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-07 19:40:25 +0000
commit698579949afd7b4b3a940b57dc3970029fb08f4a (patch)
treecb2889968f96e38fae684a63757285fe2e633ab6
parent52de24994cac199f2f0b384531c90901771a9f73 (diff)
downloadchromium_src-698579949afd7b4b3a940b57dc3970029fb08f4a.zip
chromium_src-698579949afd7b4b3a940b57dc3970029fb08f4a.tar.gz
chromium_src-698579949afd7b4b3a940b57dc3970029fb08f4a.tar.bz2
[Sync] Initialize pre-existing navs to zero timestamp
When we restore a session at restart, from a recently closed tab, or from other devices, we don't want to assign the current timestamp to all navigations. Only the current navigation should have the current timestamp, all others should be zero'd out. BUG=98892 TEST=unit tests Review URL: http://codereview.chromium.org/10381019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135699 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/glue/session_model_associator.cc9
-rw-r--r--chrome/browser/sync/glue/session_model_associator_unittest.cc7
2 files changed, 13 insertions, 3 deletions
diff --git a/chrome/browser/sync/glue/session_model_associator.cc b/chrome/browser/sync/glue/session_model_associator.cc
index 1848a6f..d0e875c 100644
--- a/chrome/browser/sync/glue/session_model_associator.cc
+++ b/chrome/browser/sync/glue/session_model_associator.cc
@@ -510,6 +510,15 @@ void SessionModelAssociator::AssociateTabContents(
// over navigations, so the subsequent navigation entries may need their
// old timestamps preserved.
++prev_nav_iter;
+ } else if (current_index != i &&
+ prev_tab->synced_tab_navigations.empty()) {
+ // If this is a new tab, and has more than one navigation, we don't
+ // actually want to assign the current timestamp to other navigations.
+ // Override the timestamp to 0 in that case.
+ // Note: this is primarily to handle restoring sessions at restart,
+ // opening recently closed tabs, or opening tabs from other devices.
+ // Only the current navigation should have a timestamp in those cases.
+ sync_nav->set_timestamp(0);
}
}
}
diff --git a/chrome/browser/sync/glue/session_model_associator_unittest.cc b/chrome/browser/sync/glue/session_model_associator_unittest.cc
index 11709d3..38a9673 100644
--- a/chrome/browser/sync/glue/session_model_associator_unittest.cc
+++ b/chrome/browser/sync/glue/session_model_associator_unittest.cc
@@ -561,7 +561,8 @@ TEST_F(SyncSessionModelAssociatorTest, FaviconCleanup) {
EXPECT_EQ(0U, NumFavicons());
}
-// Ensure new tabs have all new timestamps set.
+// Ensure new tabs have the current timestamp set for the current navigation,
+// while other navigations have timestamp zero.
TEST_F(SyncSessionModelAssociatorTest, AssociateNewTab) {
NiceMock<SyncedWindowDelegateMock> window_mock;
EXPECT_CALL(window_mock, IsTabPinned(_)).WillRepeatedly(Return(false));
@@ -606,8 +607,8 @@ TEST_F(SyncSessionModelAssociatorTest, AssociateNewTab) {
EXPECT_EQ(entry3->GetVirtualURL().spec(),
sync_tab.navigation(2).virtual_url());
EXPECT_EQ(2, sync_tab.current_navigation_index());
- EXPECT_LE(now, sync_tab.navigation(0).timestamp());
- EXPECT_LE(now, sync_tab.navigation(1).timestamp());
+ EXPECT_LE(0, sync_tab.navigation(0).timestamp());
+ EXPECT_LE(0, sync_tab.navigation(1).timestamp());
EXPECT_LE(now, sync_tab.navigation(2).timestamp());
}