Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 // Associates the given bookmark node with the given sync id. | 76 // Associates the given bookmark node with the given sync id. |
| 77 virtual void Associate(const BookmarkNode* node, int64 sync_id); | 77 virtual void Associate(const BookmarkNode* node, int64 sync_id); |
| 78 // Remove the association that corresponds to the given sync id. | 78 // Remove the association that corresponds to the given sync id. |
| 79 virtual void Disassociate(int64 sync_id); | 79 virtual void Disassociate(int64 sync_id); |
| 80 | 80 |
| 81 virtual void AbortAssociation() { | 81 virtual void AbortAssociation() { |
| 82 // No implementation needed, this associator runs on the main | 82 // No implementation needed, this associator runs on the main |
| 83 // thread. | 83 // thread. |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Returns sync service instance. | |
| 87 ProfileSyncService* sync_service() { return sync_service_; } | |
| 88 | |
| 89 protected: | 86 protected: |
| 90 // Stores the id of the node with the given tag in |sync_id|. | 87 // Stores the id of the node with the given tag in |sync_id|. |
| 91 // Returns of that node was found successfully. | 88 // Returns of that node was found successfully. |
| 92 // Tests override this. | 89 // Tests override this. |
| 93 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id); | 90 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id); |
| 94 | 91 |
| 92 ProfileSyncService* sync_service_; | |
|
tim (not reviewing)
2011/01/21 18:17:00
I think you should instead move the sync_service()
akalin
2011/01/21 21:21:09
Done.
| |
| 93 | |
| 95 private: | 94 private: |
| 96 typedef std::map<int64, int64> BookmarkIdToSyncIdMap; | 95 typedef std::map<int64, int64> BookmarkIdToSyncIdMap; |
| 97 typedef std::map<int64, const BookmarkNode*> SyncIdToBookmarkNodeMap; | 96 typedef std::map<int64, const BookmarkNode*> SyncIdToBookmarkNodeMap; |
| 98 typedef std::set<int64> DirtyAssociationsSyncIds; | 97 typedef std::set<int64> DirtyAssociationsSyncIds; |
| 99 | 98 |
| 100 // Posts a task to persist dirty associations. | 99 // Posts a task to persist dirty associations. |
| 101 void PostPersistAssociationsTask(); | 100 void PostPersistAssociationsTask(); |
| 102 // Persists all dirty associations. | 101 // Persists all dirty associations. |
| 103 void PersistAssociations(); | 102 void PersistAssociations(); |
| 104 | 103 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 116 // well known to the server and the client, and is unique within a particular | 115 // well known to the server and the client, and is unique within a particular |
| 117 // user's share. For example, "other_bookmarks" is the tag for the Other | 116 // user's share. For example, "other_bookmarks" is the tag for the Other |
| 118 // Bookmarks folder. The sync nodes are server-created. | 117 // Bookmarks folder. The sync nodes are server-created. |
| 119 bool AssociateTaggedPermanentNode(const BookmarkNode* permanent_node, | 118 bool AssociateTaggedPermanentNode(const BookmarkNode* permanent_node, |
| 120 const std::string& tag); | 119 const std::string& tag); |
| 121 | 120 |
| 122 // Compare the properties of a pair of nodes from either domain. | 121 // Compare the properties of a pair of nodes from either domain. |
| 123 bool NodesMatch(const BookmarkNode* bookmark, | 122 bool NodesMatch(const BookmarkNode* bookmark, |
| 124 const sync_api::BaseNode* sync_node) const; | 123 const sync_api::BaseNode* sync_node) const; |
| 125 | 124 |
| 126 ProfileSyncService* sync_service_; | |
| 127 UnrecoverableErrorHandler* persist_ids_error_handler_; | 125 UnrecoverableErrorHandler* persist_ids_error_handler_; |
| 128 BookmarkIdToSyncIdMap id_map_; | 126 BookmarkIdToSyncIdMap id_map_; |
| 129 SyncIdToBookmarkNodeMap id_map_inverse_; | 127 SyncIdToBookmarkNodeMap id_map_inverse_; |
| 130 // Stores sync ids for dirty associations. | 128 // Stores sync ids for dirty associations. |
| 131 DirtyAssociationsSyncIds dirty_associations_sync_ids_; | 129 DirtyAssociationsSyncIds dirty_associations_sync_ids_; |
| 132 | 130 |
| 133 // Used to post PersistAssociation tasks to the current message loop and | 131 // Used to post PersistAssociation tasks to the current message loop and |
| 134 // guarantees no invocations can occur if |this| has been deleted. (This | 132 // guarantees no invocations can occur if |this| has been deleted. (This |
| 135 // allows this class to be non-refcounted). | 133 // allows this class to be non-refcounted). |
| 136 ScopedRunnableMethodFactory<BookmarkModelAssociator> persist_associations_; | 134 ScopedRunnableMethodFactory<BookmarkModelAssociator> persist_associations_; |
| 137 | 135 |
| 138 int number_of_new_sync_nodes_created_at_association_; | 136 int number_of_new_sync_nodes_created_at_association_; |
| 139 | 137 |
| 140 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); | 138 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); |
| 141 }; | 139 }; |
| 142 | 140 |
| 143 } // namespace browser_sync | 141 } // namespace browser_sync |
| 144 | 142 |
| 145 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ | 143 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ |
| OLD | NEW |