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

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

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

Powered by Google App Engine
This is Rietveld 408576698