Commit 9db0a1d0 authored by vasilii's avatar vasilii Committed by Commit bot
parent 2fe091b1
...@@ -48,6 +48,7 @@ class MockPasswordStore : public PasswordStore { ...@@ -48,6 +48,7 @@ class MockPasswordStore : public PasswordStore {
bool(std::vector<autofill::PasswordForm*>*)); bool(std::vector<autofill::PasswordForm*>*));
MOCK_METHOD1(FillBlacklistLogins, MOCK_METHOD1(FillBlacklistLogins,
bool(std::vector<autofill::PasswordForm*>*)); bool(std::vector<autofill::PasswordForm*>*));
MOCK_METHOD1(NotifyLoginsChanged, void(const PasswordStoreChangeList&));
PasswordStoreSync* GetSyncInterface() { return this; } PasswordStoreSync* GetSyncInterface() { return this; }
......
...@@ -34,14 +34,17 @@ namespace password_manager { ...@@ -34,14 +34,17 @@ namespace password_manager {
class PasswordStoreSync; class PasswordStoreSync;
// The implementation of the SyncableService API for passwords.
class PasswordSyncableService : public syncer::SyncableService, class PasswordSyncableService : public syncer::SyncableService,
public base::NonThreadSafe { public base::NonThreadSafe {
public: public:
// |PasswordSyncableService| is owned by |PasswordStore|. // Since the constructed |PasswordSyncableService| is typically owned by the
// |password_store|, the constructor doesn't take ownership of the
// |password_store|.
explicit PasswordSyncableService(PasswordStoreSync* password_store); explicit PasswordSyncableService(PasswordStoreSync* password_store);
virtual ~PasswordSyncableService(); virtual ~PasswordSyncableService();
// syncer::SyncableServiceImplementations // syncer::SyncableService:
virtual syncer::SyncMergeResult MergeDataAndStartSyncing( virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
syncer::ModelType type, syncer::ModelType type,
const syncer::SyncDataList& initial_sync_data, const syncer::SyncDataList& initial_sync_data,
...@@ -54,11 +57,11 @@ class PasswordSyncableService : public syncer::SyncableService, ...@@ -54,11 +57,11 @@ class PasswordSyncableService : public syncer::SyncableService,
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
const syncer::SyncChangeList& change_list) OVERRIDE; const syncer::SyncChangeList& change_list) OVERRIDE;
// Notifies sync of changes to the password database. // Notifies the Sync engine of changes to the password database.
void ActOnPasswordStoreChanges(const PasswordStoreChangeList& changes); void ActOnPasswordStoreChanges(const PasswordStoreChangeList& changes);
// Provides a StartSyncFlare to the SyncableService. See // Provides a StartSyncFlare to the SyncableService. See
// sync_start_util for more. // chrome/browser/sync/glue/sync_start_util.h for more.
void InjectStartSyncFlare( void InjectStartSyncFlare(
const syncer::SyncableService::StartSyncFlare& flare); const syncer::SyncableService::StartSyncFlare& flare);
...@@ -67,49 +70,49 @@ class PasswordSyncableService : public syncer::SyncableService, ...@@ -67,49 +70,49 @@ class PasswordSyncableService : public syncer::SyncableService,
// Map from password sync tag to password form. // Map from password sync tag to password form.
typedef std::map<std::string, autofill::PasswordForm*> PasswordEntryMap; typedef std::map<std::string, autofill::PasswordForm*> PasswordEntryMap;
// Helper function to retrieve the entries from password db and fill both // The type of PasswordStoreSync::AddLoginImpl,
// |password_entries| and |passwords_entry_map|. |passwords_entry_map| can be // PasswordStoreSync::UpdateLoginImpl and PasswordStoreSync::RemoveLoginImpl.
// NULL. typedef PasswordStoreChangeList(PasswordStoreSync::*DatabaseOperation)(
const autofill::PasswordForm& form);
struct SyncEntries;
// Retrieves the entries from password db and fills both |password_entries|
// and |passwords_entry_map|. |passwords_entry_map| can be NULL.
bool ReadFromPasswordStore( bool ReadFromPasswordStore(
ScopedVector<autofill::PasswordForm>* password_entries, ScopedVector<autofill::PasswordForm>* password_entries,
PasswordEntryMap* passwords_entry_map) const; PasswordEntryMap* passwords_entry_map) const;
// Uses the |PasswordStore| APIs to change entries. // Uses the |PasswordStore| APIs to change entries.
void WriteToPasswordStore(const PasswordForms& new_entries, void WriteToPasswordStore(const SyncEntries& entries);
const PasswordForms& updated_entries,
const PasswordForms& deleted_entries); // Examines |data|, an entry in sync db, and updates |sync_entries| or
// |updated_db_entries| accordingly. An element is removed from
// Notifies password store of a change that was performed by sync. // |unmatched_data_from_password_db| if its tag is identical to |data|'s.
// Virtual so tests can override.
virtual void NotifyPasswordStoreOfLoginChanges(
const PasswordStoreChangeList& changes);
// 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
// entry may be added to |new_sync_entries| or to |updated_sync_entries|. If
// the item is identical to an entry in the passwords db, no action is
// performed. If an item needs to be updated in the sync db, then the item is
// also added to |updated_db_entries| list. If |data|'s tag is identical to
// an entry's tag in |umatched_data_from_password_db| then that entry will be
// removed from |umatched_data_from_password_db|.
void CreateOrUpdateEntry( void CreateOrUpdateEntry(
const syncer::SyncData& data, const syncer::SyncData& data,
PasswordEntryMap* umatched_data_from_password_db, PasswordEntryMap* unmatched_data_from_password_db,
ScopedVector<autofill::PasswordForm>* new_sync_entries, SyncEntries* sync_entries,
ScopedVector<autofill::PasswordForm>* updated_sync_entries,
syncer::SyncChangeList* updated_db_entries); syncer::SyncChangeList* updated_db_entries);
// Calls |operation| for each element in |entries| and appends the changes to
// |all_changes|.
void WriteEntriesToDatabase(
DatabaseOperation operation,
const PasswordForms& entries,
PasswordStoreChangeList* all_changes);
// The factory that creates sync errors. |SyncError| has rich data // The factory that creates sync errors. |SyncError| has rich data
// suitable for debugging. // suitable for debugging.
scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_; scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_;
// |SyncProcessor| will mirror the |PasswordStore| changes in the sync db. // |sync_processor_| will mirror the |PasswordStore| changes in the sync db.
scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
// The password store that adds/updates/deletes password entries. // The password store that adds/updates/deletes password entries. Not owned.
PasswordStoreSync* const password_store_; PasswordStoreSync* const password_store_;
// A signal to start sync as soon as possible. // A signal activated by this class to start sync as soon as possible.
syncer::SyncableService::StartSyncFlare flare_; syncer::SyncableService::StartSyncFlare flare_;
// True if processing sync changes is in progress. // True if processing sync changes is in progress.
...@@ -118,17 +121,6 @@ class PasswordSyncableService : public syncer::SyncableService, ...@@ -118,17 +121,6 @@ class PasswordSyncableService : public syncer::SyncableService,
DISALLOW_COPY_AND_ASSIGN(PasswordSyncableService); DISALLOW_COPY_AND_ASSIGN(PasswordSyncableService);
}; };
// Converts the |password| into a SyncData object.
syncer::SyncData SyncDataFromPassword(const autofill::PasswordForm& password);
// Extracts the |PasswordForm| data from sync's protobuffer format.
void PasswordFromSpecifics(const sync_pb::PasswordSpecificsData& password,
autofill::PasswordForm* new_password);
// Returns the unique tag that will serve as the sync identifier for the
// |password| entry.
std::string MakePasswordSyncTag(const sync_pb::PasswordSpecificsData& password);
} // namespace password_manager } // namespace password_manager
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_SYNCABLE_SERVICE_H__ #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_SYNCABLE_SERVICE_H__
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment