| 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_CHANGE_PROCESSOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_BOOKMARK_CHANGE_PROCESSOR_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_BOOKMARK_CHANGE_PROCESSOR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_BOOKMARK_CHANGE_PROCESSOR_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class WriteTransaction; | 26 class WriteTransaction; |
| 27 } // namespace syncer | 27 } // namespace syncer |
| 28 | 28 |
| 29 namespace browser_sync { | 29 namespace browser_sync { |
| 30 | 30 |
| 31 // This class is responsible for taking changes from the BookmarkModel | 31 // This class is responsible for taking changes from the BookmarkModel |
| 32 // and applying them to the sync API 'syncable' model, and vice versa. | 32 // and applying them to the sync API 'syncable' model, and vice versa. |
| 33 // All operations and use of this class are from the UI thread. | 33 // All operations and use of this class are from the UI thread. |
| 34 // This is currently bookmarks specific. | 34 // This is currently bookmarks specific. |
| 35 class BookmarkChangeProcessor : public BookmarkModelObserver, | 35 class BookmarkChangeProcessor : public BookmarkModelObserver, |
| 36 public ChangeProcessor { | 36 public sync_driver::ChangeProcessor { |
| 37 public: | 37 public: |
| 38 BookmarkChangeProcessor(Profile* profile, | 38 BookmarkChangeProcessor(Profile* profile, |
| 39 BookmarkModelAssociator* model_associator, | 39 BookmarkModelAssociator* model_associator, |
| 40 DataTypeErrorHandler* error_handler); | 40 sync_driver::DataTypeErrorHandler* error_handler); |
| 41 virtual ~BookmarkChangeProcessor(); | 41 virtual ~BookmarkChangeProcessor(); |
| 42 | 42 |
| 43 // BookmarkModelObserver implementation. | 43 // BookmarkModelObserver implementation. |
| 44 // BookmarkModel -> sync API model change application. | 44 // BookmarkModel -> sync API model change application. |
| 45 virtual void BookmarkModelLoaded(BookmarkModel* model, | 45 virtual void BookmarkModelLoaded(BookmarkModel* model, |
| 46 bool ids_reassigned) OVERRIDE; | 46 bool ids_reassigned) OVERRIDE; |
| 47 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE; | 47 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) OVERRIDE; |
| 48 virtual void BookmarkNodeMoved(BookmarkModel* model, | 48 virtual void BookmarkNodeMoved(BookmarkModel* model, |
| 49 const BookmarkNode* old_parent, | 49 const BookmarkNode* old_parent, |
| 50 int old_index, | 50 int old_index, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // Treat the |index|th child of |parent| as a newly added node, and create a | 124 // Treat the |index|th child of |parent| as a newly added node, and create a |
| 125 // corresponding node in the sync domain using |trans|. All properties | 125 // corresponding node in the sync domain using |trans|. All properties |
| 126 // will be transferred to the new node. A node corresponding to |parent| | 126 // will be transferred to the new node. A node corresponding to |parent| |
| 127 // must already exist and be associated for this call to succeed. Returns | 127 // must already exist and be associated for this call to succeed. Returns |
| 128 // the ID of the just-created node, or if creation fails, kInvalidID. | 128 // the ID of the just-created node, or if creation fails, kInvalidID. |
| 129 static int64 CreateSyncNode(const BookmarkNode* parent, | 129 static int64 CreateSyncNode(const BookmarkNode* parent, |
| 130 BookmarkModel* model, | 130 BookmarkModel* model, |
| 131 int index, | 131 int index, |
| 132 syncer::WriteTransaction* trans, | 132 syncer::WriteTransaction* trans, |
| 133 BookmarkModelAssociator* associator, | 133 BookmarkModelAssociator* associator, |
| 134 DataTypeErrorHandler* error_handler); | 134 sync_driver::DataTypeErrorHandler* error_handler); |
| 135 | 135 |
| 136 // Update |bookmark_node|'s sync node. | 136 // Update |bookmark_node|'s sync node. |
| 137 static int64 UpdateSyncNode(const BookmarkNode* bookmark_node, | 137 static int64 UpdateSyncNode(const BookmarkNode* bookmark_node, |
| 138 BookmarkModel* model, | 138 BookmarkModel* model, |
| 139 syncer::WriteTransaction* trans, | 139 syncer::WriteTransaction* trans, |
| 140 BookmarkModelAssociator* associator, | 140 BookmarkModelAssociator* associator, |
| 141 DataTypeErrorHandler* error_handler); | 141 sync_driver::DataTypeErrorHandler* error_handler); |
| 142 | 142 |
| 143 // Update transaction version of |model| and |nodes| to |new_version| if | 143 // Update transaction version of |model| and |nodes| to |new_version| if |
| 144 // it's valid. | 144 // it's valid. |
| 145 static void UpdateTransactionVersion( | 145 static void UpdateTransactionVersion( |
| 146 int64 new_version, | 146 int64 new_version, |
| 147 BookmarkModel* model, | 147 BookmarkModel* model, |
| 148 const std::vector<const BookmarkNode*>& nodes); | 148 const std::vector<const BookmarkNode*>& nodes); |
| 149 | 149 |
| 150 protected: | 150 protected: |
| 151 virtual void StartImpl() OVERRIDE; | 151 virtual void StartImpl() OVERRIDE; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 214 |
| 215 // The two models should be associated according to this ModelAssociator. | 215 // The two models should be associated according to this ModelAssociator. |
| 216 BookmarkModelAssociator* model_associator_; | 216 BookmarkModelAssociator* model_associator_; |
| 217 | 217 |
| 218 DISALLOW_COPY_AND_ASSIGN(BookmarkChangeProcessor); | 218 DISALLOW_COPY_AND_ASSIGN(BookmarkChangeProcessor); |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 } // namespace browser_sync | 221 } // namespace browser_sync |
| 222 | 222 |
| 223 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_CHANGE_PROCESSOR_H_ | 223 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_CHANGE_PROCESSOR_H_ |
| OLD | NEW |