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 #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/memory/ref_counted.h" | |
| 11 #include "chrome/browser/sync/engine/syncapi.h" | |
| 10 #include "chrome/browser/sync/syncable/model_type.h" | 12 #include "chrome/browser/sync/syncable/model_type.h" |
| 11 | 13 |
| 12 namespace sync_api { | 14 namespace browser_sync { |
| 13 class BaseNode; | |
| 14 } | |
| 15 | 15 |
| 16 namespace browser_sync { | 16 class ChangeProcessor; |
| 17 | 17 |
| 18 // This represents the fundamental operations used for model association that | 18 // This represents the fundamental operations used for model association that |
| 19 // are common to all ModelAssociators and do not depend on types of the models | 19 // are common to all ModelAssociators and do not depend on types of the models |
| 20 // being associated. | 20 // being associated. |
| 21 class AssociatorInterface { | 21 class AssociatorInterface { |
| 22 public: | 22 public: |
| 23 virtual ~AssociatorInterface() {} | 23 virtual ~AssociatorInterface() {} |
| 24 | 24 |
| 25 // Iterates through both the sync and the chrome model looking for | 25 // Iterates through both the sync and the chrome model looking for |
| 26 // matched pairs of items. After successful completion, the models | 26 // matched pairs of items. After successful completion, the models |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 virtual bool InitSyncNodeFromChromeId(const IDType& node_id, | 78 virtual bool InitSyncNodeFromChromeId(const IDType& node_id, |
| 79 sync_api::BaseNode* sync_node) = 0; | 79 sync_api::BaseNode* sync_node) = 0; |
| 80 | 80 |
| 81 // Associates the given chrome node with the given sync id. | 81 // Associates the given chrome node with the given sync id. |
| 82 virtual void Associate(const Node* node, int64 sync_id) = 0; | 82 virtual void Associate(const Node* node, int64 sync_id) = 0; |
| 83 | 83 |
| 84 // Remove the association that corresponds to the given sync id. | 84 // Remove the association that corresponds to the given sync id. |
| 85 virtual void Disassociate(int64 sync_id) = 0; | 85 virtual void Disassociate(int64 sync_id) = 0; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 // TODO(zea): Have this replace the normal AssociatorInterface. | |
| 89 class NewAssociatorInterface : public AssociatorInterface, | |
| 90 public base::RefCounted<NewAssociatorInterface> { | |
|
tim (not reviewing)
2011/04/28 21:51:44
Why RefCounted?
Nicolas Zea
2011/05/03 18:59:36
Done.
| |
| 91 public: | |
| 92 // The model type of the associator. | |
| 93 virtual syncable::ModelType model_type() const { | |
| 94 return syncable::UNSPECIFIED; | |
| 95 } | |
| 96 | |
| 97 // Sets the model associator's change processor. This is called by the | |
| 98 // ProfileSyncService and gives the associator an interface to the SyncApi. | |
| 99 virtual void set_change_processor(ChangeProcessor* processor) {} | |
| 100 | |
| 101 // Returns the model associator's current change processor. | |
| 102 virtual ChangeProcessor* change_processor() { return NULL; } | |
| 103 | |
| 104 // TODO(zea): Change the format of this to pass all specifics information | |
| 105 // in by reference. | |
| 106 virtual void ApplyChangesFromSync( | |
| 107 const sync_api::BaseTransaction* trans, | |
| 108 const sync_api::SyncManager::ChangeRecord* changes, | |
| 109 int change_count) {} | |
| 110 protected: | |
| 111 friend class base::RefCounted<NewAssociatorInterface>; | |
| 112 | |
| 113 virtual ~NewAssociatorInterface() {} | |
| 114 }; | |
| 115 | |
| 88 } // namespace browser_sync | 116 } // namespace browser_sync |
| 89 | 117 |
| 90 #endif // CHROME_BROWSER_SYNC_GLUE_MODEL_ASSOCIATOR_H_ | 118 #endif // CHROME_BROWSER_SYNC_GLUE_MODEL_ASSOCIATOR_H_ |
| OLD | NEW |