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_bookmarks/bookmark_model_associator.h" | 5 #include "components/sync_bookmarks/bookmark_model_associator.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // |title|, and |is_folder| flags. | 87 // |title|, and |is_folder| flags. |
88 static bool NodeMatches(const BookmarkNode* bookmark_node, | 88 static bool NodeMatches(const BookmarkNode* bookmark_node, |
89 const GURL& url, | 89 const GURL& url, |
90 const std::string& title, | 90 const std::string& title, |
91 bool is_folder); | 91 bool is_folder); |
92 | 92 |
93 private: | 93 private: |
94 // Maps bookmark node titles to instances, duplicates allowed. | 94 // Maps bookmark node titles to instances, duplicates allowed. |
95 // Titles are converted to the sync internal format before | 95 // Titles are converted to the sync internal format before |
96 // being used as keys for the map. | 96 // being used as keys for the map. |
97 typedef base::hash_multimap<std::string, | 97 using BookmarkNodeMap = base::hash_multimap<std::string, const BookmarkNode*>; |
98 const BookmarkNode*> BookmarkNodeMap; | 98 using BookmarkNodeRange = |
99 typedef std::pair<BookmarkNodeMap::iterator, | 99 std::pair<BookmarkNodeMap::iterator, BookmarkNodeMap::iterator>; |
100 BookmarkNodeMap::iterator> BookmarkNodeRange; | |
101 | 100 |
102 // Converts and truncates bookmark titles in the form sync does internally | 101 // Converts and truncates bookmark titles in the form sync does internally |
103 // to avoid mismatches due to sync munging titles. | 102 // to avoid mismatches due to sync munging titles. |
104 static void ConvertTitleToSyncInternalFormat(const std::string& input, | 103 static void ConvertTitleToSyncInternalFormat(const std::string& input, |
105 std::string* output); | 104 std::string* output); |
106 | 105 |
107 const BookmarkNode* parent_node_; | 106 const BookmarkNode* parent_node_; |
108 BookmarkNodeMap child_nodes_; | 107 BookmarkNodeMap child_nodes_; |
109 | 108 |
110 DISALLOW_COPY_AND_ASSIGN(BookmarkNodeFinder); | 109 DISALLOW_COPY_AND_ASSIGN(BookmarkNodeFinder); |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 this); | 793 this); |
795 } | 794 } |
796 | 795 |
797 struct FolderInfo { | 796 struct FolderInfo { |
798 FolderInfo(const BookmarkNode* f, const BookmarkNode* p, int64_t id) | 797 FolderInfo(const BookmarkNode* f, const BookmarkNode* p, int64_t id) |
799 : folder(f), parent(p), sync_id(id) {} | 798 : folder(f), parent(p), sync_id(id) {} |
800 const BookmarkNode* folder; | 799 const BookmarkNode* folder; |
801 const BookmarkNode* parent; | 800 const BookmarkNode* parent; |
802 int64_t sync_id; | 801 int64_t sync_id; |
803 }; | 802 }; |
804 typedef std::vector<FolderInfo> FolderInfoList; | 803 using FolderInfoList = std::vector<FolderInfo>; |
805 | 804 |
806 void BookmarkModelAssociator::ApplyDeletesFromSyncJournal( | 805 void BookmarkModelAssociator::ApplyDeletesFromSyncJournal( |
807 syncer::BaseTransaction* trans, | 806 syncer::BaseTransaction* trans, |
808 Context* context) { | 807 Context* context) { |
809 syncer::BookmarkDeleteJournalList bk_delete_journals; | 808 syncer::BookmarkDeleteJournalList bk_delete_journals; |
810 syncer::DeleteJournal::GetBookmarkDeleteJournals(trans, &bk_delete_journals); | 809 syncer::DeleteJournal::GetBookmarkDeleteJournals(trans, &bk_delete_journals); |
811 if (bk_delete_journals.empty()) | 810 if (bk_delete_journals.empty()) |
812 return; | 811 return; |
813 | 812 |
814 size_t num_journals_unmatched = bk_delete_journals.size(); | 813 size_t num_journals_unmatched = bk_delete_journals.size(); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 syncer::BOOKMARKS); | 1003 syncer::BOOKMARKS); |
1005 } else { | 1004 } else { |
1006 context->set_native_model_sync_state(BEHIND); | 1005 context->set_native_model_sync_state(BEHIND); |
1007 } | 1006 } |
1008 } | 1007 } |
1009 } | 1008 } |
1010 return syncer::SyncError(); | 1009 return syncer::SyncError(); |
1011 } | 1010 } |
1012 | 1011 |
1013 } // namespace sync_bookmarks | 1012 } // namespace sync_bookmarks |
OLD | NEW |