From a3c07c2082a2347b5c74d8b0c0bb9240812d331e Mon Sep 17 00:00:00 2001 From: "rlarocque@chromium.org" Date: Fri, 11 Jan 2013 15:11:21 +0000 Subject: sync: Initialize entries with a valid model type This change modifies two important sync functions. The first is MutableEntry's CREATE constructor. It now requires that the ModelType of the entry to be specified when the entry is create. This doesn't quite eliminate the existence of nodes without a valid model type (the CREATE_NEW_UPDATE_ITEM can still make them), but it helps. This paves the way for the upcoming UniquePosition change. Part of that change is that bookmarks must be granted a unique tag on creation. To support this, we must know at creation time the type of a new entry, so we can take the appropriate bookmark-specific steps if necessary. The second function to get a new signature is WriteNode's InitByCreation(), which has been renamed to WriteNode::InitBookmarkByCreation(). The function can only be used to create bookmarks, so the new name describes its function more precisely. Updates to the call-sites of MutableEntry's constructor make up the majority of this change. This change also includes some minor updates to test functions that create entries to make them compatible with the stricter assertions or to make them more closely reflect real world behaviour. BUG=145412,126505 Review URL: https://chromiumcodereview.appspot.com/11817010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176340 0039d316-1c4b-4281-b951-d872f2087c98 --- sync/internal_api/public/test/test_entry_factory.h | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'sync/internal_api/public/test') diff --git a/sync/internal_api/public/test/test_entry_factory.h b/sync/internal_api/public/test/test_entry_factory.h index 071a501..7ca79e6 100644 --- a/sync/internal_api/public/test/test_entry_factory.h +++ b/sync/internal_api/public/test/test_entry_factory.h @@ -29,15 +29,21 @@ class TestEntryFactory { const sync_pb::EntitySpecifics& specifics, const std::string& parent_id); + int64 CreateUnappliedNewBookmarkItemWithParent( + const std::string& item_id, + const sync_pb::EntitySpecifics& specifics, + const std::string& parent_id); + // Create a new unapplied update without a parent. int64 CreateUnappliedNewItem(const std::string& item_id, const sync_pb::EntitySpecifics& specifics, bool is_unique); - // Create an unsynced item in the database. If item_id is a local ID, it will - // be treated as a create-new. Otherwise, if it's a server ID, we'll fake the - // server data so that it looks like it exists on the server. Returns the - // methandle of the created item in |metahandle_out| if not NULL. + // Create an unsynced unique_client_tag item in the database. If item_id is a + // local ID, it will be treated as a create-new. Otherwise, if it's a server + // ID, we'll fake the server data so that it looks like it exists on the + // server. Returns the methandle of the created item in |metahandle_out| if + // not NULL. void CreateUnsyncedItem(const syncable::Id& item_id, const syncable::Id& parent_id, const std::string& name, @@ -45,14 +51,13 @@ class TestEntryFactory { ModelType model_type, int64* metahandle_out); - // Creates an item that is both unsynced an an unapplied update. Returns the - // metahandle of the created item. - int64 CreateUnappliedAndUnsyncedItem(const std::string& name, - ModelType model_type); + // Creates a bookmark that is both unsynced an an unapplied update. Returns + // the metahandle of the created item. + int64 CreateUnappliedAndUnsyncedBookmarkItem(const std::string& name); - // Creates an item that has neither IS_UNSYNED or IS_UNAPPLIED_UPDATE. The - // item is known to both the server and client. Returns the metahandle of - // the created item. + // Creates a unique_client_tag item that has neither IS_UNSYNED or + // IS_UNAPPLIED_UPDATE. The item is known to both the server and client. + // Returns the metahandle of the created item. int64 CreateSyncedItem(const std::string& name, ModelType model_type, bool is_folder); -- cgit v1.1