summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sync/engine/build_commit_command.cc4
-rw-r--r--sync/engine/commit.cc8
-rw-r--r--sync/engine/get_commit_ids_command.cc16
-rw-r--r--sync/engine/process_commit_response_command.cc18
-rw-r--r--sync/engine/process_commit_response_command.h2
-rw-r--r--sync/engine/process_commit_response_command_unittest.cc2
-rw-r--r--sync/engine/syncer_unittest.cc33
-rw-r--r--sync/sessions/ordered_commit_set.cc21
-rw-r--r--sync/sessions/ordered_commit_set.h23
-rw-r--r--sync/sessions/ordered_commit_set_unittest.cc87
10 files changed, 103 insertions, 111 deletions
diff --git a/sync/engine/build_commit_command.cc b/sync/engine/build_commit_command.cc
index 53c5221..70333c6 100644
--- a/sync/engine/build_commit_command.cc
+++ b/sync/engine/build_commit_command.cc
@@ -119,10 +119,10 @@ SyncerError BuildCommitCommand::ExecuteImpl(SyncSession* session) {
AddClientConfigParamsToMessage(session, commit_message);
for (size_t i = 0; i < batch_commit_set_.Size(); i++) {
- Id id = batch_commit_set_.GetCommitIdAt(i);
+ int64 handle = batch_commit_set_.GetCommitHandleAt(i);
sync_pb::SyncEntity* sync_entry = commit_message->add_entries();
- Entry meta_entry(trans_, syncable::GET_BY_ID, id);
+ Entry meta_entry(trans_, syncable::GET_BY_HANDLE, handle);
CHECK(meta_entry.good());
DCHECK_NE(0UL,
diff --git a/sync/engine/commit.cc b/sync/engine/commit.cc
index ee69812..f7f1e74 100644
--- a/sync/engine/commit.cc
+++ b/sync/engine/commit.cc
@@ -26,10 +26,10 @@ namespace {
void SetAllSyncingBitsToValue(WriteTransaction* trans,
const sessions::OrderedCommitSet& commit_set,
bool value_to_set) {
- const std::vector<syncable::Id>& commit_ids = commit_set.GetAllCommitIds();
- for (std::vector<syncable::Id>::const_iterator it = commit_ids.begin();
- it != commit_ids.end(); ++it) {
- syncable::MutableEntry entry(trans, syncable::GET_BY_ID, *it);
+ const std::vector<int64>& commit_handles = commit_set.GetAllCommitHandles();
+ for (std::vector<int64>::const_iterator it = commit_handles.begin();
+ it != commit_handles.end(); ++it) {
+ syncable::MutableEntry entry(trans, syncable::GET_BY_HANDLE, *it);
if (entry.good()) {
entry.Put(syncable::SYNCING, value_to_set);
}
diff --git a/sync/engine/get_commit_ids_command.cc b/sync/engine/get_commit_ids_command.cc
index b2f0cbf..931886d 100644
--- a/sync/engine/get_commit_ids_command.cc
+++ b/sync/engine/get_commit_ids_command.cc
@@ -74,12 +74,6 @@ SyncerError GetCommitIdsCommand::ExecuteImpl(SyncSession* session) {
session->context()->routing_info(),
ready_unsynced_set);
- const vector<syncable::Id>& verified_commit_ids =
- commit_set_->GetAllCommitIds();
-
- for (size_t i = 0; i < verified_commit_ids.size(); i++)
- DVLOG(1) << "Debug commit batch result:" << verified_commit_ids[i];
-
return SYNCER_OK;
}
@@ -225,8 +219,7 @@ void GetCommitIdsCommand::TryAddItem(const std::set<int64>& ready_unsynced_set,
DCHECK(item.Get(syncable::IS_UNSYNCED));
int64 item_handle = item.Get(syncable::META_HANDLE);
if (ready_unsynced_set.count(item_handle) != 0) {
- result->AddCommitItem(item_handle, item.Get(syncable::ID),
- item.GetModelType());
+ result->AddCommitItem(item_handle, item.GetModelType());
}
}
@@ -366,9 +359,7 @@ void GetCommitIdsCommand::AddDeletes(
DVLOG(1) << "Inserting moved and deleted entry, will be missed by "
<< "delete roll." << entry.Get(syncable::ID);
- commit_set_->AddCommitItem(metahandle,
- entry.Get(syncable::ID),
- entry.GetModelType());
+ commit_set_->AddCommitItem(metahandle, entry.GetModelType());
}
// Skip this entry since it's a child of a parent that will be
@@ -404,8 +395,7 @@ void GetCommitIdsCommand::AddDeletes(
if (entry.Get(syncable::IS_DEL)) {
syncable::Id parent_id = entry.Get(syncable::PARENT_ID);
if (legal_delete_parents.count(parent_id)) {
- commit_set_->AddCommitItem(metahandle, entry.Get(syncable::ID),
- entry.GetModelType());
+ commit_set_->AddCommitItem(metahandle, entry.GetModelType());
}
}
}
diff --git a/sync/engine/process_commit_response_command.cc b/sync/engine/process_commit_response_command.cc
index 4a921cf..5411773 100644
--- a/sync/engine/process_commit_response_command.cc
+++ b/sync/engine/process_commit_response_command.cc
@@ -38,6 +38,7 @@ using syncable::MutableEntry;
using syncable::Entry;
using syncable::BASE_VERSION;
using syncable::GET_BY_ID;
+using syncable::GET_BY_HANDLE;
using syncable::ID;
using syncable::IS_DEL;
using syncable::IS_DIR;
@@ -100,7 +101,7 @@ SyncerError ProcessCommitResponseCommand::ModelChangingExecuteImpl(
&trans,
cr.entryresponse(proj[i]),
commit_message.entries(proj[i]),
- commit_set_.GetCommitIdAt(proj[i]),
+ commit_set_.GetCommitHandleAt(proj[i]),
&deleted_folders);
switch (response_type) {
case CommitResponse::INVALID_MESSAGE:
@@ -168,10 +169,9 @@ ProcessCommitResponseCommand::ProcessSingleCommitResponse(
syncable::WriteTransaction* trans,
const sync_pb::CommitResponse_EntryResponse& server_entry,
const sync_pb::SyncEntity& commit_request_entry,
- const syncable::Id& pre_commit_id,
+ const int64 metahandle,
set<syncable::Id>* deleted_folders) {
-
- MutableEntry local_entry(trans, GET_BY_ID, pre_commit_id);
+ MutableEntry local_entry(trans, GET_BY_HANDLE, metahandle);
CHECK(local_entry.good());
bool syncing_was_set = local_entry.Get(SYNCING);
local_entry.Put(SYNCING, false);
@@ -216,11 +216,13 @@ ProcessCommitResponseCommand::ProcessSingleCommitResponse(
// it as an error response and retry later.
const syncable::Id& server_entry_id =
SyncableIdFromProto(server_entry.id_string());
- if (pre_commit_id != server_entry_id) {
+ if (local_entry.Get(ID) != server_entry_id) {
Entry e(trans, GET_BY_ID, server_entry_id);
if (e.good()) {
- LOG(ERROR) << "Got duplicate id when commiting id: " << pre_commit_id <<
- ". Treating as an error return";
+ LOG(ERROR)
+ << "Got duplicate id when commiting id: "
+ << local_entry.Get(ID)
+ << ". Treating as an error return";
return CommitResponse::INVALID_MESSAGE;
}
}
@@ -230,7 +232,7 @@ ProcessCommitResponseCommand::ProcessSingleCommitResponse(
}
ProcessSuccessfulCommitResponse(commit_request_entry, server_entry,
- pre_commit_id, &local_entry, syncing_was_set, deleted_folders);
+ local_entry.Get(ID), &local_entry, syncing_was_set, deleted_folders);
return response;
}
diff --git a/sync/engine/process_commit_response_command.h b/sync/engine/process_commit_response_command.h
index 155a47d..15ce4eb 100644
--- a/sync/engine/process_commit_response_command.h
+++ b/sync/engine/process_commit_response_command.h
@@ -70,7 +70,7 @@ class SYNC_EXPORT_PRIVATE ProcessCommitResponseCommand
syncable::WriteTransaction* trans,
const sync_pb::CommitResponse_EntryResponse& pb_commit_response,
const sync_pb::SyncEntity& pb_committed_entry,
- const syncable::Id& pre_commit_id,
+ int64 metahandle,
std::set<syncable::Id>* deleted_folders);
void ProcessSuccessfulCommitResponse(
diff --git a/sync/engine/process_commit_response_command_unittest.cc b/sync/engine/process_commit_response_command_unittest.cc
index 1520ca2..7f3e369 100644
--- a/sync/engine/process_commit_response_command_unittest.cc
+++ b/sync/engine/process_commit_response_command_unittest.cc
@@ -98,7 +98,7 @@ class ProcessCommitResponseCommandTest : public SyncerCommandTest {
// ProcessCommitResponseCommand consumes commit_ids from the session
// state, so we need to update that. O(n^2) because it's a test.
- commit_set->AddCommitItem(metahandle, item_id, model_type);
+ commit_set->AddCommitItem(metahandle, model_type);
WriteTransaction trans(FROM_HERE, UNITTEST, directory());
MutableEntry entry(&trans, syncable::GET_BY_ID, item_id);
diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc
index 96b664f..068d863 100644
--- a/sync/engine/syncer_unittest.cc
+++ b/sync/engine/syncer_unittest.cc
@@ -393,8 +393,8 @@ class SyncerTest : public testing::Test,
}
void DoTruncationTest(const vector<int64>& unsynced_handle_view,
- const vector<syncable::Id>& expected_id_order) {
- for (size_t limit = expected_id_order.size() + 2; limit > 0; --limit) {
+ const vector<int64>& expected_handle_order) {
+ for (size_t limit = expected_handle_order.size() + 2; limit > 0; --limit) {
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
ModelSafeRoutingInfo routes;
@@ -407,10 +407,10 @@ class SyncerTest : public testing::Test,
ModelTypeSet(), false,
unsynced_handle_view, &ready_unsynced_set);
command.BuildCommitIds(&wtrans, routes, ready_unsynced_set);
- size_t truncated_size = std::min(limit, expected_id_order.size());
+ size_t truncated_size = std::min(limit, expected_handle_order.size());
ASSERT_EQ(truncated_size, output_set.Size());
for (size_t i = 0; i < truncated_size; ++i) {
- ASSERT_EQ(expected_id_order[i], output_set.GetCommitIdAt(i))
+ ASSERT_EQ(expected_handle_order[i], output_set.GetCommitHandleAt(i))
<< "At index " << i << " with batch size limited to " << limit;
}
sessions::OrderedCommitSet::Projection proj;
@@ -418,10 +418,10 @@ class SyncerTest : public testing::Test,
ASSERT_EQ(truncated_size, proj.size());
for (size_t i = 0; i < truncated_size; ++i) {
SCOPED_TRACE(::testing::Message("Projection mismatch with i = ") << i);
- syncable::Id projected = output_set.GetCommitIdAt(proj[i]);
- ASSERT_EQ(expected_id_order[proj[i]], projected);
+ int64 projected = output_set.GetCommitHandleAt(proj[i]);
+ ASSERT_EQ(expected_handle_order[proj[i]], projected);
// Since this projection is the identity, the following holds.
- ASSERT_EQ(expected_id_order[i], projected);
+ ASSERT_EQ(expected_handle_order[i], projected);
}
}
}
@@ -600,6 +600,7 @@ TEST_F(SyncerTest, GetCommitIdsCommandTruncates) {
CreateUnsyncedDirectory("E", ids_.MakeLocal("e"));
CreateUnsyncedDirectory("J", ids_.MakeLocal("j"));
+ vector<int64> expected_order;
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
MutableEntry entry_x(&wtrans, GET_BY_ID, ids_.MakeServer("x"));
@@ -620,24 +621,24 @@ TEST_F(SyncerTest, GetCommitIdsCommandTruncates) {
entry_w.Put(SERVER_VERSION, 20);
entry_w.Put(IS_UNAPPLIED_UPDATE, true); // Fake a conflict.
entry_j.PutPredecessor(entry_w.Get(ID));
+
+ // The expected order is "x", "b", "c", "d", "e", "j", truncated
+ // appropriately.
+ expected_order.push_back(entry_x.Get(META_HANDLE));
+ expected_order.push_back(entry_b.Get(META_HANDLE));
+ expected_order.push_back(entry_c.Get(META_HANDLE));
+ expected_order.push_back(entry_d.Get(META_HANDLE));
+ expected_order.push_back(entry_e.Get(META_HANDLE));
+ expected_order.push_back(entry_j.Get(META_HANDLE));
}
// The arrangement is now: x (b (d) c (e)) w j
// Entry "w" is in conflict, so it is not eligible for commit.
vector<int64> unsynced_handle_view;
- vector<syncable::Id> expected_order;
{
syncable::ReadTransaction rtrans(FROM_HERE, directory());
GetUnsyncedEntries(&rtrans, &unsynced_handle_view);
}
- // The expected order is "x", "b", "c", "d", "e", "j", truncated
- // appropriately.
- expected_order.push_back(ids_.MakeServer("x"));
- expected_order.push_back(ids_.MakeLocal("b"));
- expected_order.push_back(ids_.MakeLocal("c"));
- expected_order.push_back(ids_.MakeLocal("d"));
- expected_order.push_back(ids_.MakeLocal("e"));
- expected_order.push_back(ids_.MakeLocal("j"));
DoTruncationTest(unsynced_handle_view, expected_order);
}
diff --git a/sync/sessions/ordered_commit_set.cc b/sync/sessions/ordered_commit_set.cc
index 842a0e9..3bbddb9 100644
--- a/sync/sessions/ordered_commit_set.cc
+++ b/sync/sessions/ordered_commit_set.cc
@@ -18,19 +18,26 @@ OrderedCommitSet::OrderedCommitSet(const ModelSafeRoutingInfo& routes)
OrderedCommitSet::~OrderedCommitSet() {}
void OrderedCommitSet::AddCommitItem(const int64 metahandle,
- const syncable::Id& commit_id,
ModelType type) {
if (!HaveCommitItem(metahandle)) {
inserted_metahandles_.insert(metahandle);
metahandle_order_.push_back(metahandle);
- commit_ids_.push_back(commit_id);
projections_[GetGroupForModelType(type, routes_)].push_back(
- commit_ids_.size() - 1);
+ inserted_metahandles_.size() - 1);
types_.push_back(type);
types_in_list_.Put(type);
}
}
+void OrderedCommitSet::AddCommitItems(
+ const std::vector<int64> metahandles,
+ ModelType type) {
+ for (std::vector<int64>::const_iterator it = metahandles.begin();
+ it != metahandles.end(); ++it) {
+ AddCommitItem(*it, type);
+ }
+}
+
const OrderedCommitSet::Projection& OrderedCommitSet::GetCommitIdProjection(
ModelSafeGroup group) const {
Projections::const_iterator i = projections_.find(group);
@@ -41,14 +48,14 @@ const OrderedCommitSet::Projection& OrderedCommitSet::GetCommitIdProjection(
void OrderedCommitSet::Append(const OrderedCommitSet& other) {
for (size_t i = 0; i < other.Size(); ++i) {
CommitItem item = other.GetCommitItemAt(i);
- AddCommitItem(item.meta, item.id, item.group);
+ AddCommitItem(item.meta, item.group);
}
}
void OrderedCommitSet::AppendReverse(const OrderedCommitSet& other) {
for (int i = other.Size() - 1; i >= 0; i--) {
CommitItem item = other.GetCommitItemAt(i);
- AddCommitItem(item.meta, item.id, item.group);
+ AddCommitItem(item.meta, item.group);
}
}
@@ -72,7 +79,6 @@ void OrderedCommitSet::Truncate(size_t max_size) {
if (element != p.end())
p.erase(element, p.end());
}
- commit_ids_.resize(max_size);
metahandle_order_.resize(max_size);
types_.resize(max_size);
}
@@ -80,7 +86,6 @@ void OrderedCommitSet::Truncate(size_t max_size) {
void OrderedCommitSet::Clear() {
inserted_metahandles_.clear();
- commit_ids_.clear();
metahandle_order_.clear();
for (Projections::iterator it = projections_.begin();
it != projections_.end(); ++it) {
@@ -94,7 +99,6 @@ OrderedCommitSet::CommitItem OrderedCommitSet::GetCommitItemAt(
const size_t position) const {
DCHECK(position < Size());
CommitItem return_item = {metahandle_order_[position],
- commit_ids_[position],
types_[position]};
return return_item;
}
@@ -116,7 +120,6 @@ bool OrderedCommitSet::HasBookmarkCommitId() const {
void OrderedCommitSet::operator=(const OrderedCommitSet& other) {
inserted_metahandles_ = other.inserted_metahandles_;
- commit_ids_ = other.commit_ids_;
metahandle_order_ = other.metahandle_order_;
projections_ = other.projections_;
types_ = other.types_;
diff --git a/sync/sessions/ordered_commit_set.h b/sync/sessions/ordered_commit_set.h
index ae99dcd..a30724e 100644
--- a/sync/sessions/ordered_commit_set.h
+++ b/sync/sessions/ordered_commit_set.h
@@ -12,7 +12,6 @@
#include "sync/base/sync_export.h"
#include "sync/internal_api/public/base/model_type.h"
#include "sync/internal_api/public/engine/model_safe_worker.h"
-#include "sync/syncable/syncable_id.h"
namespace syncer {
namespace sessions {
@@ -37,22 +36,22 @@ class SYNC_EXPORT_PRIVATE OrderedCommitSet {
return inserted_metahandles_.count(metahandle) > 0;
}
- void AddCommitItem(const int64 metahandle, const syncable::Id& commit_id,
- ModelType type);
+ void AddCommitItem(const int64 metahandle, ModelType type);
+ void AddCommitItems(const std::vector<int64> metahandles, ModelType type);
- const std::vector<syncable::Id>& GetAllCommitIds() const {
- return commit_ids_;
+ const std::vector<int64>& GetAllCommitHandles() const {
+ return metahandle_order_;
}
- // Return the Id at index |position| in this OrderedCommitSet. Note that
+ // Return the handle at index |position| in this OrderedCommitSet. Note that
// the index uniquely identifies the same logical item in each of:
// 1) this OrderedCommitSet
// 2) the CommitRequest sent to the server
// 3) the list of EntryResponse objects in the CommitResponse.
// These together allow re-association of the pre-commit Id with the
// actual committed entry.
- const syncable::Id& GetCommitIdAt(const size_t position) const {
- return commit_ids_[position];
+ int64 GetCommitHandleAt(const size_t position) const {
+ return metahandle_order_[position];
}
// Same as above, but for ModelType of the item.
@@ -68,7 +67,7 @@ class SYNC_EXPORT_PRIVATE OrderedCommitSet {
ModelSafeGroup group) const;
size_t Size() const {
- return commit_ids_.size();
+ return metahandle_order_.size();
}
bool Empty() const {
@@ -99,7 +98,6 @@ class SYNC_EXPORT_PRIVATE OrderedCommitSet {
// Helper container for return value of GetCommitItemAt.
struct CommitItem {
int64 meta;
- syncable::Id id;
ModelType group;
};
@@ -108,16 +106,13 @@ class SYNC_EXPORT_PRIVATE OrderedCommitSet {
// These lists are different views of the same items; e.g they are
// isomorphic.
std::set<int64> inserted_metahandles_;
- std::vector<syncable::Id> commit_ids_;
std::vector<int64> metahandle_order_;
Projections projections_;
// We need this because of operations like AppendReverse that take ids from
// one OrderedCommitSet and insert into another -- we need to know the
// group for each ID so that the insertion can update the appropriate
- // projection. We could store it in commit_ids_, but sometimes we want
- // to just return the vector of Ids, so this is more straightforward
- // and shouldn't take up too much extra space since commit lists are small.
+ // projection.
std::vector<ModelType> types_;
// The set of types which are included in this particular list.
diff --git a/sync/sessions/ordered_commit_set_unittest.cc b/sync/sessions/ordered_commit_set_unittest.cc
index 4bf1d61..4aca4f4 100644
--- a/sync/sessions/ordered_commit_set_unittest.cc
+++ b/sync/sessions/ordered_commit_set_unittest.cc
@@ -26,90 +26,91 @@ class OrderedCommitSetTest : public testing::Test {
};
TEST_F(OrderedCommitSetTest, Projections) {
- vector<syncable::Id> expected;
- for (int i = 0; i < 8; i++)
- expected.push_back(ids_.NewLocalId());
+ vector<int64> expected;
+ for (int64 i = 0; i < 8; i++)
+ expected.push_back(i);
OrderedCommitSet commit_set1(routes_), commit_set2(routes_);
- commit_set1.AddCommitItem(0, expected[0], BOOKMARKS);
- commit_set1.AddCommitItem(1, expected[1], BOOKMARKS);
- commit_set1.AddCommitItem(2, expected[2], PREFERENCES);
+ commit_set1.AddCommitItem(expected[0], BOOKMARKS);
+ commit_set1.AddCommitItem(expected[1], BOOKMARKS);
+ commit_set1.AddCommitItem(expected[2], PREFERENCES);
// Duplicates should be dropped.
- commit_set1.AddCommitItem(2, expected[2], PREFERENCES);
- commit_set1.AddCommitItem(3, expected[3], SESSIONS);
- commit_set1.AddCommitItem(4, expected[4], SESSIONS);
- commit_set2.AddCommitItem(7, expected[7], AUTOFILL);
- commit_set2.AddCommitItem(6, expected[6], AUTOFILL);
- commit_set2.AddCommitItem(5, expected[5], AUTOFILL);
+ commit_set1.AddCommitItem(expected[2], PREFERENCES);
+ commit_set1.AddCommitItem(expected[3], SESSIONS);
+ commit_set1.AddCommitItem(expected[4], SESSIONS);
+ commit_set2.AddCommitItem(expected[7], AUTOFILL);
+ commit_set2.AddCommitItem(expected[6], AUTOFILL);
+ commit_set2.AddCommitItem(expected[5], AUTOFILL);
// Add something in set1 to set2, which should get dropped by AppendReverse.
- commit_set2.AddCommitItem(0, expected[0], BOOKMARKS);
+ commit_set2.AddCommitItem(expected[0], BOOKMARKS);
commit_set1.AppendReverse(commit_set2);
+ EXPECT_EQ(8U, commit_set1.Size());
+
// First, we should verify the projections are correct. Second, we want to
// do the same verification after truncating by 1. Next, try truncating
// the set to a size of 4, so that the DB projection is wiped out and
// PASSIVE has one element removed. Finally, truncate to 1 so only UI is
// remaining.
- int j = 0;
- do {
- SCOPED_TRACE(::testing::Message("Iteration j = ") << j);
- vector<syncable::Id> all_ids = commit_set1.GetAllCommitIds();
- EXPECT_EQ(expected.size(), all_ids.size());
- for (size_t i = 0; i < expected.size(); i++) {
- SCOPED_TRACE(::testing::Message("CommitSet mismatch at iteration i = ")
- << i);
+ std::vector<size_t> sizes;
+ sizes.push_back(8);
+ sizes.push_back(7);
+ sizes.push_back(4);
+ sizes.push_back(1);
+ for (std::vector<size_t>::iterator it = sizes.begin();
+ it != sizes.end(); ++it) {
+ commit_set1.Truncate(*it);
+ size_t expected_size = *it;
+
+ SCOPED_TRACE(::testing::Message("Iteration size = ") << *it);
+ std::vector<int64> all_ids = commit_set1.GetAllCommitHandles();
+ EXPECT_EQ(expected_size, all_ids.size());
+ for (size_t i = 0; i < expected_size; i++) {
EXPECT_TRUE(expected[i] == all_ids[i]);
- EXPECT_TRUE(expected[i] == commit_set1.GetCommitIdAt(i));
+ EXPECT_TRUE(expected[i] == commit_set1.GetCommitHandleAt(i));
}
OrderedCommitSet::Projection p1, p2, p3;
p1 = commit_set1.GetCommitIdProjection(GROUP_UI);
p2 = commit_set1.GetCommitIdProjection(GROUP_PASSIVE);
p3 = commit_set1.GetCommitIdProjection(GROUP_DB);
- EXPECT_TRUE(p1.size() + p2.size() + p3.size() == expected.size()) << "Sum"
+ EXPECT_TRUE(p1.size() + p2.size() + p3.size() == expected_size) << "Sum"
<< "of sizes of projections should equal full expected size!";
for (size_t i = 0; i < p1.size(); i++) {
SCOPED_TRACE(::testing::Message("UI projection mismatch at i = ") << i);
- EXPECT_TRUE(expected[p1[i]] == commit_set1.GetCommitIdAt(p1[i]))
+ EXPECT_TRUE(expected[p1[i]] == commit_set1.GetCommitHandleAt(p1[i]))
<< "expected[p1[i]] = " << expected[p1[i]]
- << ", commit_set1[p1[i]] = " << commit_set1.GetCommitIdAt(p1[i]);
+ << ", commit_set1[p1[i]] = " << commit_set1.GetCommitHandleAt(p1[i]);
}
for (size_t i = 0; i < p2.size(); i++) {
SCOPED_TRACE(::testing::Message("PASSIVE projection mismatch at i = ")
<< i);
- EXPECT_TRUE(expected[p2[i]] == commit_set1.GetCommitIdAt(p2[i]))
+ EXPECT_TRUE(expected[p2[i]] == commit_set1.GetCommitHandleAt(p2[i]))
<< "expected[p2[i]] = " << expected[p2[i]]
- << ", commit_set1[p2[i]] = " << commit_set1.GetCommitIdAt(p2[i]);
+ << ", commit_set1[p2[i]] = " << commit_set1.GetCommitHandleAt(p2[i]);
}
for (size_t i = 0; i < p3.size(); i++) {
SCOPED_TRACE(::testing::Message("DB projection mismatch at i = ") << i);
- EXPECT_TRUE(expected[p3[i]] == commit_set1.GetCommitIdAt(p3[i]))
+ EXPECT_TRUE(expected[p3[i]] == commit_set1.GetCommitHandleAt(p3[i]))
<< "expected[p3[i]] = " << expected[p3[i]]
- << ", commit_set1[p3[i]] = " << commit_set1.GetCommitIdAt(p3[i]);
+ << ", commit_set1[p3[i]] = " << commit_set1.GetCommitHandleAt(p3[i]);
}
-
- int cut_to_size = 7 - 3 * j++;
- if (cut_to_size < 0)
- break;
-
- expected.resize(cut_to_size);
- commit_set1.Truncate(cut_to_size);
- } while (true);
+ }
}
TEST_F(OrderedCommitSetTest, HasBookmarkCommitId) {
OrderedCommitSet commit_set(routes_);
- commit_set.AddCommitItem(0, ids_.NewLocalId(), AUTOFILL);
- commit_set.AddCommitItem(1, ids_.NewLocalId(), SESSIONS);
+ commit_set.AddCommitItem(0, AUTOFILL);
+ commit_set.AddCommitItem(1, SESSIONS);
EXPECT_FALSE(commit_set.HasBookmarkCommitId());
- commit_set.AddCommitItem(2, ids_.NewLocalId(), PREFERENCES);
- commit_set.AddCommitItem(3, ids_.NewLocalId(), PREFERENCES);
+ commit_set.AddCommitItem(2, PREFERENCES);
+ commit_set.AddCommitItem(3, PREFERENCES);
EXPECT_FALSE(commit_set.HasBookmarkCommitId());
- commit_set.AddCommitItem(4, ids_.NewLocalId(), BOOKMARKS);
+ commit_set.AddCommitItem(4, BOOKMARKS);
EXPECT_TRUE(commit_set.HasBookmarkCommitId());
commit_set.Truncate(4);
@@ -121,7 +122,7 @@ TEST_F(OrderedCommitSetTest, AddAndRemoveEntries) {
ASSERT_TRUE(commit_set.Empty());
- commit_set.AddCommitItem(0, ids_.NewLocalId(), AUTOFILL);
+ commit_set.AddCommitItem(0, AUTOFILL);
ASSERT_EQ(static_cast<size_t>(1), commit_set.Size());
commit_set.Clear();