| 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 20 matching lines...) Expand all Loading... |
| 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 sync_driver::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 sync_driver::DataTypeErrorHandler* error_handler); | 40 sync_driver::DataTypeErrorHandler* error_handler); |
| 41 virtual ~BookmarkChangeProcessor(); | 41 ~BookmarkChangeProcessor() override; |
| 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 void BookmarkModelLoaded(BookmarkModel* model, bool ids_reassigned) override; |
| 46 bool ids_reassigned) override; | 46 void BookmarkModelBeingDeleted(BookmarkModel* model) override; |
| 47 virtual void BookmarkModelBeingDeleted(BookmarkModel* model) override; | 47 void BookmarkNodeMoved(BookmarkModel* model, |
| 48 virtual void BookmarkNodeMoved(BookmarkModel* model, | 48 const BookmarkNode* old_parent, |
| 49 const BookmarkNode* old_parent, | 49 int old_index, |
| 50 int old_index, | 50 const BookmarkNode* new_parent, |
| 51 const BookmarkNode* new_parent, | 51 int new_index) override; |
| 52 int new_index) override; | 52 void BookmarkNodeAdded(BookmarkModel* model, |
| 53 virtual void BookmarkNodeAdded(BookmarkModel* model, | 53 const BookmarkNode* parent, |
| 54 const BookmarkNode* parent, | 54 int index) override; |
| 55 int index) override; | 55 void BookmarkNodeRemoved(BookmarkModel* model, |
| 56 virtual void BookmarkNodeRemoved(BookmarkModel* model, | 56 const BookmarkNode* parent, |
| 57 const BookmarkNode* parent, | 57 int index, |
| 58 int index, | 58 const BookmarkNode* node, |
| 59 const BookmarkNode* node, | 59 const std::set<GURL>& removed_urls) override; |
| 60 void BookmarkAllUserNodesRemoved(BookmarkModel* model, |
| 60 const std::set<GURL>& removed_urls) override; | 61 const std::set<GURL>& removed_urls) override; |
| 61 virtual void BookmarkAllUserNodesRemoved( | 62 void BookmarkNodeChanged(BookmarkModel* model, |
| 62 BookmarkModel* model, | 63 const BookmarkNode* node) override; |
| 63 const std::set<GURL>& removed_urls) override; | 64 void BookmarkMetaInfoChanged(BookmarkModel* model, |
| 64 virtual void BookmarkNodeChanged(BookmarkModel* model, | 65 const BookmarkNode* node) override; |
| 65 const BookmarkNode* node) override; | 66 void BookmarkNodeFaviconChanged(BookmarkModel* model, |
| 66 virtual void BookmarkMetaInfoChanged(BookmarkModel* model, | 67 const BookmarkNode* node) override; |
| 67 const BookmarkNode* node) override; | 68 void BookmarkNodeChildrenReordered(BookmarkModel* model, |
| 68 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model, | 69 const BookmarkNode* node) override; |
| 69 const BookmarkNode* node) override; | |
| 70 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, | |
| 71 const BookmarkNode* node) override; | |
| 72 | 70 |
| 73 // The change processor implementation, responsible for applying changes from | 71 // The change processor implementation, responsible for applying changes from |
| 74 // the sync model to the bookmarks model. | 72 // the sync model to the bookmarks model. |
| 75 virtual void ApplyChangesFromSyncModel( | 73 void ApplyChangesFromSyncModel( |
| 76 const syncer::BaseTransaction* trans, | 74 const syncer::BaseTransaction* trans, |
| 77 int64 model_version, | 75 int64 model_version, |
| 78 const syncer::ImmutableChangeRecordList& changes) override; | 76 const syncer::ImmutableChangeRecordList& changes) override; |
| 79 | 77 |
| 80 // The following methods are static and hence may be invoked at any time, and | 78 // The following methods are static and hence may be invoked at any time, and |
| 81 // do not depend on having a running ChangeProcessor. | 79 // do not depend on having a running ChangeProcessor. |
| 82 | 80 |
| 83 // Updates the title, URL, creation time and favicon of the bookmark |node| | 81 // Updates the title, URL, creation time and favicon of the bookmark |node| |
| 84 // with data taken from the |sync_node| sync node. | 82 // with data taken from the |sync_node| sync node. |
| 85 static void UpdateBookmarkWithSyncData( | 83 static void UpdateBookmarkWithSyncData( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 sync_driver::DataTypeErrorHandler* error_handler); | 139 sync_driver::DataTypeErrorHandler* error_handler); |
| 142 | 140 |
| 143 // Update transaction version of |model| and |nodes| to |new_version| if | 141 // Update transaction version of |model| and |nodes| to |new_version| if |
| 144 // it's valid. | 142 // it's valid. |
| 145 static void UpdateTransactionVersion( | 143 static void UpdateTransactionVersion( |
| 146 int64 new_version, | 144 int64 new_version, |
| 147 BookmarkModel* model, | 145 BookmarkModel* model, |
| 148 const std::vector<const BookmarkNode*>& nodes); | 146 const std::vector<const BookmarkNode*>& nodes); |
| 149 | 147 |
| 150 protected: | 148 protected: |
| 151 virtual void StartImpl() override; | 149 void StartImpl() override; |
| 152 | 150 |
| 153 private: | 151 private: |
| 154 enum MoveOrCreate { | 152 enum MoveOrCreate { |
| 155 MOVE, | 153 MOVE, |
| 156 CREATE, | 154 CREATE, |
| 157 }; | 155 }; |
| 158 | 156 |
| 159 // Retrieves the meta info from the given sync node. | 157 // Retrieves the meta info from the given sync node. |
| 160 static scoped_ptr<BookmarkNode::MetaInfoMap> GetBookmarkMetaInfo( | 158 static scoped_ptr<BookmarkNode::MetaInfoMap> GetBookmarkMetaInfo( |
| 161 const syncer::BaseNode* sync_node); | 159 const syncer::BaseNode* sync_node); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 215 |
| 218 // The two models should be associated according to this ModelAssociator. | 216 // The two models should be associated according to this ModelAssociator. |
| 219 BookmarkModelAssociator* model_associator_; | 217 BookmarkModelAssociator* model_associator_; |
| 220 | 218 |
| 221 DISALLOW_COPY_AND_ASSIGN(BookmarkChangeProcessor); | 219 DISALLOW_COPY_AND_ASSIGN(BookmarkChangeProcessor); |
| 222 }; | 220 }; |
| 223 | 221 |
| 224 } // namespace browser_sync | 222 } // namespace browser_sync |
| 225 | 223 |
| 226 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_CHANGE_PROCESSOR_H_ | 224 #endif // CHROME_BROWSER_SYNC_GLUE_BOOKMARK_CHANGE_PROCESSOR_H_ |
| OLD | NEW |