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 16 matching lines...) Expand all Loading... |
27 struct UserShare; | 27 struct UserShare; |
28 } | 28 } |
29 | 29 |
30 namespace browser_sync { | 30 namespace browser_sync { |
31 | 31 |
32 // Contains all model association related logic: | 32 // Contains all model association related logic: |
33 // * Algorithm to associate bookmark model and sync model. | 33 // * Algorithm to associate bookmark model and sync model. |
34 // * Methods to get a bookmark node for a given sync node and vice versa. | 34 // * Methods to get a bookmark node for a given sync node and vice versa. |
35 // * Persisting model associations and loading them back. | 35 // * Persisting model associations and loading them back. |
36 class BookmarkModelAssociator | 36 class BookmarkModelAssociator |
37 : public PerDataTypeAssociatorInterface<BookmarkNode, int64> { | 37 : public sync_driver::PerDataTypeAssociatorInterface<BookmarkNode, int64> { |
38 public: | 38 public: |
39 static syncer::ModelType model_type() { return syncer::BOOKMARKS; } | 39 static syncer::ModelType model_type() { return syncer::BOOKMARKS; } |
40 // |expect_mobile_bookmarks_folder| controls whether or not we | 40 // |expect_mobile_bookmarks_folder| controls whether or not we |
41 // expect the mobile bookmarks permanent folder to be created. | 41 // expect the mobile bookmarks permanent folder to be created. |
42 // Should be set to true only by mobile clients. | 42 // Should be set to true only by mobile clients. |
43 BookmarkModelAssociator( | 43 BookmarkModelAssociator( |
44 BookmarkModel* bookmark_model, | 44 BookmarkModel* bookmark_model, |
45 Profile* profile_, | 45 Profile* profile_, |
46 syncer::UserShare* user_share, | 46 syncer::UserShare* user_share, |
47 DataTypeErrorHandler* unrecoverable_error_handler, | 47 sync_driver::DataTypeErrorHandler* unrecoverable_error_handler, |
48 bool expect_mobile_bookmarks_folder); | 48 bool expect_mobile_bookmarks_folder); |
49 virtual ~BookmarkModelAssociator(); | 49 virtual ~BookmarkModelAssociator(); |
50 | 50 |
51 // Updates the visibility of the permanents node in the BookmarkModel. | 51 // Updates the visibility of the permanents node in the BookmarkModel. |
52 void UpdatePermanentNodeVisibility(); | 52 void UpdatePermanentNodeVisibility(); |
53 | 53 |
54 // AssociatorInterface implementation. | 54 // AssociatorInterface implementation. |
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 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // their transaction versions. | 143 // their transaction versions. |
144 // Returns a PERSISTENCE_ERROR if a transaction mismatch was detected where | 144 // Returns a PERSISTENCE_ERROR if a transaction mismatch was detected where |
145 // the native model has a newer transaction verison. | 145 // the native model has a newer transaction verison. |
146 syncer::SyncError CheckModelSyncState( | 146 syncer::SyncError CheckModelSyncState( |
147 syncer::SyncMergeResult* local_merge_result, | 147 syncer::SyncMergeResult* local_merge_result, |
148 syncer::SyncMergeResult* syncer_merge_result) const; | 148 syncer::SyncMergeResult* syncer_merge_result) const; |
149 | 149 |
150 BookmarkModel* bookmark_model_; | 150 BookmarkModel* bookmark_model_; |
151 Profile* profile_; | 151 Profile* profile_; |
152 syncer::UserShare* user_share_; | 152 syncer::UserShare* user_share_; |
153 DataTypeErrorHandler* unrecoverable_error_handler_; | 153 sync_driver::DataTypeErrorHandler* unrecoverable_error_handler_; |
154 const bool expect_mobile_bookmarks_folder_; | 154 const bool expect_mobile_bookmarks_folder_; |
155 BookmarkIdToSyncIdMap id_map_; | 155 BookmarkIdToSyncIdMap id_map_; |
156 SyncIdToBookmarkNodeMap id_map_inverse_; | 156 SyncIdToBookmarkNodeMap id_map_inverse_; |
157 // Stores sync ids for dirty associations. | 157 // Stores sync ids for dirty associations. |
158 DirtyAssociationsSyncIds dirty_associations_sync_ids_; | 158 DirtyAssociationsSyncIds dirty_associations_sync_ids_; |
159 | 159 |
160 // Used to post PersistAssociation tasks to the current message loop and | 160 // Used to post PersistAssociation tasks to the current message loop and |
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 |