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

Side by Side Diff: chrome/browser/sync/glue/password_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_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>
(...skipping 10 matching lines...) Expand all
21 class MessageLoop; 21 class MessageLoop;
22 class PasswordStore; 22 class PasswordStore;
23 class ProfileSyncService; 23 class ProfileSyncService;
24 24
25 namespace webkit { 25 namespace webkit {
26 namespace forms { 26 namespace forms {
27 struct PasswordForm; 27 struct PasswordForm;
28 } 28 }
29 } 29 }
30 30
31 namespace csync { 31 namespace syncer {
32 class WriteNode; 32 class WriteNode;
33 class WriteTransaction; 33 class WriteTransaction;
34 } 34 }
35 35
36 namespace browser_sync { 36 namespace browser_sync {
37 37
38 extern const char kPasswordTag[]; 38 extern const char kPasswordTag[];
39 39
40 // Contains all model association related logic: 40 // Contains all model association related logic:
41 // * Algorithm to associate password model and sync model. 41 // * Algorithm to associate password model and sync model.
42 // * Persisting model associations and loading them back. 42 // * Persisting model associations and loading them back.
43 // We do not check if we have local data before this runs; we always 43 // We do not check if we have local data before this runs; we always
44 // merge and sync. 44 // merge and sync.
45 class PasswordModelAssociator 45 class PasswordModelAssociator
46 : public PerDataTypeAssociatorInterface<std::string, std::string> { 46 : public PerDataTypeAssociatorInterface<std::string, std::string> {
47 public: 47 public:
48 typedef std::vector<webkit::forms::PasswordForm> PasswordVector; 48 typedef std::vector<webkit::forms::PasswordForm> PasswordVector;
49 49
50 static syncable::ModelType model_type() { return syncable::PASSWORDS; } 50 static syncable::ModelType model_type() { return syncable::PASSWORDS; }
51 PasswordModelAssociator(ProfileSyncService* sync_service, 51 PasswordModelAssociator(ProfileSyncService* sync_service,
52 PasswordStore* password_store, 52 PasswordStore* password_store,
53 DataTypeErrorHandler* error_handler); 53 DataTypeErrorHandler* error_handler);
54 virtual ~PasswordModelAssociator(); 54 virtual ~PasswordModelAssociator();
55 55
56 // PerDataTypeAssociatorInterface implementation. 56 // PerDataTypeAssociatorInterface implementation.
57 // 57 //
58 // Iterates through the sync model looking for matched pairs of items. 58 // Iterates through the sync model looking for matched pairs of items.
59 virtual csync::SyncError AssociateModels() OVERRIDE; 59 virtual syncer::SyncError AssociateModels() OVERRIDE;
60 60
61 // Delete all password nodes. 61 // Delete all password nodes.
62 bool DeleteAllNodes(csync::WriteTransaction* trans); 62 bool DeleteAllNodes(syncer::WriteTransaction* trans);
63 63
64 // Clears all associations. 64 // Clears all associations.
65 virtual csync::SyncError DisassociateModels() OVERRIDE; 65 virtual syncer::SyncError DisassociateModels() OVERRIDE;
66 66
67 // The has_nodes out param is true if the sync model has nodes other 67 // The has_nodes out param is true if the sync model has nodes other
68 // than the permanent tagged nodes. 68 // than the permanent tagged nodes.
69 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) OVERRIDE; 69 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) OVERRIDE;
70 70
71 // See ModelAssociator interface. 71 // See ModelAssociator interface.
72 virtual void AbortAssociation() OVERRIDE; 72 virtual void AbortAssociation() OVERRIDE;
73 73
74 // See ModelAssociator interface. 74 // See ModelAssociator interface.
75 virtual bool CryptoReadyIfNecessary() OVERRIDE; 75 virtual bool CryptoReadyIfNecessary() OVERRIDE;
76 76
77 // Not implemented. 77 // Not implemented.
78 virtual const std::string* GetChromeNodeFromSyncId(int64 sync_id) OVERRIDE; 78 virtual const std::string* GetChromeNodeFromSyncId(int64 sync_id) OVERRIDE;
79 79
80 // Not implemented. 80 // Not implemented.
81 virtual bool InitSyncNodeFromChromeId(const std::string& node_id, 81 virtual bool InitSyncNodeFromChromeId(const std::string& node_id,
82 csync::BaseNode* sync_node) OVERRIDE; 82 syncer::BaseNode* sync_node) OVERRIDE;
83 83
84 // Returns the sync id for the given password name, or csync::kInvalidId 84 // Returns the sync id for the given password name, or syncer::kInvalidId
85 // if the password name is not associated to any sync id. 85 // if the password name is not associated to any sync id.
86 virtual int64 GetSyncIdFromChromeId(const std::string& node_id) OVERRIDE; 86 virtual int64 GetSyncIdFromChromeId(const std::string& node_id) OVERRIDE;
87 87
88 // Associates the given password name with the given sync id. 88 // Associates the given password name with the given sync id.
89 virtual void Associate(const std::string* node, int64 sync_id) OVERRIDE; 89 virtual void Associate(const std::string* node, int64 sync_id) OVERRIDE;
90 90
91 // Remove the association that corresponds to the given sync id. 91 // Remove the association that corresponds to the given sync id.
92 virtual void Disassociate(int64 sync_id) OVERRIDE; 92 virtual void Disassociate(int64 sync_id) OVERRIDE;
93 93
94 // Returns whether a node with the given permanent tag was found and update 94 // Returns whether a node with the given permanent tag was found and update
95 // |sync_id| with that node's id. 95 // |sync_id| with that node's id.
96 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id); 96 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id);
97 97
98 csync::SyncError WriteToPasswordStore(const PasswordVector* new_passwords, 98 syncer::SyncError WriteToPasswordStore(const PasswordVector* new_passwords,
99 const PasswordVector* updated_passwords, 99 const PasswordVector* updated_passwords,
100 const PasswordVector* deleted_passwords); 100 const PasswordVector* deleted_passwords);
101 101
102 static std::string MakeTag(const webkit::forms::PasswordForm& password); 102 static std::string MakeTag(const webkit::forms::PasswordForm& password);
103 static std::string MakeTag(const sync_pb::PasswordSpecificsData& password); 103 static std::string MakeTag(const sync_pb::PasswordSpecificsData& password);
104 static std::string MakeTag(const std::string& origin_url, 104 static std::string MakeTag(const std::string& origin_url,
105 const std::string& username_element, 105 const std::string& username_element,
106 const std::string& username_value, 106 const std::string& username_value,
107 const std::string& password_element, 107 const std::string& password_element,
108 const std::string& signon_realm); 108 const std::string& signon_realm);
109 109
110 static void CopyPassword(const sync_pb::PasswordSpecificsData& password, 110 static void CopyPassword(const sync_pb::PasswordSpecificsData& password,
111 webkit::forms::PasswordForm* new_password); 111 webkit::forms::PasswordForm* new_password);
112 112
113 static bool MergePasswords(const sync_pb::PasswordSpecificsData& password, 113 static bool MergePasswords(const sync_pb::PasswordSpecificsData& password,
114 const webkit::forms::PasswordForm& password_form, 114 const webkit::forms::PasswordForm& password_form,
115 webkit::forms::PasswordForm* new_password); 115 webkit::forms::PasswordForm* new_password);
116 static void WriteToSyncNode(const webkit::forms::PasswordForm& password_form, 116 static void WriteToSyncNode(const webkit::forms::PasswordForm& password_form,
117 csync::WriteNode* node); 117 syncer::WriteNode* node);
118 118
119 // Called at various points in model association to determine if the 119 // Called at various points in model association to determine if the
120 // user requested an abort. 120 // user requested an abort.
121 bool IsAbortPending(); 121 bool IsAbortPending();
122 122
123 private: 123 private:
124 typedef std::map<std::string, int64> PasswordToSyncIdMap; 124 typedef std::map<std::string, int64> PasswordToSyncIdMap;
125 typedef std::map<int64, std::string> SyncIdToPasswordMap; 125 typedef std::map<int64, std::string> SyncIdToPasswordMap;
126 126
127 ProfileSyncService* sync_service_; 127 ProfileSyncService* sync_service_;
(...skipping 11 matching lines...) Expand all
139 PasswordToSyncIdMap id_map_; 139 PasswordToSyncIdMap id_map_;
140 SyncIdToPasswordMap id_map_inverse_; 140 SyncIdToPasswordMap id_map_inverse_;
141 DataTypeErrorHandler* error_handler_; 141 DataTypeErrorHandler* error_handler_;
142 142
143 DISALLOW_COPY_AND_ASSIGN(PasswordModelAssociator); 143 DISALLOW_COPY_AND_ASSIGN(PasswordModelAssociator);
144 }; 144 };
145 145
146 } // namespace browser_sync 146 } // namespace browser_sync
147 147
148 #endif // CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_ 148 #endif // CHROME_BROWSER_SYNC_GLUE_PASSWORD_MODEL_ASSOCIATOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/password_data_type_controller.cc ('k') | chrome/browser/sync/glue/password_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698