OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_PASSWORD_MODEL_ASSOCIATOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // * Persisting model associations and loading them back. | 45 // * Persisting model associations and loading them back. |
46 // We do not check if we have local data before this runs; we always | 46 // We do not check if we have local data before this runs; we always |
47 // merge and sync. | 47 // merge and sync. |
48 class PasswordModelAssociator | 48 class PasswordModelAssociator |
49 : public PerDataTypeAssociatorInterface<std::string, std::string> { | 49 : public PerDataTypeAssociatorInterface<std::string, std::string> { |
50 public: | 50 public: |
51 typedef std::vector<webkit_glue::PasswordForm> PasswordVector; | 51 typedef std::vector<webkit_glue::PasswordForm> PasswordVector; |
52 | 52 |
53 static syncable::ModelType model_type() { return syncable::PASSWORD; } | 53 static syncable::ModelType model_type() { return syncable::PASSWORD; } |
54 PasswordModelAssociator(ProfileSyncService* sync_service, | 54 PasswordModelAssociator(ProfileSyncService* sync_service, |
55 PasswordStore* password_store, | 55 PasswordStore* password_store); |
56 UnrecoverableErrorHandler* error_handler); | |
57 virtual ~PasswordModelAssociator() { } | 56 virtual ~PasswordModelAssociator() { } |
58 | 57 |
59 // PerDataTypeAssociatorInterface implementation. | 58 // PerDataTypeAssociatorInterface implementation. |
60 // | 59 // |
61 // Iterates through the sync model looking for matched pairs of items. | 60 // Iterates through the sync model looking for matched pairs of items. |
62 virtual bool AssociateModels(); | 61 virtual bool AssociateModels(); |
63 | 62 |
64 // Delete all password nodes. | 63 // Delete all password nodes. |
65 bool DeleteAllNodes(sync_api::WriteTransaction* trans); | 64 bool DeleteAllNodes(sync_api::WriteTransaction* trans); |
66 | 65 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 protected: | 128 protected: |
130 // Returns sync service instance. | 129 // Returns sync service instance. |
131 ProfileSyncService* sync_service() { return sync_service_; } | 130 ProfileSyncService* sync_service() { return sync_service_; } |
132 | 131 |
133 private: | 132 private: |
134 typedef std::map<std::string, int64> PasswordToSyncIdMap; | 133 typedef std::map<std::string, int64> PasswordToSyncIdMap; |
135 typedef std::map<int64, std::string> SyncIdToPasswordMap; | 134 typedef std::map<int64, std::string> SyncIdToPasswordMap; |
136 | 135 |
137 ProfileSyncService* sync_service_; | 136 ProfileSyncService* sync_service_; |
138 PasswordStore* password_store_; | 137 PasswordStore* password_store_; |
139 UnrecoverableErrorHandler* error_handler_; | |
140 int64 password_node_id_; | 138 int64 password_node_id_; |
141 | 139 |
142 // Abort association pending flag and lock. If this is set to true | 140 // Abort association pending flag and lock. If this is set to true |
143 // (via the AbortAssociation method), return from the | 141 // (via the AbortAssociation method), return from the |
144 // AssociateModels method as soon as possible. | 142 // AssociateModels method as soon as possible. |
145 Lock abort_association_pending_lock_; | 143 Lock abort_association_pending_lock_; |
146 bool abort_association_pending_; | 144 bool abort_association_pending_; |
147 | 145 |
148 MessageLoop* expected_loop_; | 146 MessageLoop* expected_loop_; |
149 | 147 |
150 PasswordToSyncIdMap id_map_; | 148 PasswordToSyncIdMap id_map_; |
151 SyncIdToPasswordMap id_map_inverse_; | 149 SyncIdToPasswordMap id_map_inverse_; |
152 | 150 |
153 DISALLOW_COPY_AND_ASSIGN(PasswordModelAssociator); | 151 DISALLOW_COPY_AND_ASSIGN(PasswordModelAssociator); |
154 }; | 152 }; |
155 | 153 |
156 } // namespace browser_sync | 154 } // namespace browser_sync |
157 | 155 |
158 #endif // CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_ | 156 #endif // CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_ |
OLD | NEW |