OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // Associates the given bookmark node with the given sync id. | 76 // Associates the given bookmark node with the given sync id. |
77 virtual void Associate(const BookmarkNode* node, int64 sync_id); | 77 virtual void Associate(const BookmarkNode* node, int64 sync_id); |
78 // Remove the association that corresponds to the given sync id. | 78 // Remove the association that corresponds to the given sync id. |
79 virtual void Disassociate(int64 sync_id); | 79 virtual void Disassociate(int64 sync_id); |
80 | 80 |
81 virtual void AbortAssociation() { | 81 virtual void AbortAssociation() { |
82 // No implementation needed, this associator runs on the main | 82 // No implementation needed, this associator runs on the main |
83 // thread. | 83 // thread. |
84 } | 84 } |
85 | 85 |
86 // Returns sync service instance. | |
87 ProfileSyncService* sync_service() { return sync_service_; } | |
88 | |
89 protected: | 86 protected: |
90 // Stores the id of the node with the given tag in |sync_id|. | 87 // Stores the id of the node with the given tag in |sync_id|. |
91 // Returns of that node was found successfully. | 88 // Returns of that node was found successfully. |
92 // Tests override this. | 89 // Tests override this. |
93 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id); | 90 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id); |
94 | 91 |
| 92 // Used by TestBookmarkModelAssociator. |
| 93 ProfileSyncService* sync_service() { return sync_service_; } |
| 94 |
95 private: | 95 private: |
96 typedef std::map<int64, int64> BookmarkIdToSyncIdMap; | 96 typedef std::map<int64, int64> BookmarkIdToSyncIdMap; |
97 typedef std::map<int64, const BookmarkNode*> SyncIdToBookmarkNodeMap; | 97 typedef std::map<int64, const BookmarkNode*> SyncIdToBookmarkNodeMap; |
98 typedef std::set<int64> DirtyAssociationsSyncIds; | 98 typedef std::set<int64> DirtyAssociationsSyncIds; |
99 | 99 |
100 // Posts a task to persist dirty associations. | 100 // Posts a task to persist dirty associations. |
101 void PostPersistAssociationsTask(); | 101 void PostPersistAssociationsTask(); |
102 // Persists all dirty associations. | 102 // Persists all dirty associations. |
103 void PersistAssociations(); | 103 void PersistAssociations(); |
104 | 104 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 ScopedRunnableMethodFactory<BookmarkModelAssociator> persist_associations_; | 136 ScopedRunnableMethodFactory<BookmarkModelAssociator> persist_associations_; |
137 | 137 |
138 int number_of_new_sync_nodes_created_at_association_; | 138 int number_of_new_sync_nodes_created_at_association_; |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); | 140 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); |
141 }; | 141 }; |
142 | 142 |
143 } // namespace browser_sync | 143 } // namespace browser_sync |
144 | 144 |
145 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ | 145 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ |
OLD | NEW |