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_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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/compiler_specific.h" |
14 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
15 #include "base/task.h" | 16 #include "base/task.h" |
16 #include "chrome/browser/history/history_types.h" | 17 #include "chrome/browser/history/history_types.h" |
17 #include "chrome/browser/sync/glue/model_associator.h" | 18 #include "chrome/browser/sync/glue/model_associator.h" |
18 #include "chrome/browser/sync/protocol/password_specifics.pb.h" | 19 #include "chrome/browser/sync/protocol/password_specifics.pb.h" |
19 | 20 |
20 class MessageLoop; | 21 class MessageLoop; |
21 class PasswordStore; | 22 class PasswordStore; |
22 class ProfileSyncService; | 23 class ProfileSyncService; |
23 | 24 |
(...skipping 21 matching lines...) Expand all Loading... |
45 typedef std::vector<webkit_glue::PasswordForm> PasswordVector; | 46 typedef std::vector<webkit_glue::PasswordForm> PasswordVector; |
46 | 47 |
47 static syncable::ModelType model_type() { return syncable::PASSWORDS; } | 48 static syncable::ModelType model_type() { return syncable::PASSWORDS; } |
48 PasswordModelAssociator(ProfileSyncService* sync_service, | 49 PasswordModelAssociator(ProfileSyncService* sync_service, |
49 PasswordStore* password_store); | 50 PasswordStore* password_store); |
50 virtual ~PasswordModelAssociator(); | 51 virtual ~PasswordModelAssociator(); |
51 | 52 |
52 // PerDataTypeAssociatorInterface implementation. | 53 // PerDataTypeAssociatorInterface implementation. |
53 // | 54 // |
54 // Iterates through the sync model looking for matched pairs of items. | 55 // Iterates through the sync model looking for matched pairs of items. |
55 virtual bool AssociateModels(SyncError* error); | 56 virtual bool AssociateModels(SyncError* error) OVERRIDE; |
56 | 57 |
57 // Delete all password nodes. | 58 // Delete all password nodes. |
58 bool DeleteAllNodes(sync_api::WriteTransaction* trans); | 59 bool DeleteAllNodes(sync_api::WriteTransaction* trans); |
59 | 60 |
60 // Clears all associations. | 61 // Clears all associations. |
61 virtual bool DisassociateModels(SyncError* error); | 62 virtual bool DisassociateModels(SyncError* error) OVERRIDE; |
62 | 63 |
63 // The has_nodes out param is true if the sync model has nodes other | 64 // The has_nodes out param is true if the sync model has nodes other |
64 // than the permanent tagged nodes. | 65 // than the permanent tagged nodes. |
65 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes); | 66 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) OVERRIDE; |
66 | 67 |
67 // See ModelAssociator interface. | 68 // See ModelAssociator interface. |
68 virtual void AbortAssociation(); | 69 virtual void AbortAssociation() OVERRIDE; |
69 | 70 |
70 // See ModelAssociator interface. | 71 // See ModelAssociator interface. |
71 virtual bool CryptoReadyIfNecessary(); | 72 virtual bool CryptoReadyIfNecessary() OVERRIDE; |
72 | 73 |
73 // Not implemented. | 74 // Not implemented. |
74 virtual const std::string* GetChromeNodeFromSyncId(int64 sync_id); | 75 virtual const std::string* GetChromeNodeFromSyncId(int64 sync_id) OVERRIDE; |
75 | 76 |
76 // Not implemented. | 77 // Not implemented. |
77 virtual bool InitSyncNodeFromChromeId(const std::string& node_id, | 78 virtual bool InitSyncNodeFromChromeId(const std::string& node_id, |
78 sync_api::BaseNode* sync_node); | 79 sync_api::BaseNode* sync_node) OVERRIDE; |
79 | 80 |
80 // Returns the sync id for the given password name, or sync_api::kInvalidId | 81 // Returns the sync id for the given password name, or sync_api::kInvalidId |
81 // if the password name is not associated to any sync id. | 82 // if the password name is not associated to any sync id. |
82 virtual int64 GetSyncIdFromChromeId(const std::string& node_id); | 83 virtual int64 GetSyncIdFromChromeId(const std::string& node_id) OVERRIDE; |
83 | 84 |
84 // Associates the given password name with the given sync id. | 85 // Associates the given password name with the given sync id. |
85 virtual void Associate(const std::string* node, int64 sync_id); | 86 virtual void Associate(const std::string* node, int64 sync_id) OVERRIDE; |
86 | 87 |
87 // Remove the association that corresponds to the given sync id. | 88 // Remove the association that corresponds to the given sync id. |
88 virtual void Disassociate(int64 sync_id); | 89 virtual void Disassociate(int64 sync_id) OVERRIDE; |
89 | 90 |
90 // Returns whether a node with the given permanent tag was found and update | 91 // Returns whether a node with the given permanent tag was found and update |
91 // |sync_id| with that node's id. | 92 // |sync_id| with that node's id. |
92 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id); | 93 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id); |
93 | 94 |
94 bool WriteToPasswordStore(const PasswordVector* new_passwords, | 95 bool WriteToPasswordStore(const PasswordVector* new_passwords, |
95 const PasswordVector* updated_passwords, | 96 const PasswordVector* updated_passwords, |
96 const PasswordVector* deleted_passwords); | 97 const PasswordVector* deleted_passwords); |
97 | 98 |
98 static std::string MakeTag(const webkit_glue::PasswordForm& password); | 99 static std::string MakeTag(const webkit_glue::PasswordForm& password); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 135 |
135 PasswordToSyncIdMap id_map_; | 136 PasswordToSyncIdMap id_map_; |
136 SyncIdToPasswordMap id_map_inverse_; | 137 SyncIdToPasswordMap id_map_inverse_; |
137 | 138 |
138 DISALLOW_COPY_AND_ASSIGN(PasswordModelAssociator); | 139 DISALLOW_COPY_AND_ASSIGN(PasswordModelAssociator); |
139 }; | 140 }; |
140 | 141 |
141 } // namespace browser_sync | 142 } // namespace browser_sync |
142 | 143 |
143 #endif // CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_ | 144 #endif // CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_ |
OLD | NEW |