Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 // * Algorithm to associate bookmark model and sync model. | 32 // * Algorithm to associate bookmark model and sync model. |
| 33 // * Methods to get a bookmark node for a given sync node and vice versa. | 33 // * Methods to get a bookmark node for a given sync node and vice versa. |
| 34 // * Persisting model associations and loading them back. | 34 // * Persisting model associations and loading them back. |
| 35 class BookmarkModelAssociator | 35 class BookmarkModelAssociator |
| 36 : public PerDataTypeAssociatorInterface<BookmarkNode, int64> { | 36 : public PerDataTypeAssociatorInterface<BookmarkNode, int64> { |
| 37 public: | 37 public: |
| 38 static syncable::ModelType model_type() { return syncable::BOOKMARKS; } | 38 static syncable::ModelType model_type() { return syncable::BOOKMARKS; } |
| 39 BookmarkModelAssociator( | 39 BookmarkModelAssociator( |
| 40 BookmarkModel* bookmark_model, | 40 BookmarkModel* bookmark_model, |
| 41 sync_api::UserShare* user_share, | 41 sync_api::UserShare* user_share, |
| 42 DataTypeErrorHandler* unrecoverable_error_handler); | 42 DataTypeErrorHandler* unrecoverable_error_handler, |
| 43 bool create_mobile_bookmarks_folder); | |
|
Nicolas Zea
2012/02/27 20:03:12
Comment about this param
akalin
2012/02/27 22:04:18
Done.
| |
| 43 virtual ~BookmarkModelAssociator(); | 44 virtual ~BookmarkModelAssociator(); |
| 44 | 45 |
| 45 // Updates the visibility of the permanents node in the BookmarkModel. | 46 // Updates the visibility of the permanents node in the BookmarkModel. |
| 46 void UpdatePermanentNodeVisibility(); | 47 void UpdatePermanentNodeVisibility(); |
| 47 | 48 |
| 48 // AssociatorInterface implementation. | 49 // AssociatorInterface implementation. |
| 49 // | 50 // |
| 50 // AssociateModels iterates through both the sync and the browser | 51 // AssociateModels iterates through both the sync and the browser |
| 51 // bookmark model, looking for matched pairs of items. For any pairs it | 52 // bookmark model, looking for matched pairs of items. For any pairs it |
| 52 // finds, it will call AssociateSyncID. For any unmatched items, | 53 // finds, it will call AssociateSyncID. For any unmatched items, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 bool AssociateTaggedPermanentNode(const BookmarkNode* permanent_node, | 124 bool AssociateTaggedPermanentNode(const BookmarkNode* permanent_node, |
| 124 const std::string& tag) WARN_UNUSED_RESULT; | 125 const std::string& tag) WARN_UNUSED_RESULT; |
| 125 | 126 |
| 126 // Compare the properties of a pair of nodes from either domain. | 127 // Compare the properties of a pair of nodes from either domain. |
| 127 bool NodesMatch(const BookmarkNode* bookmark, | 128 bool NodesMatch(const BookmarkNode* bookmark, |
| 128 const sync_api::BaseNode* sync_node) const; | 129 const sync_api::BaseNode* sync_node) const; |
| 129 | 130 |
| 130 BookmarkModel* bookmark_model_; | 131 BookmarkModel* bookmark_model_; |
| 131 sync_api::UserShare* user_share_; | 132 sync_api::UserShare* user_share_; |
| 132 DataTypeErrorHandler* unrecoverable_error_handler_; | 133 DataTypeErrorHandler* unrecoverable_error_handler_; |
| 134 const bool create_mobile_bookmarks_folder_; | |
| 133 BookmarkIdToSyncIdMap id_map_; | 135 BookmarkIdToSyncIdMap id_map_; |
| 134 SyncIdToBookmarkNodeMap id_map_inverse_; | 136 SyncIdToBookmarkNodeMap id_map_inverse_; |
| 135 // Stores sync ids for dirty associations. | 137 // Stores sync ids for dirty associations. |
| 136 DirtyAssociationsSyncIds dirty_associations_sync_ids_; | 138 DirtyAssociationsSyncIds dirty_associations_sync_ids_; |
| 137 | 139 |
| 138 // Used to post PersistAssociation tasks to the current message loop and | 140 // Used to post PersistAssociation tasks to the current message loop and |
| 139 // guarantees no invocations can occur if |this| has been deleted. (This | 141 // guarantees no invocations can occur if |this| has been deleted. (This |
| 140 // allows this class to be non-refcounted). | 142 // allows this class to be non-refcounted). |
| 141 base::WeakPtrFactory<BookmarkModelAssociator> weak_factory_; | 143 base::WeakPtrFactory<BookmarkModelAssociator> weak_factory_; |
| 142 | 144 |
| 143 int number_of_new_sync_nodes_created_at_association_; | 145 int number_of_new_sync_nodes_created_at_association_; |
| 144 | 146 |
| 145 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); | 147 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); |
| 146 }; | 148 }; |
| 147 | 149 |
| 148 } // namespace browser_sync | 150 } // namespace browser_sync |
| 149 | 151 |
| 150 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ | 152 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ |
| OLD | NEW |