OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 } | 769 } |
770 | 770 |
771 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed | 771 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed |
772 TEST_F(ProfileSyncServiceSessionTest, TabNodePoolNonEmpty) { | 772 TEST_F(ProfileSyncServiceSessionTest, TabNodePoolNonEmpty) { |
773 CreateRootHelper create_root(this); | 773 CreateRootHelper create_root(this); |
774 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 774 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
775 ASSERT_TRUE(create_root.success()); | 775 ASSERT_TRUE(create_root.success()); |
776 | 776 |
777 const size_t num_starting_nodes = 3; | 777 const size_t num_starting_nodes = 3; |
778 for (size_t i = 0; i < num_starting_nodes; ++i) { | 778 for (size_t i = 0; i < num_starting_nodes; ++i) { |
779 model_associator_->tab_pool_.AddTabNode(i); | 779 model_associator_->tab_pool_.AddOldTabNode(i + 1, i); |
780 } | 780 } |
781 | 781 |
| 782 model_associator_->tab_pool_.FreeUnusedOldSyncNodes(std::set<int64>()); |
782 std::vector<int64> node_ids; | 783 std::vector<int64> node_ids; |
783 ASSERT_EQ(num_starting_nodes, model_associator_->tab_pool_.capacity()); | 784 ASSERT_EQ(num_starting_nodes, model_associator_->tab_pool_.capacity()); |
784 ASSERT_FALSE(model_associator_->tab_pool_.empty()); | 785 ASSERT_FALSE(model_associator_->tab_pool_.empty()); |
785 ASSERT_TRUE(model_associator_->tab_pool_.full()); | 786 ASSERT_TRUE(model_associator_->tab_pool_.full()); |
786 const size_t num_ids = 10; | 787 const size_t num_ids = 10; |
787 for (size_t i = 0; i < num_ids; ++i) { | 788 for (size_t i = 0; i < num_ids; ++i) { |
788 int64 id = model_associator_->tab_pool_.GetFreeTabNode(); | 789 int64 id = model_associator_->tab_pool_.GetFreeTabNode(); |
789 ASSERT_GT(id, -1); | 790 ASSERT_GT(id, -1); |
790 node_ids.push_back(id); | 791 node_ids.push_back(id); |
791 } | 792 } |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 NavigateAndCommitActiveTab(GURL("http://bar2")); | 1155 NavigateAndCommitActiveTab(GURL("http://bar2")); |
1155 CreateRootHelper create_root(this); | 1156 CreateRootHelper create_root(this); |
1156 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 1157 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
1157 std::string local_tag = model_associator_->GetCurrentMachineTag(); | 1158 std::string local_tag = model_associator_->GetCurrentMachineTag(); |
1158 syncer::SyncError error; | 1159 syncer::SyncError error; |
1159 | 1160 |
1160 error = model_associator_->DisassociateModels(); | 1161 error = model_associator_->DisassociateModels(); |
1161 ASSERT_FALSE(error.IsSet()); | 1162 ASSERT_FALSE(error.IsSet()); |
1162 { | 1163 { |
1163 // Delete the first sync tab node. | 1164 // Delete the first sync tab node. |
1164 std::string tab_tag = TabNodePool::TabIdToTag(local_tag, 0); | 1165 std::string tab_tag = TabNodePool::TabIdToTag(local_tag, 1); |
1165 | 1166 |
1166 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1167 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
1167 syncer::ReadNode root(&trans); | 1168 syncer::ReadNode root(&trans); |
1168 root.InitByTagLookup(syncer::ModelTypeToRootTag(syncer::SESSIONS)); | 1169 root.InitByTagLookup(syncer::ModelTypeToRootTag(syncer::SESSIONS)); |
1169 syncer::WriteNode tab_node(&trans); | 1170 syncer::WriteNode tab_node(&trans); |
1170 ASSERT_EQ(syncer::BaseNode::INIT_OK, | 1171 ASSERT_EQ(syncer::BaseNode::INIT_OK, |
1171 tab_node.InitByClientTagLookup(syncer::SESSIONS, tab_tag)); | 1172 tab_node.InitByClientTagLookup(syncer::SESSIONS, tab_tag)); |
1172 tab_node.Tombstone(); | 1173 tab_node.Tombstone(); |
1173 } | 1174 } |
1174 error = model_associator_->AssociateModels(NULL, NULL); | 1175 error = model_associator_->AssociateModels(NULL, NULL); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 sync_pb::SessionSpecifics specifics; | 1245 sync_pb::SessionSpecifics specifics; |
1245 header.SetSessionSpecifics(specifics); | 1246 header.SetSessionSpecifics(specifics); |
1246 } | 1247 } |
1247 // Ensure we associate properly despite the pre-existing node with our local | 1248 // Ensure we associate properly despite the pre-existing node with our local |
1248 // tag. | 1249 // tag. |
1249 error = model_associator_->AssociateModels(NULL, NULL); | 1250 error = model_associator_->AssociateModels(NULL, NULL); |
1250 ASSERT_FALSE(error.IsSet()); | 1251 ASSERT_FALSE(error.IsSet()); |
1251 } | 1252 } |
1252 | 1253 |
1253 } // namespace browser_sync | 1254 } // namespace browser_sync |
OLD | NEW |