| 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 "chrome/browser/sync/glue/bookmark_model_associator.h" | 5 #include "chrome/browser/sync/glue/bookmark_model_associator.h" |
| 6 | 6 |
| 7 #include <stack> | 7 #include <stack> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 BookmarkNodeFinder::NodeMatches( | 698 BookmarkNodeFinder::NodeMatches( |
| 699 child, GURL(delete_entry.specifics.bookmark().url()), | 699 child, GURL(delete_entry.specifics.bookmark().url()), |
| 700 delete_entry.specifics.bookmark().title(), | 700 delete_entry.specifics.bookmark().title(), |
| 701 delete_entry.is_folder)) { | 701 delete_entry.is_folder)) { |
| 702 if (child->is_folder()) { | 702 if (child->is_folder()) { |
| 703 // Remember matched folder without removing and delete only empty | 703 // Remember matched folder without removing and delete only empty |
| 704 // ones later. | 704 // ones later. |
| 705 folders_matched.push_back( | 705 folders_matched.push_back( |
| 706 FolderInfo(child, parent, delete_entry.id)); | 706 FolderInfo(child, parent, delete_entry.id)); |
| 707 } else { | 707 } else { |
| 708 bookmark_model_->Remove(parent, child_index); | 708 bookmark_model_->Remove(child); |
| 709 ++num_bookmark_deleted; | 709 ++num_bookmark_deleted; |
| 710 } | 710 } |
| 711 // Move unmatched journal here and decrement counter. | 711 // Move unmatched journal here and decrement counter. |
| 712 bk_delete_journals[journal_index] = | 712 bk_delete_journals[journal_index] = |
| 713 bk_delete_journals[--num_journals_unmatched]; | 713 bk_delete_journals[--num_journals_unmatched]; |
| 714 break; | 714 break; |
| 715 } | 715 } |
| 716 } | 716 } |
| 717 } | 717 } |
| 718 } | 718 } |
| 719 | 719 |
| 720 // Ids of sync nodes not found in bookmark model, meaning the deletions are | 720 // Ids of sync nodes not found in bookmark model, meaning the deletions are |
| 721 // persisted and correponding delete journals can be dropped. | 721 // persisted and correponding delete journals can be dropped. |
| 722 std::set<int64> journals_to_purge; | 722 std::set<int64> journals_to_purge; |
| 723 | 723 |
| 724 // Remove empty folders from bottom to top. | 724 // Remove empty folders from bottom to top. |
| 725 for (FolderInfoList::reverse_iterator it = folders_matched.rbegin(); | 725 for (FolderInfoList::reverse_iterator it = folders_matched.rbegin(); |
| 726 it != folders_matched.rend(); ++it) { | 726 it != folders_matched.rend(); ++it) { |
| 727 if (it->folder->child_count() == 0) { | 727 if (it->folder->child_count() == 0) { |
| 728 bookmark_model_->Remove(it->parent, it->parent->GetIndexOf(it->folder)); | 728 bookmark_model_->Remove(it->folder); |
| 729 ++num_bookmark_deleted; | 729 ++num_bookmark_deleted; |
| 730 } else { | 730 } else { |
| 731 // Keep non-empty folder and remove its journal so that it won't match | 731 // Keep non-empty folder and remove its journal so that it won't match |
| 732 // again in the future. | 732 // again in the future. |
| 733 journals_to_purge.insert(it->sync_id); | 733 journals_to_purge.insert(it->sync_id); |
| 734 } | 734 } |
| 735 } | 735 } |
| 736 | 736 |
| 737 // Purge unmatched journals. | 737 // Purge unmatched journals. |
| 738 for (size_t i = 0; i < num_journals_unmatched; ++i) | 738 for (size_t i = 0; i < num_journals_unmatched; ++i) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 syncer::SyncError::PERSISTENCE_ERROR, | 838 syncer::SyncError::PERSISTENCE_ERROR, |
| 839 message, | 839 message, |
| 840 syncer::BOOKMARKS); | 840 syncer::BOOKMARKS); |
| 841 } | 841 } |
| 842 } | 842 } |
| 843 } | 843 } |
| 844 return syncer::SyncError(); | 844 return syncer::SyncError(); |
| 845 } | 845 } |
| 846 | 846 |
| 847 } // namespace browser_sync | 847 } // namespace browser_sync |
| OLD | NEW |