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