Index: sync/internal_api/write_node.cc |
diff --git a/sync/internal_api/write_node.cc b/sync/internal_api/write_node.cc |
index 2057c25f9b10f9e0cd9613a39251a8bbfde106dc..1a6a0bc1b42ee85f140c1e79c6ab805fa349d6fa 100644 |
--- a/sync/internal_api/write_node.cc |
+++ b/sync/internal_api/write_node.cc |
@@ -205,12 +205,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); |
@@ -320,22 +315,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()) { |
@@ -350,7 +333,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; |
@@ -358,8 +342,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); |
} |
@@ -427,7 +409,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; |
@@ -438,9 +421,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) |