| 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 COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_ASSOCIATOR_H_ | 5 #ifndef COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_ASSOCIATOR_H_ |
| 6 #define COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_ASSOCIATOR_H_ | 6 #define COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_ASSOCIATOR_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> |
| 12 #include <set> | 13 #include <set> |
| 13 #include <stack> | 14 #include <stack> |
| 14 #include <string> | 15 #include <string> |
| 15 #include <vector> | 16 #include <vector> |
| 16 | 17 |
| 17 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 18 #include "base/containers/hash_tables.h" | 19 #include "base/containers/hash_tables.h" |
| 19 #include "base/hash.h" | 20 #include "base/hash.h" |
| 20 #include "base/macros.h" | 21 #include "base/macros.h" |
| 21 #include "base/memory/weak_ptr.h" | 22 #include "base/memory/weak_ptr.h" |
| 22 #include "base/strings/string16.h" | 23 #include "base/strings/string16.h" |
| 23 #include "base/threading/thread_checker.h" | 24 #include "base/threading/thread_checker.h" |
| 25 #include "components/sync/api/data_type_error_handler.h" |
| 24 #include "components/sync/base/unrecoverable_error_handler.h" | 26 #include "components/sync/base/unrecoverable_error_handler.h" |
| 25 #include "components/sync/core/data_type_error_handler.h" | |
| 26 #include "components/sync/driver/model_associator.h" | 27 #include "components/sync/driver/model_associator.h" |
| 27 | 28 |
| 28 class GURL; | 29 class GURL; |
| 29 | 30 |
| 30 namespace bookmarks { | 31 namespace bookmarks { |
| 31 class BookmarkModel; | 32 class BookmarkModel; |
| 32 class BookmarkNode; | 33 class BookmarkNode; |
| 33 } | 34 } |
| 34 | 35 |
| 35 namespace syncer { | 36 namespace syncer { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 54 PerDataTypeAssociatorInterface<bookmarks::BookmarkNode, int64_t> { | 55 PerDataTypeAssociatorInterface<bookmarks::BookmarkNode, int64_t> { |
| 55 public: | 56 public: |
| 56 static syncer::ModelType model_type() { return syncer::BOOKMARKS; } | 57 static syncer::ModelType model_type() { return syncer::BOOKMARKS; } |
| 57 // |expect_mobile_bookmarks_folder| controls whether or not we | 58 // |expect_mobile_bookmarks_folder| controls whether or not we |
| 58 // expect the mobile bookmarks permanent folder to be created. | 59 // expect the mobile bookmarks permanent folder to be created. |
| 59 // Should be set to true only by mobile clients. | 60 // Should be set to true only by mobile clients. |
| 60 BookmarkModelAssociator( | 61 BookmarkModelAssociator( |
| 61 bookmarks::BookmarkModel* bookmark_model, | 62 bookmarks::BookmarkModel* bookmark_model, |
| 62 sync_driver::SyncClient* sync_client, | 63 sync_driver::SyncClient* sync_client, |
| 63 syncer::UserShare* user_share, | 64 syncer::UserShare* user_share, |
| 64 syncer::DataTypeErrorHandler* unrecoverable_error_handler, | 65 std::unique_ptr<syncer::DataTypeErrorHandler> unrecoverable_error_handler, |
| 65 bool expect_mobile_bookmarks_folder); | 66 bool expect_mobile_bookmarks_folder); |
| 66 ~BookmarkModelAssociator() override; | 67 ~BookmarkModelAssociator() override; |
| 67 | 68 |
| 68 // AssociatorInterface implementation. | 69 // AssociatorInterface implementation. |
| 69 // | 70 // |
| 70 // AssociateModels iterates through both the sync and the browser | 71 // AssociateModels iterates through both the sync and the browser |
| 71 // bookmark model, looking for matched pairs of items. For any pairs it | 72 // bookmark model, looking for matched pairs of items. For any pairs it |
| 72 // finds, it will call AssociateSyncID. For any unmatched items, | 73 // finds, it will call AssociateSyncID. For any unmatched items, |
| 73 // MergeAndAssociateModels will try to repair the match, e.g. by adding a new | 74 // MergeAndAssociateModels will try to repair the match, e.g. by adding a new |
| 74 // node. After successful completion, the models should be identical and | 75 // node. After successful completion, the models should be identical and |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // Check whether bookmark model and sync model are synced by comparing | 288 // Check whether bookmark model and sync model are synced by comparing |
| 288 // their transaction versions. | 289 // their transaction versions. |
| 289 // Returns a PERSISTENCE_ERROR if a transaction mismatch was detected where | 290 // Returns a PERSISTENCE_ERROR if a transaction mismatch was detected where |
| 290 // the native model has a newer transaction verison. | 291 // the native model has a newer transaction verison. |
| 291 syncer::SyncError CheckModelSyncState(Context* context) const; | 292 syncer::SyncError CheckModelSyncState(Context* context) const; |
| 292 | 293 |
| 293 base::ThreadChecker thread_checker_; | 294 base::ThreadChecker thread_checker_; |
| 294 bookmarks::BookmarkModel* bookmark_model_; | 295 bookmarks::BookmarkModel* bookmark_model_; |
| 295 sync_driver::SyncClient* sync_client_; | 296 sync_driver::SyncClient* sync_client_; |
| 296 syncer::UserShare* user_share_; | 297 syncer::UserShare* user_share_; |
| 297 syncer::DataTypeErrorHandler* unrecoverable_error_handler_; | 298 std::unique_ptr<syncer::DataTypeErrorHandler> unrecoverable_error_handler_; |
| 298 const bool expect_mobile_bookmarks_folder_; | 299 const bool expect_mobile_bookmarks_folder_; |
| 299 BookmarkIdToSyncIdMap id_map_; | 300 BookmarkIdToSyncIdMap id_map_; |
| 300 SyncIdToBookmarkNodeMap id_map_inverse_; | 301 SyncIdToBookmarkNodeMap id_map_inverse_; |
| 301 // Stores sync ids for dirty associations. | 302 // Stores sync ids for dirty associations. |
| 302 DirtyAssociationsSyncIds dirty_associations_sync_ids_; | 303 DirtyAssociationsSyncIds dirty_associations_sync_ids_; |
| 303 | 304 |
| 304 // Used to post PersistAssociation tasks to the current message loop and | 305 // Used to post PersistAssociation tasks to the current message loop and |
| 305 // guarantees no invocations can occur if |this| has been deleted. (This | 306 // guarantees no invocations can occur if |this| has been deleted. (This |
| 306 // allows this class to be non-refcounted). | 307 // allows this class to be non-refcounted). |
| 307 base::WeakPtrFactory<BookmarkModelAssociator> weak_factory_; | 308 base::WeakPtrFactory<BookmarkModelAssociator> weak_factory_; |
| 308 | 309 |
| 309 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); | 310 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); |
| 310 }; | 311 }; |
| 311 | 312 |
| 312 } // namespace browser_sync | 313 } // namespace browser_sync |
| 313 | 314 |
| 314 #endif // COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_ASSOCIATOR_H_ | 315 #endif // COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_ASSOCIATOR_H_ |
| OLD | NEW |