| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 // AssociatorInterface implementation. | 52 // AssociatorInterface implementation. |
| 53 // | 53 // |
| 54 // AssociateModels iterates through both the sync and the browser | 54 // AssociateModels iterates through both the sync and the browser |
| 55 // bookmark model, looking for matched pairs of items. For any pairs it | 55 // bookmark model, looking for matched pairs of items. For any pairs it |
| 56 // finds, it will call AssociateSyncID. For any unmatched items, | 56 // finds, it will call AssociateSyncID. For any unmatched items, |
| 57 // MergeAndAssociateModels will try to repair the match, e.g. by adding a new | 57 // MergeAndAssociateModels will try to repair the match, e.g. by adding a new |
| 58 // node. After successful completion, the models should be identical and | 58 // node. After successful completion, the models should be identical and |
| 59 // corresponding. Returns true on success. On failure of this step, we | 59 // corresponding. Returns true on success. On failure of this step, we |
| 60 // should abort the sync operation and report an error to the user. | 60 // should abort the sync operation and report an error to the user. |
| 61 virtual SyncError AssociateModels() OVERRIDE; | 61 virtual csync::SyncError AssociateModels() OVERRIDE; |
| 62 | 62 |
| 63 virtual SyncError DisassociateModels() OVERRIDE; | 63 virtual csync::SyncError DisassociateModels() OVERRIDE; |
| 64 | 64 |
| 65 // The has_nodes out param is true if the sync model has nodes other | 65 // The has_nodes out param is true if the sync model has nodes other |
| 66 // than the permanent tagged nodes. | 66 // than the permanent tagged nodes. |
| 67 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) OVERRIDE; | 67 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) OVERRIDE; |
| 68 | 68 |
| 69 // Returns sync id for the given bookmark node id. | 69 // Returns sync id for the given bookmark node id. |
| 70 // Returns csync::kInvalidId if the sync node is not found for the given | 70 // Returns csync::kInvalidId if the sync node is not found for the given |
| 71 // bookmark node id. | 71 // bookmark node id. |
| 72 virtual int64 GetSyncIdFromChromeId(const int64& node_id) OVERRIDE; | 72 virtual int64 GetSyncIdFromChromeId(const int64& node_id) OVERRIDE; |
| 73 | 73 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // Persists all dirty associations. | 111 // Persists all dirty associations. |
| 112 void PersistAssociations(); | 112 void PersistAssociations(); |
| 113 | 113 |
| 114 // Loads the persisted associations into in-memory maps. | 114 // Loads the persisted associations into in-memory maps. |
| 115 // If the persisted associations are out-of-date due to some reason, returns | 115 // If the persisted associations are out-of-date due to some reason, returns |
| 116 // false; otherwise returns true. | 116 // false; otherwise returns true. |
| 117 bool LoadAssociations(); | 117 bool LoadAssociations(); |
| 118 | 118 |
| 119 // Matches up the bookmark model and the sync model to build model | 119 // Matches up the bookmark model and the sync model to build model |
| 120 // associations. | 120 // associations. |
| 121 SyncError BuildAssociations(); | 121 csync::SyncError BuildAssociations(); |
| 122 | 122 |
| 123 // Associate a top-level node of the bookmark model with a permanent node in | 123 // Associate a top-level node of the bookmark model with a permanent node in |
| 124 // the sync domain. Such permanent nodes are identified by a tag that is | 124 // the sync domain. Such permanent nodes are identified by a tag that is |
| 125 // well known to the server and the client, and is unique within a particular | 125 // well known to the server and the client, and is unique within a particular |
| 126 // user's share. For example, "other_bookmarks" is the tag for the Other | 126 // user's share. For example, "other_bookmarks" is the tag for the Other |
| 127 // Bookmarks folder. The sync nodes are server-created. | 127 // Bookmarks folder. The sync nodes are server-created. |
| 128 SyncError AssociateTaggedPermanentNode( | 128 csync::SyncError AssociateTaggedPermanentNode( |
| 129 const BookmarkNode* permanent_node, | 129 const BookmarkNode* permanent_node, |
| 130 const std::string& tag) WARN_UNUSED_RESULT; | 130 const std::string& tag) WARN_UNUSED_RESULT; |
| 131 | 131 |
| 132 // Compare the properties of a pair of nodes from either domain. | 132 // Compare the properties of a pair of nodes from either domain. |
| 133 bool NodesMatch(const BookmarkNode* bookmark, | 133 bool NodesMatch(const BookmarkNode* bookmark, |
| 134 const csync::BaseNode* sync_node) const; | 134 const csync::BaseNode* sync_node) const; |
| 135 | 135 |
| 136 BookmarkModel* bookmark_model_; | 136 BookmarkModel* bookmark_model_; |
| 137 csync::UserShare* user_share_; | 137 csync::UserShare* user_share_; |
| 138 DataTypeErrorHandler* unrecoverable_error_handler_; | 138 DataTypeErrorHandler* unrecoverable_error_handler_; |
| 139 const bool expect_mobile_bookmarks_folder_; | 139 const bool expect_mobile_bookmarks_folder_; |
| 140 BookmarkIdToSyncIdMap id_map_; | 140 BookmarkIdToSyncIdMap id_map_; |
| 141 SyncIdToBookmarkNodeMap id_map_inverse_; | 141 SyncIdToBookmarkNodeMap id_map_inverse_; |
| 142 // Stores sync ids for dirty associations. | 142 // Stores sync ids for dirty associations. |
| 143 DirtyAssociationsSyncIds dirty_associations_sync_ids_; | 143 DirtyAssociationsSyncIds dirty_associations_sync_ids_; |
| 144 | 144 |
| 145 // Used to post PersistAssociation tasks to the current message loop and | 145 // Used to post PersistAssociation tasks to the current message loop and |
| 146 // guarantees no invocations can occur if |this| has been deleted. (This | 146 // guarantees no invocations can occur if |this| has been deleted. (This |
| 147 // allows this class to be non-refcounted). | 147 // allows this class to be non-refcounted). |
| 148 base::WeakPtrFactory<BookmarkModelAssociator> weak_factory_; | 148 base::WeakPtrFactory<BookmarkModelAssociator> weak_factory_; |
| 149 | 149 |
| 150 int number_of_new_sync_nodes_created_at_association_; | 150 int number_of_new_sync_nodes_created_at_association_; |
| 151 | 151 |
| 152 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); | 152 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 } // namespace browser_sync | 155 } // namespace browser_sync |
| 156 | 156 |
| 157 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ | 157 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ |
| OLD | NEW |