Chromium Code Reviews| 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 // Defines ChangeReorderBuffer, which can be used to sort a list of item | 5 // Defines ChangeReorderBuffer, which can be used to sort a list of item |
| 6 // actions to achieve the ordering constraint required by the SyncObserver | 6 // actions to achieve the ordering constraint required by the SyncObserver |
| 7 // interface of the SyncAPI. | 7 // interface of the SyncAPI. |
| 8 | 8 |
| 9 #ifndef CHROME_BROWSER_SYNC_INTERNAL_API_CHANGE_REORDER_BUFFER_H_ | 9 #ifndef CHROME_BROWSER_SYNC_INTERNAL_API_CHANGE_REORDER_BUFFER_H_ |
| 10 #define CHROME_BROWSER_SYNC_INTERNAL_API_CHANGE_REORDER_BUFFER_H_ | 10 #define CHROME_BROWSER_SYNC_INTERNAL_API_CHANGE_REORDER_BUFFER_H_ |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 // Reset the buffer, forgetting any pushed items, so that it can be used | 77 // Reset the buffer, forgetting any pushed items, so that it can be used |
| 78 // again to reorder a new set of changes. | 78 // again to reorder a new set of changes. |
| 79 void Clear() { | 79 void Clear() { |
| 80 operations_.clear(); | 80 operations_.clear(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool IsEmpty() const { | 83 bool IsEmpty() const { |
| 84 return operations_.empty(); | 84 return operations_.empty(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Output a reordered list of changes to |changelist| using the items that | 87 // Output a reordered list of changes to |changes| using the items |
| 88 // were pushed into the reorder buffer. |sync_trans| is used to determine the | 88 // that were pushed into the reorder buffer. |sync_trans| is used to |
| 89 // ordering. | 89 // determine the ordering. Returns true if successful, or false if |
| 90 ImmutableChangeRecordList | 90 // an error was encountered. |
| 91 GetAllChangesInTreeOrder(const BaseTransaction* sync_trans); | 91 bool GetAllChangesInTreeOrder(const BaseTransaction* sync_trans, |
| 92 ImmutableChangeRecordList* changes); | |
|
Nicolas Zea
2011/10/27 18:28:30
consider WARN_UNUSED_RESULT
akalin
2011/10/27 21:11:43
Done.
| |
| 92 | 93 |
| 93 private: | 94 private: |
| 94 class Traversal; | 95 class Traversal; |
| 95 enum Operation { | 96 enum Operation { |
| 96 OP_ADD, // AddedItem. | 97 OP_ADD, // AddedItem. |
| 97 OP_DELETE, // DeletedItem. | 98 OP_DELETE, // DeletedItem. |
| 98 OP_UPDATE_PROPERTIES_ONLY, // UpdatedItem with position_changed=0. | 99 OP_UPDATE_PROPERTIES_ONLY, // UpdatedItem with position_changed=0. |
| 99 OP_UPDATE_POSITION_AND_PROPERTIES, // UpdatedItem with position_changed=1. | 100 OP_UPDATE_POSITION_AND_PROPERTIES, // UpdatedItem with position_changed=1. |
| 100 }; | 101 }; |
| 101 typedef std::map<int64, Operation> OperationMap; | 102 typedef std::map<int64, Operation> OperationMap; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 112 | 113 |
| 113 // Stores type-specific extra data per-ID. | 114 // Stores type-specific extra data per-ID. |
| 114 ExtraDataMap extra_data_; | 115 ExtraDataMap extra_data_; |
| 115 | 116 |
| 116 DISALLOW_COPY_AND_ASSIGN(ChangeReorderBuffer); | 117 DISALLOW_COPY_AND_ASSIGN(ChangeReorderBuffer); |
| 117 }; | 118 }; |
| 118 | 119 |
| 119 } // namespace sync_api | 120 } // namespace sync_api |
| 120 | 121 |
| 121 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_CHANGE_REORDER_BUFFER_H_ | 122 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_CHANGE_REORDER_BUFFER_H_ |
| OLD | NEW |