| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sync/internal_api/public/write_node.h" | 5 #include "sync/internal_api/public/write_node.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 // Client tags are immutable and must be paired with the ID. | 367 // Client tags are immutable and must be paired with the ID. |
| 368 // If a server update comes down with an ID and client tag combo, | 368 // If a server update comes down with an ID and client tag combo, |
| 369 // and it already exists, always overwrite it and store only one copy. | 369 // and it already exists, always overwrite it and store only one copy. |
| 370 // We have to undelete entries because we can't disassociate IDs from | 370 // We have to undelete entries because we can't disassociate IDs from |
| 371 // tags and updates. | 371 // tags and updates. |
| 372 | 372 |
| 373 existing_entry->PutNonUniqueName(dummy); | 373 existing_entry->PutNonUniqueName(dummy); |
| 374 existing_entry->PutParentId(parent_id); | 374 existing_entry->PutParentId(parent_id); |
| 375 } // Else just reuse the existing entry. | 375 } // Else just reuse the existing entry. |
| 376 entry_ = existing_entry.release(); | 376 entry_ = existing_entry.release(); |
| 377 if (!DecryptIfNecessary()) |
| 378 return INIT_FAILED_DECRYPT_EXISTING_ENTRY; |
| 377 } else { | 379 } else { |
| 378 entry_ = new syncable::MutableEntry(transaction_->GetWrappedWriteTrans(), | 380 entry_ = new syncable::MutableEntry(transaction_->GetWrappedWriteTrans(), |
| 379 syncable::CREATE, | 381 syncable::CREATE, |
| 380 model_type, parent_id, dummy); | 382 model_type, parent_id, dummy); |
| 381 } | 383 } |
| 382 | 384 |
| 383 if (!entry_->good()) | 385 if (!entry_->good()) |
| 384 return INIT_FAILED_COULD_NOT_CREATE_ENTRY; | 386 return INIT_FAILED_COULD_NOT_CREATE_ENTRY; |
| 385 | 387 |
| 386 // Has no impact if the client tag is already set. | 388 // Has no impact if the client tag is already set. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 syncable::Id predecessor_id = | 469 syncable::Id predecessor_id = |
| 468 predecessor ? predecessor->GetSyncId() : syncable::Id(); | 470 predecessor ? predecessor->GetSyncId() : syncable::Id(); |
| 469 return entry_->PutPredecessor(predecessor_id); | 471 return entry_->PutPredecessor(predecessor_id); |
| 470 } | 472 } |
| 471 | 473 |
| 472 void WriteNode::MarkForSyncing() { | 474 void WriteNode::MarkForSyncing() { |
| 473 syncable::MarkForSyncing(entry_); | 475 syncable::MarkForSyncing(entry_); |
| 474 } | 476 } |
| 475 | 477 |
| 476 } // namespace syncer | 478 } // namespace syncer |
| OLD | NEW |