Chromium Code Reviews| Index: sync/syncable/mutable_entry.cc |
| diff --git a/sync/syncable/mutable_entry.cc b/sync/syncable/mutable_entry.cc |
| index 64a23ced691f04c7f20b9dd1ae1a0504ebc2e878..816e951ed4d3d16ab3749bc1e65e238548ac2ca0 100644 |
| --- a/sync/syncable/mutable_entry.cc |
| +++ b/sync/syncable/mutable_entry.cc |
| @@ -19,15 +19,9 @@ using std::string; |
| namespace syncer { |
| namespace syncable { |
| -MutableEntry::MutableEntry(WriteTransaction* trans, Create, |
| - const Id& parent_id, const string& name) |
| - : Entry(trans), |
| - write_transaction_(trans) { |
| - Init(trans, parent_id, name); |
| -} |
| - |
| - |
| -void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id, |
| +void MutableEntry::Init(WriteTransaction* trans, |
| + ModelType model_type, |
| + const Id& parent_id, |
| const string& name) { |
| scoped_ptr<EntryKernel> kernel(new EntryKernel); |
| kernel_ = NULL; |
| @@ -43,9 +37,15 @@ void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id, |
| // We match the database defaults here |
| kernel->put(BASE_VERSION, CHANGES_VERSION); |
| kernel->put(SERVER_ORDINAL_IN_PARENT, NodeOrdinal::CreateInitialOrdinal()); |
| - if (!trans->directory()->InsertEntry(trans, kernel.get())) { |
| - return; // We failed inserting, nothing more to do. |
| - } |
| + |
| + // Normally the SPECIFICS setting code is wrapped in logic to deal with |
| + // unknown fields and encryption. Since all we want to do here is ensure that |
| + // GetModelType() returns a correct value from the very beginning, these |
| + // few lines are sufficient. |
| + sync_pb::EntitySpecifics specifics; |
| + AddDefaultFieldValue(model_type, &specifics); |
| + kernel->put(SPECIFICS, specifics); |
| + |
| // Because this entry is new, it was originally deleted. |
| kernel->put(IS_DEL, true); |
| trans->SaveOriginal(kernel.get()); |
| @@ -55,6 +55,17 @@ void MutableEntry::Init(WriteTransaction* trans, const Id& parent_id, |
| kernel_ = kernel.release(); |
| } |
| +MutableEntry::MutableEntry(WriteTransaction* trans, |
| + Create, |
| + ModelType model_type, |
| + const Id& parent_id, |
| + const string& name) |
| + : Entry(trans), |
| + write_transaction_(trans) { |
| + Init(trans, model_type, parent_id, name); |
| + DCHECK(trans->directory()->InsertEntry(trans, kernel_)); |
|
rlarocque
2013/01/11 18:41:14
Actually, this is the root cause of the failures.
|
| +} |
| + |
| MutableEntry::MutableEntry(WriteTransaction* trans, CreateNewUpdateItem, |
| const Id& id) |
| : Entry(trans), write_transaction_(trans) { |