Chromium Code Reviews| 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_MODEL_ASSOCIATOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_MODEL_ASSOCIATOR_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_MODEL_ASSOCIATOR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_MODEL_ASSOCIATOR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| 11 #include "sync/syncable/model_type.h" | 11 #include "sync/syncable/model_type.h" |
| 12 | 12 |
| 13 class SyncError; | 13 class SyncError; |
|
Nicolas Zea
2012/04/05 22:08:58
Remove this and add #include (no longer just using
lipalani1
2012/04/05 22:51:03
Done.
| |
| 14 | 14 |
| 15 namespace sync_api { | 15 namespace sync_api { |
| 16 class BaseNode; | 16 class BaseNode; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace browser_sync { | 19 namespace browser_sync { |
| 20 | 20 |
| 21 // This represents the fundamental operations used for model association that | 21 // This represents the fundamental operations used for model association that |
| 22 // are common to all ModelAssociators and do not depend on types of the models | 22 // are common to all ModelAssociators and do not depend on types of the models |
| 23 // being associated. | 23 // being associated. |
| 24 class AssociatorInterface { | 24 class AssociatorInterface { |
| 25 public: | 25 public: |
| 26 virtual ~AssociatorInterface() {} | 26 virtual ~AssociatorInterface() {} |
| 27 | 27 |
| 28 // Iterates through both the sync and the chrome model looking for | 28 // Iterates through both the sync and the chrome model looking for |
| 29 // matched pairs of items. After successful completion, the models | 29 // matched pairs of items. After successful completion, the models |
| 30 // should be identical and corresponding. Returns true on | 30 // should be identical and corresponding. Returns true on |
| 31 // success. On failure of this step, we should abort the sync | 31 // success. On failure of this step, we should abort the sync |
| 32 // operation and report an error to the user. | 32 // operation and report an error to the user. |
| 33 // TODO(zea): return a SyncError instead of passing one in. | 33 virtual SyncError AssociateModels() = 0; |
| 34 virtual bool AssociateModels(SyncError* error) = 0; | |
| 35 | 34 |
| 36 // Clears all the associations between the chrome and sync models. | 35 // Clears all the associations between the chrome and sync models. |
| 37 // TODO(zea): return a SyncError instead of passing one in. | 36 virtual SyncError DisassociateModels() = 0; |
| 38 virtual bool DisassociateModels(SyncError* error) = 0; | |
| 39 | 37 |
| 40 // The has_nodes out parameter is set to true if the sync model has | 38 // The has_nodes out parameter is set to true if the sync model has |
| 41 // nodes other than the permanent tagged nodes. The method may | 39 // nodes other than the permanent tagged nodes. The method may |
| 42 // return false if an error occurred. | 40 // return false if an error occurred. |
| 43 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) = 0; | 41 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) = 0; |
| 44 | 42 |
| 45 // Calling this method while AssociateModels() is in progress will | 43 // Calling this method while AssociateModels() is in progress will |
| 46 // cause the method to exit early with a "false" return value. This | 44 // cause the method to exit early with a "false" return value. This |
| 47 // is useful for aborting model associations for shutdown. This | 45 // is useful for aborting model associations for shutdown. This |
| 48 // method is only implemented for model associators that are invoked | 46 // method is only implemented for model associators that are invoked |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 // Associates the given chrome node with the given sync id. | 84 // Associates the given chrome node with the given sync id. |
| 87 virtual void Associate(const Node* node, int64 sync_id) = 0; | 85 virtual void Associate(const Node* node, int64 sync_id) = 0; |
| 88 | 86 |
| 89 // Remove the association that corresponds to the given sync id. | 87 // Remove the association that corresponds to the given sync id. |
| 90 virtual void Disassociate(int64 sync_id) = 0; | 88 virtual void Disassociate(int64 sync_id) = 0; |
| 91 }; | 89 }; |
| 92 | 90 |
| 93 } // namespace browser_sync | 91 } // namespace browser_sync |
| 94 | 92 |
| 95 #endif // CHROME_BROWSER_SYNC_GLUE_MODEL_ASSOCIATOR_H_ | 93 #endif // CHROME_BROWSER_SYNC_GLUE_MODEL_ASSOCIATOR_H_ |
| OLD | NEW |