Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Side by Side Diff: chrome/browser/sync/glue/model_associator.h

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/api/sync_error.h" 11 #include "sync/api/sync_error.h"
12 #include "sync/internal_api/public/syncable/model_type.h" 12 #include "sync/internal_api/public/syncable/model_type.h"
13 13
14 namespace csync { 14 namespace syncer {
15 class BaseNode; 15 class BaseNode;
16 } 16 }
17 17
18 namespace browser_sync { 18 namespace browser_sync {
19 19
20 // This represents the fundamental operations used for model association that 20 // This represents the fundamental operations used for model association that
21 // 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
22 // being associated. 22 // being associated.
23 class AssociatorInterface { 23 class AssociatorInterface {
24 public: 24 public:
25 virtual ~AssociatorInterface() {} 25 virtual ~AssociatorInterface() {}
26 26
27 // Iterates through both the sync and the chrome model looking for 27 // Iterates through both the sync and the chrome model looking for
28 // matched pairs of items. After successful completion, the models 28 // matched pairs of items. After successful completion, the models
29 // should be identical and corresponding. Returns true on 29 // should be identical and corresponding. Returns true on
30 // success. On failure of this step, we should abort the sync 30 // success. On failure of this step, we should abort the sync
31 // operation and report an error to the user. 31 // operation and report an error to the user.
32 virtual csync::SyncError AssociateModels() = 0; 32 virtual syncer::SyncError AssociateModels() = 0;
33 33
34 // Clears all the associations between the chrome and sync models. 34 // Clears all the associations between the chrome and sync models.
35 virtual csync::SyncError DisassociateModels() = 0; 35 virtual syncer::SyncError DisassociateModels() = 0;
36 36
37 // 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
38 // nodes other than the permanent tagged nodes. The method may 38 // nodes other than the permanent tagged nodes. The method may
39 // return false if an error occurred. 39 // return false if an error occurred.
40 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) = 0; 40 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) = 0;
41 41
42 // Calling this method while AssociateModels() is in progress will 42 // Calling this method while AssociateModels() is in progress will
43 // 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
44 // is useful for aborting model associations for shutdown. This 44 // is useful for aborting model associations for shutdown. This
45 // method is only implemented for model associators that are invoked 45 // method is only implemented for model associators that are invoked
(...skipping 13 matching lines...) Expand all
59 // interface that encapsulates everything you need to implement to have a model 59 // interface that encapsulates everything you need to implement to have a model
60 // associator for a specific data type. 60 // associator for a specific data type.
61 // This template is appropriate for data types where a Node* makes sense for 61 // This template is appropriate for data types where a Node* makes sense for
62 // referring to a particular item. If we encounter a type that does not fit 62 // referring to a particular item. If we encounter a type that does not fit
63 // in this world, we may want to have several PerDataType templates. 63 // in this world, we may want to have several PerDataType templates.
64 template <class Node, class IDType> 64 template <class Node, class IDType>
65 class PerDataTypeAssociatorInterface : public AssociatorInterface { 65 class PerDataTypeAssociatorInterface : public AssociatorInterface {
66 public: 66 public:
67 virtual ~PerDataTypeAssociatorInterface() {} 67 virtual ~PerDataTypeAssociatorInterface() {}
68 // Returns sync id for the given chrome model id. 68 // Returns sync id for the given chrome model id.
69 // Returns csync::kInvalidId if the sync node is not found for the given 69 // Returns syncer::kInvalidId if the sync node is not found for the given
70 // chrome id. 70 // chrome id.
71 virtual int64 GetSyncIdFromChromeId(const IDType& id) = 0; 71 virtual int64 GetSyncIdFromChromeId(const IDType& id) = 0;
72 72
73 // Returns the chrome node for the given sync id. 73 // Returns the chrome node for the given sync id.
74 // Returns NULL if no node is found for the given sync id. 74 // Returns NULL if no node is found for the given sync id.
75 virtual const Node* GetChromeNodeFromSyncId(int64 sync_id) = 0; 75 virtual const Node* GetChromeNodeFromSyncId(int64 sync_id) = 0;
76 76
77 // Initializes the given sync node from the given chrome node id. 77 // Initializes the given sync node from the given chrome node id.
78 // Returns false if no sync node was found for the given chrome node id or 78 // Returns false if no sync node was found for the given chrome node id or
79 // if the initialization of sync node fails. 79 // if the initialization of sync node fails.
80 virtual bool InitSyncNodeFromChromeId( 80 virtual bool InitSyncNodeFromChromeId(
81 const IDType& node_id, 81 const IDType& node_id,
82 csync::BaseNode* sync_node) = 0; 82 syncer::BaseNode* sync_node) = 0;
83 83
84 // Associates the given chrome node with the given sync id. 84 // Associates the given chrome node with the given sync id.
85 virtual void Associate(const Node* node, int64 sync_id) = 0; 85 virtual void Associate(const Node* node, int64 sync_id) = 0;
86 86
87 // Remove the association that corresponds to the given sync id. 87 // Remove the association that corresponds to the given sync id.
88 virtual void Disassociate(int64 sync_id) = 0; 88 virtual void Disassociate(int64 sync_id) = 0;
89 }; 89 };
90 90
91 } // namespace browser_sync 91 } // namespace browser_sync
92 92
93 #endif // CHROME_BROWSER_SYNC_GLUE_MODEL_ASSOCIATOR_H_ 93 #endif // CHROME_BROWSER_SYNC_GLUE_MODEL_ASSOCIATOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/model_association_manager_unittest.cc ('k') | chrome/browser/sync/glue/model_associator_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698