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