Chromium Code Reviews| Index: chrome/browser/password_manager/password_syncable_service.h |
| diff --git a/chrome/browser/password_manager/password_syncable_service.h b/chrome/browser/password_manager/password_syncable_service.h |
| index dd32b2c323ab774c14fe583990b7c3724055809e..f0fb831517ec92f7dbe36efb06f27cc0f597f4fb 100644 |
| --- a/chrome/browser/password_manager/password_syncable_service.h |
| +++ b/chrome/browser/password_manager/password_syncable_service.h |
| @@ -9,6 +9,7 @@ |
| #include <vector> |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/memory/scoped_vector.h" |
| #include "sync/api/sync_change.h" |
| #include "sync/api/sync_data.h" |
| #include "sync/api/sync_error.h" |
| @@ -60,15 +61,55 @@ class PasswordSyncableService : public syncer::SyncableService { |
| const std::string& password_element, |
| const std::string& signon_realm); |
| + protected: |
| + // Notifies password store of a change that was performed by sync. |
| + // Virtual so tests can override. |
| + virtual void NotifyPasswordStoreOfLoginChanges(); |
| + |
| private: |
| typedef std::vector<autofill::PasswordForm*> PasswordForms; |
| + typedef std::map<std::string, autofill::PasswordForm*> |
| + PasswordEntryMap; |
| - // Use the |PasswordStore| APIs to add and update entries. |
| - void WriteToPasswordStore(PasswordForms* new_entries, |
| - PasswordForms* udpated_entries); |
| + friend class PasswordStoreDataVerifier; |
| + friend class TestSyncChangeProcessor; |
| - // Converts the |PasswordForm| to |SyncData| suitable for syncing. |
| - syncer::SyncData CreateSyncData(const autofill::PasswordForm& password); |
| + // Use the |PasswordStore| APIs to add and update entries. |
| + void WriteToPasswordStore(const PasswordForms& new_entries, |
| + const PasswordForms& updated_entries); |
| + |
| + // Checks if |data|, the entry in sync db, needs to be created or updated |
| + // in the passwords db. Depending on what action needs to be performed the |
|
Ilya Sherman
2013/12/05 07:01:54
nit: "needs to be performed the" -> "needs to be p
|
| + // entry may be added to |new_entries| or |updated_entries|. If the item is |
|
Ilya Sherman
2013/12/05 07:01:54
nit: "to |new_entries| or |updated_entries|" -> "t
|
| + // identical to an entry in passwords db, no action is performed. If an |
|
Ilya Sherman
2013/12/05 07:01:54
nit: "in passwords db" -> "in the passwords db"
|
| + // item needs to be updated in the sync database then the item is also |
|
Ilya Sherman
2013/12/05 07:01:54
nit: Might as well be consistent about "database"
Ilya Sherman
2013/12/05 07:01:54
nit: "in the sync database then" -> "in the sync d
|
| + // added to |updated_local_entries| list. If |data|'s tag is identical to an |
| + // entry's tag in |umatched_data_from_password_db| then that entry |
|
Ilya Sherman
2013/12/05 07:01:54
nit: Spurious leading whitespace.
|
| + // will be removed from |umatched_data_from_password_db|. |
| + void CreateOrUpdateEntry( |
| + const syncer::SyncData& data, |
| + PasswordEntryMap* umatched_data_from_password_db, |
| + ScopedVector<autofill::PasswordForm>* new_entries, |
| + ScopedVector<autofill::PasswordForm>* updated_entries, |
| + syncer::SyncChangeList* updated_local_entries); |
| + |
| + // Converts the |password| into a SyncData object. |
| + static syncer::SyncData CreateSyncData( |
| + const autofill::PasswordForm& password); |
| + |
| + // Extracts the |PasswordForm| data from sync's protobuffer |
| + // format, |PasswordSpecificsData|. |
| + static void ExtractPasswordFromSpecifics( |
| + const sync_pb::PasswordSpecificsData& password, |
| + autofill::PasswordForm* new_password); |
| + |
| + // Merges the local and sync passwords and outputs the entry into |
| + // |new_password_form|. Returns true if the local and the sync |
| + // passwords differ. Returns false if they are identical. |
| + bool MergeLocalAndSyncPasswords( |
| + const sync_pb::PasswordSpecificsData& password_specifics, |
| + const autofill::PasswordForm& password_form, |
| + autofill::PasswordForm* new_password_form); |
| // The factory that creates sync errors. |SyncError| has rich data |
| // suitable for debugging. |