| 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 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "chrome/browser/sync/glue/data_type_controller.h" | 15 #include "chrome/browser/sync/glue/data_type_controller.h" |
| 16 #include "chrome/browser/sync/glue/data_type_error_handler.h" | 16 #include "chrome/browser/sync/glue/data_type_error_handler.h" |
| 17 #include "chrome/browser/sync/glue/model_associator.h" | 17 #include "chrome/browser/sync/glue/model_associator.h" |
| 18 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 18 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
| 19 | 19 |
| 20 class BookmarkModel; | 20 class BookmarkModel; |
| 21 class BookmarkNode; | 21 class BookmarkNode; |
| 22 | 22 |
| 23 namespace syncer { | 23 namespace syncer { |
| 24 class BaseNode; | 24 class BaseNode; |
| 25 class BaseTransaction; |
| 25 struct UserShare; | 26 struct UserShare; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace browser_sync { | 29 namespace browser_sync { |
| 29 | 30 |
| 30 // Contains all model association related logic: | 31 // Contains all model association related logic: |
| 31 // * Algorithm to associate bookmark model and sync model. | 32 // * Algorithm to associate bookmark model and sync model. |
| 32 // * Methods to get a bookmark node for a given sync node and vice versa. | 33 // * Methods to get a bookmark node for a given sync node and vice versa. |
| 33 // * Persisting model associations and loading them back. | 34 // * Persisting model associations and loading them back. |
| 34 class BookmarkModelAssociator | 35 class BookmarkModelAssociator |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 void PostPersistAssociationsTask(); | 112 void PostPersistAssociationsTask(); |
| 112 // Persists all dirty associations. | 113 // Persists all dirty associations. |
| 113 void PersistAssociations(); | 114 void PersistAssociations(); |
| 114 | 115 |
| 115 // Matches up the bookmark model and the sync model to build model | 116 // Matches up the bookmark model and the sync model to build model |
| 116 // associations. | 117 // associations. |
| 117 syncer::SyncError BuildAssociations( | 118 syncer::SyncError BuildAssociations( |
| 118 syncer::SyncMergeResult* local_merge_result, | 119 syncer::SyncMergeResult* local_merge_result, |
| 119 syncer::SyncMergeResult* syncer_merge_result); | 120 syncer::SyncMergeResult* syncer_merge_result); |
| 120 | 121 |
| 122 // Removes bookmark nodes whose corresponding sync nodes have been deleted |
| 123 // according to sync delete journals. Return number of deleted bookmarks. |
| 124 int64 ApplyDeletesFromSyncJournal(syncer::BaseTransaction* trans); |
| 125 |
| 121 // Associate a top-level node of the bookmark model with a permanent node in | 126 // Associate a top-level node of the bookmark model with a permanent node in |
| 122 // the sync domain. Such permanent nodes are identified by a tag that is | 127 // the sync domain. Such permanent nodes are identified by a tag that is |
| 123 // well known to the server and the client, and is unique within a particular | 128 // well known to the server and the client, and is unique within a particular |
| 124 // user's share. For example, "other_bookmarks" is the tag for the Other | 129 // user's share. For example, "other_bookmarks" is the tag for the Other |
| 125 // Bookmarks folder. The sync nodes are server-created. | 130 // Bookmarks folder. The sync nodes are server-created. |
| 126 // Returns true on success, false if association failed. | 131 // Returns true on success, false if association failed. |
| 127 bool AssociateTaggedPermanentNode( | 132 bool AssociateTaggedPermanentNode( |
| 128 const BookmarkNode* permanent_node, | 133 const BookmarkNode* permanent_node, |
| 129 const std::string& tag) WARN_UNUSED_RESULT; | 134 const std::string& tag) WARN_UNUSED_RESULT; |
| 130 | 135 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 149 // guarantees no invocations can occur if |this| has been deleted. (This | 154 // guarantees no invocations can occur if |this| has been deleted. (This |
| 150 // allows this class to be non-refcounted). | 155 // allows this class to be non-refcounted). |
| 151 base::WeakPtrFactory<BookmarkModelAssociator> weak_factory_; | 156 base::WeakPtrFactory<BookmarkModelAssociator> weak_factory_; |
| 152 | 157 |
| 153 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); | 158 DISALLOW_COPY_AND_ASSIGN(BookmarkModelAssociator); |
| 154 }; | 159 }; |
| 155 | 160 |
| 156 } // namespace browser_sync | 161 } // namespace browser_sync |
| 157 | 162 |
| 158 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ | 163 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_MODEL_ASSOCIATOR_H_ |
| OLD | NEW |