OLD | NEW |
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // AssociatorInterface implementation. | 46 // AssociatorInterface implementation. |
47 // | 47 // |
48 // AssociateModels iterates through both the sync and the browser | 48 // AssociateModels iterates through both the sync and the browser |
49 // bookmark model, looking for matched pairs of items. For any pairs it | 49 // bookmark model, looking for matched pairs of items. For any pairs it |
50 // finds, it will call AssociateSyncID. For any unmatched items, | 50 // finds, it will call AssociateSyncID. For any unmatched items, |
51 // MergeAndAssociateModels will try to repair the match, e.g. by adding a new | 51 // MergeAndAssociateModels will try to repair the match, e.g. by adding a new |
52 // node. After successful completion, the models should be identical and | 52 // node. After successful completion, the models should be identical and |
53 // corresponding. Returns true on success. On failure of this step, we | 53 // corresponding. Returns true on success. On failure of this step, we |
54 // should abort the sync operation and report an error to the user. | 54 // should abort the sync operation and report an error to the user. |
55 virtual bool AssociateModels(SyncError* error); | 55 virtual bool AssociateModels(); |
56 | 56 |
57 virtual bool DisassociateModels(SyncError* error); | 57 virtual bool DisassociateModels(); |
58 | 58 |
59 // The has_nodes out param is true if the sync model has nodes other | 59 // The has_nodes out param is true if the sync model has nodes other |
60 // than the permanent tagged nodes. | 60 // than the permanent tagged nodes. |
61 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes); | 61 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes); |
62 | 62 |
63 // Returns sync id for the given bookmark node id. | 63 // Returns sync id for the given bookmark node id. |
64 // Returns sync_api::kInvalidId if the sync node is not found for the given | 64 // Returns sync_api::kInvalidId if the sync node is not found for the given |
65 // bookmark node id. | 65 // bookmark node id. |
66 virtual int64 GetSyncIdFromChromeId(const int64& node_id); | 66 virtual int64 GetSyncIdFromChromeId(const int64& node_id); |
67 | 67 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Persists all dirty associations. | 104 // Persists all dirty associations. |
105 void PersistAssociations(); | 105 void PersistAssociations(); |
106 | 106 |
107 // Loads the persisted associations into in-memory maps. | 107 // Loads the persisted associations into in-memory maps. |
108 // If the persisted associations are out-of-date due to some reason, returns | 108 // If the persisted associations are out-of-date due to some reason, returns |
109 // false; otherwise returns true. | 109 // false; otherwise returns true. |
110 bool LoadAssociations(); | 110 bool LoadAssociations(); |
111 | 111 |
112 // Matches up the bookmark model and the sync model to build model | 112 // Matches up the bookmark model and the sync model to build model |
113 // associations. | 113 // associations. |
114 bool BuildAssociations(SyncError* error); | 114 bool BuildAssociations(); |
115 | 115 |
116 // Associate a top-level node of the bookmark model with a permanent node in | 116 // Associate a top-level node of the bookmark model with a permanent node in |
117 // the sync domain. Such permanent nodes are identified by a tag that is | 117 // the sync domain. Such permanent nodes are identified by a tag that is |
118 // well known to the server and the client, and is unique within a particular | 118 // well known to the server and the client, and is unique within a particular |
119 // user's share. For example, "other_bookmarks" is the tag for the Other | 119 // user's share. For example, "other_bookmarks" is the tag for the Other |
120 // Bookmarks folder. The sync nodes are server-created. | 120 // Bookmarks folder. The sync nodes are server-created. |
121 bool AssociateTaggedPermanentNode(const BookmarkNode* permanent_node, | 121 bool AssociateTaggedPermanentNode(const BookmarkNode* permanent_node, |
122 const std::string& tag); | 122 const std::string& tag); |
123 | 123 |
124 // Compare the properties of a pair of nodes from either domain. | 124 // Compare the properties of a pair of nodes from either domain. |
(...skipping 14 matching lines...) Expand all Loading... |
139 ScopedRunnableMethodFactory<BookmarkModelAssociator> persist_associations_; | 139 ScopedRunnableMethodFactory<BookmarkModelAssociator> persist_associations_; |
140 | 140 |
141 int number_of_new_sync_nodes_created_at_association_; | 141 int number_of_new_sync_nodes_created_at_association_; |
142 | 142 |
143 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); | 143 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); |
144 }; | 144 }; |
145 | 145 |
146 } // namespace browser_sync | 146 } // namespace browser_sync |
147 | 147 |
148 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ | 148 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ |
OLD | NEW |