Chromium Code Reviews| Index: chrome/browser/sync/glue/autofill_profile_change_processor.h |
| diff --git a/chrome/browser/sync/glue/autofill_profile_change_processor.h b/chrome/browser/sync/glue/autofill_profile_change_processor.h |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..3596cdada002d22867dbe6777aacd86224866398 |
| --- /dev/null |
| +++ b/chrome/browser/sync/glue/autofill_profile_change_processor.h |
| @@ -0,0 +1,119 @@ |
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +#ifndef CHROME_BROWSER_SYNC_GLUE_AUTOFILL_PROFILE_CHANGE_PROCESSOR_H_ |
| +#define CHROME_BROWSER_SYNC_GLUE_AUTOFILL_PROFILE_CHANGE_PROCESSOR_H_ |
| +#pragma once |
| +#include <vector> |
| +#include <string> |
| + |
| +#include "chrome/browser/autofill/autofill_profile.h" |
| +#include "chrome/browser/autofill/personal_data_manager.h" |
| +#include "chrome/browser/sync/engine/syncapi.h" |
| +#include "chrome/browser/sync/glue/autofill_profile_model_associator.h" |
| +#include "chrome/browser/sync/glue/change_processor.h" |
| +#include "chrome/browser/sync/unrecoverable_error_handler.h" |
| +#include "chrome/browser/webdata/autofill_change.h" |
| +#include "chrome/browser/webdata/web_database.h" |
| +#include "chrome/common/notification_observer.h" |
| +#include "chrome/common/notification_registrar.h" |
| +#include "chrome/common/notification_service.h" |
| +#include "chrome/common/notification_type.h" |
| + |
| +namespace browser_sync { |
| + |
| +class AutofillProfileChangeProcessor : public ChangeProcessor, |
| + public NotificationObserver { |
| + public: |
| + AutofillProfileChangeProcessor( |
| + AutofillProfileModelAssociator *model_associator, |
| + WebDatabase* web_database, |
| + PersonalDataManager* personal_data_manager, |
| + UnrecoverableErrorHandler* error_handler); |
| + |
| + virtual ~AutofillProfileChangeProcessor() {} |
| + |
| + // Virtual methods from changeprocessor class |
|
tim (not reviewing)
2010/12/10 22:16:02
nit - ChangeProcessor and add period.
lipalani
2010/12/11 00:12:36
Done.
|
| + virtual void ApplyChangesFromSyncModel( |
| + const sync_api::BaseTransaction *write_trans, |
| + const sync_api::SyncManager::ChangeRecord* changes, |
| + int change_count); |
| + |
| + virtual void CommitChangesFromSyncModel(); |
| + |
| + // Virtual method implemented for the observer class. |
| + virtual void Observe(NotificationType type, |
| + const NotificationSource& source, |
| + const NotificationDetails& details); |
| + |
| + |
| + static void WriteAutofillProfile(const AutoFillProfile& profile, |
| + sync_api::WriteNode* node); |
| + |
| + // This ensures that startobsrving gets called after stopobserving even |
|
tim (not reviewing)
2010/12/10 22:16:02
I like this. We should probably generalize it and
lipalani
2010/12/11 00:12:36
Done.
|
| + // if there is an early return in the function. |
| + class ScopedObserver { |
| + public: |
| + explicit ScopedObserver(AutofillProfileChangeProcessor* processor); |
| + ~ScopedObserver(); |
| + |
| + private: |
| + ScopedObserver() {} |
| + AutofillProfileChangeProcessor* processor_; |
| + }; |
| + |
| + protected: |
| + // Protected methods from ChangeProcessor. |
| + virtual void StartImpl(Profile* profile) {} |
| + virtual void StopImpl() {} |
| + |
| +struct AutofillProfileChangeRecord { |
|
tim (not reviewing)
2010/12/10 22:16:02
this should go in syncapi.
lipalani
2010/12/11 00:12:36
moved the definition to the .cc file. consistent w
|
| + sync_api::SyncManager::ChangeRecord::Action action_; |
| + int64 id_; |
| + sync_pb::AutofillProfileSpecifics profile_specifics_; |
| + AutofillProfileChangeRecord( |
| + sync_api::SyncManager::ChangeRecord::Action action, |
| + int64 id, |
| + const sync_pb::AutofillProfileSpecifics profile_specifics) |
| + : action_(action), |
| + id_(id), |
| + profile_specifics_(profile_specifics) {} |
| +}; |
| + std::vector<AutofillProfileChangeRecord> autofill_changes_; |
| + |
| + virtual void AddAutofillProfileSyncNode(sync_api::WriteTransaction* trans, |
| + sync_api::BaseNode& autofill_profile_root, |
| + const AutoFillProfile& profile); |
| + |
| + void ActOnChange(AutofillProfileChangeGUID* change, |
| + sync_api::WriteTransaction* trans, |
| + sync_api::ReadNode& autofill_root); |
| + |
| + private: |
| + |
| + void StartObserving(); |
| + void StopObserving(); |
| + |
| + void PostOptimisticRefreshTask(); |
| + |
| + void ApplyAutofillProfileChange( |
| + sync_api::SyncManager::ChangeRecord::Action action, |
| + const sync_pb::AutofillProfileSpecifics& profile, |
| + int64 sync_id); |
| + |
| + void RemoveSyncNode( |
| + const std::string& guid, sync_api::WriteTransaction *trans); |
| + |
| + AutofillProfileModelAssociator* model_associator_; |
| + bool observing_; |
| + |
| + WebDatabase* web_database_; |
| + PersonalDataManager* personal_data_; |
| + NotificationRegistrar notification_registrar_; |
| +}; |
| + |
| +} // namespace browser_sync |
| + |
| +#endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_PROFILE_CHANGE_PROCESSOR_H_ |
| + |
| + |