| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/sync/syncable/mutable_entry.h" | 5 #include "components/sync/syncable/mutable_entry.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "components/sync/base/hash_util.h" |
| 9 #include "components/sync/base/unique_position.h" | 10 #include "components/sync/base/unique_position.h" |
| 10 #include "components/sync/syncable/directory.h" | 11 #include "components/sync/syncable/directory.h" |
| 11 #include "components/sync/syncable/scoped_kernel_lock.h" | 12 #include "components/sync/syncable/scoped_kernel_lock.h" |
| 12 #include "components/sync/syncable/scoped_parent_child_index_updater.h" | 13 #include "components/sync/syncable/scoped_parent_child_index_updater.h" |
| 13 #include "components/sync/syncable/syncable_changes_version.h" | 14 #include "components/sync/syncable/syncable_changes_version.h" |
| 14 #include "components/sync/syncable/syncable_util.h" | |
| 15 #include "components/sync/syncable/syncable_write_transaction.h" | 15 #include "components/sync/syncable/syncable_write_transaction.h" |
| 16 | 16 |
| 17 using std::string; | 17 using std::string; |
| 18 | 18 |
| 19 namespace syncer { | 19 namespace syncer { |
| 20 namespace syncable { | 20 namespace syncable { |
| 21 | 21 |
| 22 void MutableEntry::Init(WriteTransaction* trans, | 22 void MutableEntry::Init(WriteTransaction* trans, |
| 23 ModelType model_type, | 23 ModelType model_type, |
| 24 const Id& parent_id, | 24 const Id& parent_id, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 MutableEntry::MutableEntry(WriteTransaction* trans, | 74 MutableEntry::MutableEntry(WriteTransaction* trans, |
| 75 Create, | 75 Create, |
| 76 ModelType model_type, | 76 ModelType model_type, |
| 77 const Id& parent_id, | 77 const Id& parent_id, |
| 78 const string& name) | 78 const string& name) |
| 79 : ModelNeutralMutableEntry(trans), write_transaction_(trans) { | 79 : ModelNeutralMutableEntry(trans), write_transaction_(trans) { |
| 80 Init(trans, model_type, parent_id, name); | 80 Init(trans, model_type, parent_id, name); |
| 81 // We need to have a valid position ready before we can index the item. | 81 // We need to have a valid position ready before we can index the item. |
| 82 if (model_type == BOOKMARKS) { | 82 if (model_type == BOOKMARKS) { |
| 83 // Base the tag off of our cache-guid and local "c-" style ID. | 83 // Base the tag off of our cache-guid and local "c-" style ID. |
| 84 std::string unique_tag = syncable::GenerateSyncableBookmarkHash( | 84 std::string unique_tag = GenerateSyncableBookmarkHash( |
| 85 trans->directory()->cache_guid(), GetId().GetServerId()); | 85 trans->directory()->cache_guid(), GetId().GetServerId()); |
| 86 kernel_->put(UNIQUE_BOOKMARK_TAG, unique_tag); | 86 kernel_->put(UNIQUE_BOOKMARK_TAG, unique_tag); |
| 87 kernel_->put(UNIQUE_POSITION, UniquePosition::InitialPosition(unique_tag)); | 87 kernel_->put(UNIQUE_POSITION, UniquePosition::InitialPosition(unique_tag)); |
| 88 } else { | 88 } else { |
| 89 DCHECK(!ShouldMaintainPosition()); | 89 DCHECK(!ShouldMaintainPosition()); |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool result = trans->directory()->InsertEntry(trans, kernel_); | 92 bool result = trans->directory()->InsertEntry(trans, kernel_); |
| 93 DCHECK(result); | 93 DCHECK(result); |
| 94 } | 94 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; | 309 DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; |
| 310 if (!(e->PutIsUnsynced(true))) | 310 if (!(e->PutIsUnsynced(true))) |
| 311 return false; | 311 return false; |
| 312 if (e->GetSyncing()) | 312 if (e->GetSyncing()) |
| 313 e->PutDirtySync(true); | 313 e->PutDirtySync(true); |
| 314 return true; | 314 return true; |
| 315 } | 315 } |
| 316 | 316 |
| 317 } // namespace syncable | 317 } // namespace syncable |
| 318 } // namespace syncer | 318 } // namespace syncer |
| OLD | NEW |