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

Side by Side Diff: chrome/browser/sync/glue/bookmark_model_associator.h

Issue 6905044: Refactor preference syncing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the previous fix Created 9 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 16 matching lines...) Expand all
27 27
28 namespace browser_sync { 28 namespace browser_sync {
29 29
30 class BookmarkChangeProcessor; 30 class BookmarkChangeProcessor;
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 NewAssociatorInterface {
38 public: 38 public:
39 static syncable::ModelType model_type() { return syncable::BOOKMARKS; }
40 BookmarkModelAssociator( 39 BookmarkModelAssociator(
41 BookmarkModel* bookmark_model, 40 BookmarkModel* bookmark_model,
42 sync_api::UserShare* user_share, 41 sync_api::UserShare* user_share,
43 UnrecoverableErrorHandler* unrecoverable_error_handler); 42 UnrecoverableErrorHandler* unrecoverable_error_handler);
44 virtual ~BookmarkModelAssociator();
45 43
46 // AssociatorInterface implementation. 44 // AssociatorInterface implementation.
47 // 45 //
48 // AssociateModels iterates through both the sync and the browser 46 // AssociateModels iterates through both the sync and the browser
49 // bookmark model, looking for matched pairs of items. For any pairs it 47 // bookmark model, looking for matched pairs of items. For any pairs it
50 // finds, it will call AssociateSyncID. For any unmatched items, 48 // finds, it will call AssociateSyncID. For any unmatched items,
51 // MergeAndAssociateModels will try to repair the match, e.g. by adding a new 49 // MergeAndAssociateModels will try to repair the match, e.g. by adding a new
52 // node. After successful completion, the models should be identical and 50 // node. After successful completion, the models should be identical and
53 // corresponding. Returns true on success. On failure of this step, we 51 // corresponding. Returns true on success. On failure of this step, we
54 // should abort the sync operation and report an error to the user. 52 // should abort the sync operation and report an error to the user.
(...skipping 26 matching lines...) Expand all
81 virtual void Disassociate(int64 sync_id); 79 virtual void Disassociate(int64 sync_id);
82 80
83 virtual void AbortAssociation() { 81 virtual void AbortAssociation() {
84 // No implementation needed, this associator runs on the main 82 // No implementation needed, this associator runs on the main
85 // thread. 83 // thread.
86 } 84 }
87 85
88 // See ModelAssociator interface. 86 // See ModelAssociator interface.
89 virtual bool CryptoReadyIfNecessary(); 87 virtual bool CryptoReadyIfNecessary();
90 88
89 virtual syncable::ModelType model_type() const { return syncable::BOOKMARKS; }
91 protected: 90 protected:
91 virtual ~BookmarkModelAssociator();
92
92 // Stores the id of the node with the given tag in |sync_id|. 93 // Stores the id of the node with the given tag in |sync_id|.
93 // Returns of that node was found successfully. 94 // Returns of that node was found successfully.
94 // Tests override this. 95 // Tests override this.
95 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id); 96 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id);
96 97
97 private: 98 private:
98 typedef std::map<int64, int64> BookmarkIdToSyncIdMap; 99 typedef std::map<int64, int64> BookmarkIdToSyncIdMap;
99 typedef std::map<int64, const BookmarkNode*> SyncIdToBookmarkNodeMap; 100 typedef std::map<int64, const BookmarkNode*> SyncIdToBookmarkNodeMap;
100 typedef std::set<int64> DirtyAssociationsSyncIds; 101 typedef std::set<int64> DirtyAssociationsSyncIds;
101 102
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 ScopedRunnableMethodFactory<BookmarkModelAssociator> persist_associations_; 140 ScopedRunnableMethodFactory<BookmarkModelAssociator> persist_associations_;
140 141
141 int number_of_new_sync_nodes_created_at_association_; 142 int number_of_new_sync_nodes_created_at_association_;
142 143
143 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); 144 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator);
144 }; 145 };
145 146
146 } // namespace browser_sync 147 } // namespace browser_sync
147 148
148 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ 149 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698