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

Side by Side Diff: chrome/browser/sync/glue/autofill_profile_change_processor.h

Issue 7819002: Migrate AutofillProfile sync to new API. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SYNC_GLUE_AUTOFILL_PROFILE_CHANGE_PROCESSOR_H_
6 #define CHROME_BROWSER_SYNC_GLUE_AUTOFILL_PROFILE_CHANGE_PROCESSOR_H_
7 #pragma once
8 #include <string>
9 #include <vector>
10
11 #include "chrome/browser/autofill/autofill_profile.h"
12 #include "chrome/browser/autofill/personal_data_manager.h"
13 #include "chrome/browser/sync/glue/autofill_profile_model_associator.h"
14 #include "chrome/browser/sync/glue/change_processor.h"
15 #include "chrome/browser/sync/internal_api/sync_manager.h"
16 #include "chrome/browser/sync/unrecoverable_error_handler.h"
17 #include "chrome/browser/webdata/autofill_change.h"
18 #include "chrome/browser/webdata/web_database.h"
19 #include "content/common/content_notification_types.h"
20 #include "content/common/notification_observer.h"
21 #include "content/common/notification_registrar.h"
22 #include "content/common/notification_service.h"
23
24 namespace sync_api {
25 class ReadNode;
26 class WriteNode;
27 class WriteTransaction;
28 } // namespace sync_api
29
30 namespace browser_sync {
31
32 class AutofillProfileChangeProcessor : public ChangeProcessor,
33 public NotificationObserver {
34 public:
35 AutofillProfileChangeProcessor(
36 AutofillProfileModelAssociator *model_associator,
37 WebDatabase* web_database,
38 PersonalDataManager* personal_data_manager,
39 UnrecoverableErrorHandler* error_handler);
40
41 virtual ~AutofillProfileChangeProcessor();
42
43 // Virtual methods from ChangeProcessor class.
44 virtual void ApplyChangesFromSyncModel(
45 const sync_api::BaseTransaction *write_trans,
46 const sync_api::SyncManager::ChangeRecord* changes,
47 int change_count);
48
49 virtual void CommitChangesFromSyncModel();
50
51 // Virtual method implemented for the observer class.
52 virtual void Observe(int type,
53 const NotificationSource& source,
54 const NotificationDetails& details);
55
56
57 static void WriteAutofillProfile(const AutofillProfile& profile,
58 sync_api::WriteNode* node);
59
60 protected:
61 // Protected methods from ChangeProcessor.
62 virtual void StartImpl(Profile* profile) {}
63 virtual void StopImpl() {}
64
65 struct AutofillProfileChangeRecord {
66 sync_api::SyncManager::ChangeRecord::Action action_;
67 int64 id_;
68 sync_pb::AutofillProfileSpecifics profile_specifics_;
69 AutofillProfileChangeRecord(
70 sync_api::SyncManager::ChangeRecord::Action action,
71 int64 id,
72 const sync_pb::AutofillProfileSpecifics& profile_specifics)
73 : action_(action),
74 id_(id),
75 profile_specifics_(profile_specifics) {}
76 };
77
78 std::vector<AutofillProfileChangeRecord> autofill_changes_;
79
80 virtual void AddAutofillProfileSyncNode(sync_api::WriteTransaction* trans,
81 sync_api::BaseNode& autofill_profile_root,
82 const AutofillProfile& profile);
83
84 void ActOnChange(AutofillProfileChange* change,
85 sync_api::WriteTransaction* trans,
86 sync_api::ReadNode& autofill_root);
87
88 private:
89 friend class ScopedStopObserving<AutofillProfileChangeProcessor>;
90
91 void StartObserving();
92 void StopObserving();
93
94 void PostOptimisticRefreshTask();
95
96 void ApplyAutofillProfileChange(
97 sync_api::SyncManager::ChangeRecord::Action action,
98 const sync_pb::AutofillProfileSpecifics& profile,
99 int64 sync_id);
100
101 void RemoveSyncNode(
102 const std::string& guid, sync_api::WriteTransaction *trans);
103
104 AutofillProfileModelAssociator* model_associator_;
105 bool observing_;
106
107 WebDatabase* web_database_;
108 PersonalDataManager* personal_data_;
109 NotificationRegistrar notification_registrar_;
110 };
111
112 } // namespace browser_sync
113
114 #endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_PROFILE_CHANGE_PROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698