| 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // | 55 // |
| 56 // AssociateModels iterates through both the sync and the browser | 56 // AssociateModels iterates through both the sync and the browser |
| 57 // bookmark model, looking for matched pairs of items. For any pairs it | 57 // bookmark model, looking for matched pairs of items. For any pairs it |
| 58 // finds, it will call AssociateSyncID. For any unmatched items, | 58 // finds, it will call AssociateSyncID. For any unmatched items, |
| 59 // MergeAndAssociateModels will try to repair the match, e.g. by adding a new | 59 // MergeAndAssociateModels will try to repair the match, e.g. by adding a new |
| 60 // node. After successful completion, the models should be identical and | 60 // node. After successful completion, the models should be identical and |
| 61 // corresponding. Returns true on success. On failure of this step, we | 61 // corresponding. Returns true on success. On failure of this step, we |
| 62 // should abort the sync operation and report an error to the user. | 62 // should abort the sync operation and report an error to the user. |
| 63 virtual syncer::SyncError AssociateModels( | 63 virtual syncer::SyncError AssociateModels( |
| 64 syncer::SyncMergeResult* local_merge_result, | 64 syncer::SyncMergeResult* local_merge_result, |
| 65 syncer::SyncMergeResult* syncer_merge_result) OVERRIDE; | 65 syncer::SyncMergeResult* syncer_merge_result) override; |
| 66 | 66 |
| 67 virtual syncer::SyncError DisassociateModels() OVERRIDE; | 67 virtual syncer::SyncError DisassociateModels() override; |
| 68 | 68 |
| 69 // The has_nodes out param is true if the sync model has nodes other | 69 // The has_nodes out param is true if the sync model has nodes other |
| 70 // than the permanent tagged nodes. | 70 // than the permanent tagged nodes. |
| 71 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) OVERRIDE; | 71 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) override; |
| 72 | 72 |
| 73 // Returns sync id for the given bookmark node id. | 73 // Returns sync id for the given bookmark node id. |
| 74 // Returns syncer::kInvalidId if the sync node is not found for the given | 74 // Returns syncer::kInvalidId if the sync node is not found for the given |
| 75 // bookmark node id. | 75 // bookmark node id. |
| 76 virtual int64 GetSyncIdFromChromeId(const int64& node_id) OVERRIDE; | 76 virtual int64 GetSyncIdFromChromeId(const int64& node_id) override; |
| 77 | 77 |
| 78 // Returns the bookmark node for the given sync id. | 78 // Returns the bookmark node for the given sync id. |
| 79 // Returns NULL if no bookmark node is found for the given sync id. | 79 // Returns NULL if no bookmark node is found for the given sync id. |
| 80 virtual const BookmarkNode* GetChromeNodeFromSyncId(int64 sync_id) OVERRIDE; | 80 virtual const BookmarkNode* GetChromeNodeFromSyncId(int64 sync_id) override; |
| 81 | 81 |
| 82 // Initializes the given sync node from the given bookmark node id. | 82 // Initializes the given sync node from the given bookmark node id. |
| 83 // Returns false if no sync node was found for the given bookmark node id or | 83 // Returns false if no sync node was found for the given bookmark node id or |
| 84 // if the initialization of sync node fails. | 84 // if the initialization of sync node fails. |
| 85 virtual bool InitSyncNodeFromChromeId( | 85 virtual bool InitSyncNodeFromChromeId( |
| 86 const int64& node_id, | 86 const int64& node_id, |
| 87 syncer::BaseNode* sync_node) OVERRIDE; | 87 syncer::BaseNode* sync_node) override; |
| 88 | 88 |
| 89 // Associates the given bookmark node with the given sync id. | 89 // Associates the given bookmark node with the given sync id. |
| 90 virtual void Associate(const BookmarkNode* node, int64 sync_id) OVERRIDE; | 90 virtual void Associate(const BookmarkNode* node, int64 sync_id) override; |
| 91 // Remove the association that corresponds to the given sync id. | 91 // Remove the association that corresponds to the given sync id. |
| 92 virtual void Disassociate(int64 sync_id) OVERRIDE; | 92 virtual void Disassociate(int64 sync_id) override; |
| 93 | 93 |
| 94 virtual void AbortAssociation() OVERRIDE { | 94 virtual void AbortAssociation() override { |
| 95 // No implementation needed, this associator runs on the main | 95 // No implementation needed, this associator runs on the main |
| 96 // thread. | 96 // thread. |
| 97 } | 97 } |
| 98 | 98 |
| 99 // See ModelAssociator interface. | 99 // See ModelAssociator interface. |
| 100 virtual bool CryptoReadyIfNecessary() OVERRIDE; | 100 virtual bool CryptoReadyIfNecessary() override; |
| 101 | 101 |
| 102 protected: | 102 protected: |
| 103 // Stores the id of the node with the given tag in |sync_id|. | 103 // Stores the id of the node with the given tag in |sync_id|. |
| 104 // Returns of that node was found successfully. | 104 // Returns of that node was found successfully. |
| 105 // Tests override this. | 105 // Tests override this. |
| 106 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id); | 106 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id); |
| 107 | 107 |
| 108 private: | 108 private: |
| 109 typedef std::map<int64, int64> BookmarkIdToSyncIdMap; | 109 typedef std::map<int64, int64> BookmarkIdToSyncIdMap; |
| 110 typedef std::map<int64, const BookmarkNode*> SyncIdToBookmarkNodeMap; | 110 typedef std::map<int64, const BookmarkNode*> SyncIdToBookmarkNodeMap; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // guarantees no invocations can occur if |this| has been deleted. (This | 161 // guarantees no invocations can occur if |this| has been deleted. (This |
| 162 // allows this class to be non-refcounted). | 162 // allows this class to be non-refcounted). |
| 163 base::WeakPtrFactory<BookmarkModelAssociator> weak_factory_; | 163 base::WeakPtrFactory<BookmarkModelAssociator> weak_factory_; |
| 164 | 164 |
| 165 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); | 165 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 } // namespace browser_sync | 168 } // namespace browser_sync |
| 169 | 169 |
| 170 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ | 170 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ |
| OLD | NEW |