| Index: sync/internal_api/write_node.cc
|
| diff --git a/sync/internal_api/write_node.cc b/sync/internal_api/write_node.cc
|
| index 56285715940e421f328291ba71994a5010977438..43d6e50313b11d6b47cf611d0087049325a8fe63 100644
|
| --- a/sync/internal_api/write_node.cc
|
| +++ b/sync/internal_api/write_node.cc
|
| @@ -212,12 +212,7 @@ void WriteNode::SetEntitySpecifics(
|
| DCHECK_NE(new_specifics_type, UNSPECIFIED);
|
| DVLOG(1) << "Writing entity specifics of type "
|
| << ModelTypeToString(new_specifics_type);
|
| - // GetModelType() can be unspecified if this is the first time this
|
| - // node is being initialized (see PutModelType()). Otherwise, it
|
| - // should match |new_specifics_type|.
|
| - if (GetModelType() != UNSPECIFIED) {
|
| - DCHECK_EQ(new_specifics_type, GetModelType());
|
| - }
|
| + DCHECK_EQ(new_specifics_type, GetModelType());
|
|
|
| // Preserve unknown fields.
|
| const sync_pb::EntitySpecifics& old_specifics = entry_->Get(SPECIFICS);
|
| @@ -327,22 +322,10 @@ BaseNode::InitByLookupResult WriteNode::InitByTagLookup(
|
| return INIT_OK;
|
| }
|
|
|
| -void WriteNode::PutModelType(ModelType model_type) {
|
| - // Set an empty specifics of the appropriate datatype. The presence
|
| - // of the specific field will identify the model type.
|
| - DCHECK(GetModelType() == model_type ||
|
| - GetModelType() == UNSPECIFIED); // Immutable once set.
|
| -
|
| - sync_pb::EntitySpecifics specifics;
|
| - AddDefaultFieldValue(model_type, &specifics);
|
| - SetEntitySpecifics(specifics);
|
| -}
|
| -
|
| // Create a new node with default properties, and bind this WriteNode to it.
|
| // Return true on success.
|
| -bool WriteNode::InitByCreation(ModelType model_type,
|
| - const BaseNode& parent,
|
| - const BaseNode* predecessor) {
|
| +bool WriteNode::InitBookmarkByCreation(const BaseNode& parent,
|
| + const BaseNode* predecessor) {
|
| DCHECK(!entry_) << "Init called twice";
|
| // |predecessor| must be a child of |parent| or NULL.
|
| if (predecessor && predecessor->GetParentId() != parent.GetId()) {
|
| @@ -357,7 +340,8 @@ bool WriteNode::InitByCreation(ModelType model_type,
|
| string dummy(kDefaultNameForNewNodes);
|
|
|
| entry_ = new syncable::MutableEntry(transaction_->GetWrappedWriteTrans(),
|
| - syncable::CREATE, parent_id, dummy);
|
| + syncable::CREATE, BOOKMARKS,
|
| + parent_id, dummy);
|
|
|
| if (!entry_->good())
|
| return false;
|
| @@ -365,8 +349,6 @@ bool WriteNode::InitByCreation(ModelType model_type,
|
| // Entries are untitled folders by default.
|
| entry_->Put(syncable::IS_DIR, true);
|
|
|
| - PutModelType(model_type);
|
| -
|
| // Now set the predecessor, which sets IS_UNSYNCED as necessary.
|
| return PutPredecessor(predecessor);
|
| }
|
| @@ -434,7 +416,8 @@ WriteNode::InitUniqueByCreationResult WriteNode::InitUniqueByCreation(
|
| }
|
| } else {
|
| entry_ = new syncable::MutableEntry(transaction_->GetWrappedWriteTrans(),
|
| - syncable::CREATE, parent_id, dummy);
|
| + syncable::CREATE,
|
| + model_type, parent_id, dummy);
|
| if (!entry_->good())
|
| return INIT_FAILED_COULD_NOT_CREATE_ENTRY;
|
|
|
| @@ -445,9 +428,6 @@ WriteNode::InitUniqueByCreationResult WriteNode::InitUniqueByCreation(
|
| // We don't support directory and tag combinations.
|
| entry_->Put(syncable::IS_DIR, false);
|
|
|
| - // Will clear specifics data.
|
| - PutModelType(model_type);
|
| -
|
| // Now set the predecessor, which sets IS_UNSYNCED as necessary.
|
| bool success = PutPredecessor(NULL);
|
| if (!success)
|
|
|