Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: components/sync_bookmarks/bookmark_model_associator.h

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 18 matching lines...) Expand all
29 class GURL; 29 class GURL;
30 30
31 namespace bookmarks { 31 namespace bookmarks {
32 class BookmarkModel; 32 class BookmarkModel;
33 class BookmarkNode; 33 class BookmarkNode;
34 } 34 }
35 35
36 namespace syncer { 36 namespace syncer {
37 class BaseNode; 37 class BaseNode;
38 class BaseTransaction; 38 class BaseTransaction;
39 struct UserShare;
40 class WriteTransaction;
41 }
42
43 namespace sync_driver {
39 class SyncClient; 44 class SyncClient;
40 class WriteTransaction;
41 struct UserShare;
42 } 45 }
43 46
44 namespace sync_bookmarks { 47 namespace sync_bookmarks {
45 48
46 // Contains all model association related logic: 49 // Contains all model association related logic:
47 // * Algorithm to associate bookmark model and sync model. 50 // * Algorithm to associate bookmark model and sync model.
48 // * Methods to get a bookmark node for a given sync node and vice versa. 51 // * Methods to get a bookmark node for a given sync node and vice versa.
49 // * Persisting model associations and loading them back. 52 // * Persisting model associations and loading them back.
50 class BookmarkModelAssociator 53 class BookmarkModelAssociator
51 : public syncer::PerDataTypeAssociatorInterface<bookmarks::BookmarkNode, 54 : public sync_driver::
52 int64_t> { 55 PerDataTypeAssociatorInterface<bookmarks::BookmarkNode, int64_t> {
53 public: 56 public:
54 static syncer::ModelType model_type() { return syncer::BOOKMARKS; } 57 static syncer::ModelType model_type() { return syncer::BOOKMARKS; }
55 // |expect_mobile_bookmarks_folder| controls whether or not we 58 // |expect_mobile_bookmarks_folder| controls whether or not we
56 // expect the mobile bookmarks permanent folder to be created. 59 // expect the mobile bookmarks permanent folder to be created.
57 // Should be set to true only by mobile clients. 60 // Should be set to true only by mobile clients.
58 BookmarkModelAssociator( 61 BookmarkModelAssociator(
59 bookmarks::BookmarkModel* bookmark_model, 62 bookmarks::BookmarkModel* bookmark_model,
60 syncer::SyncClient* sync_client, 63 sync_driver::SyncClient* sync_client,
61 syncer::UserShare* user_share, 64 syncer::UserShare* user_share,
62 std::unique_ptr<syncer::DataTypeErrorHandler> unrecoverable_error_handler, 65 std::unique_ptr<syncer::DataTypeErrorHandler> unrecoverable_error_handler,
63 bool expect_mobile_bookmarks_folder); 66 bool expect_mobile_bookmarks_folder);
64 ~BookmarkModelAssociator() override; 67 ~BookmarkModelAssociator() override;
65 68
66 // AssociatorInterface implementation. 69 // AssociatorInterface implementation.
67 // 70 //
68 // AssociateModels iterates through both the sync and the browser 71 // AssociateModels iterates through both the sync and the browser
69 // 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
70 // finds, it will call AssociateSyncID. For any unmatched items, 73 // finds, it will call AssociateSyncID. For any unmatched items,
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 int RemoveSyncNodeHierarchy(syncer::WriteTransaction* trans, int64_t sync_id); 286 int RemoveSyncNodeHierarchy(syncer::WriteTransaction* trans, int64_t sync_id);
284 287
285 // Check whether bookmark model and sync model are synced by comparing 288 // Check whether bookmark model and sync model are synced by comparing
286 // their transaction versions. 289 // their transaction versions.
287 // Returns a PERSISTENCE_ERROR if a transaction mismatch was detected where 290 // Returns a PERSISTENCE_ERROR if a transaction mismatch was detected where
288 // the native model has a newer transaction verison. 291 // the native model has a newer transaction verison.
289 syncer::SyncError CheckModelSyncState(Context* context) const; 292 syncer::SyncError CheckModelSyncState(Context* context) const;
290 293
291 base::ThreadChecker thread_checker_; 294 base::ThreadChecker thread_checker_;
292 bookmarks::BookmarkModel* bookmark_model_; 295 bookmarks::BookmarkModel* bookmark_model_;
293 syncer::SyncClient* sync_client_; 296 sync_driver::SyncClient* sync_client_;
294 syncer::UserShare* user_share_; 297 syncer::UserShare* user_share_;
295 std::unique_ptr<syncer::DataTypeErrorHandler> unrecoverable_error_handler_; 298 std::unique_ptr<syncer::DataTypeErrorHandler> unrecoverable_error_handler_;
296 const bool expect_mobile_bookmarks_folder_; 299 const bool expect_mobile_bookmarks_folder_;
297 BookmarkIdToSyncIdMap id_map_; 300 BookmarkIdToSyncIdMap id_map_;
298 SyncIdToBookmarkNodeMap id_map_inverse_; 301 SyncIdToBookmarkNodeMap id_map_inverse_;
299 // Stores sync ids for dirty associations. 302 // Stores sync ids for dirty associations.
300 DirtyAssociationsSyncIds dirty_associations_sync_ids_; 303 DirtyAssociationsSyncIds dirty_associations_sync_ids_;
301 304
302 // Used to post PersistAssociation tasks to the current message loop and 305 // Used to post PersistAssociation tasks to the current message loop and
303 // guarantees no invocations can occur if |this| has been deleted. (This 306 // guarantees no invocations can occur if |this| has been deleted. (This
304 // allows this class to be non-refcounted). 307 // allows this class to be non-refcounted).
305 base::WeakPtrFactory<BookmarkModelAssociator> weak_factory_; 308 base::WeakPtrFactory<BookmarkModelAssociator> weak_factory_;
306 309
307 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); 310 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator);
308 }; 311 };
309 312
310 } // namespace sync_bookmarks 313 } // namespace sync_bookmarks
311 314
312 #endif // COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_ASSOCIATOR_H_ 315 #endif // COMPONENTS_SYNC_BOOKMARKS_BOOKMARK_MODEL_ASSOCIATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698