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

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

Issue 7967024: Profile shouldn't own PersonalDataManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addresses isherman #11 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SYNC_GLUE_AUTOFILL_MODEL_ASSOCIATOR_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_AUTOFILL_MODEL_ASSOCIATOR_H_
6 #define CHROME_BROWSER_SYNC_GLUE_AUTOFILL_MODEL_ASSOCIATOR_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_AUTOFILL_MODEL_ASSOCIATOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
17 #include "chrome/browser/autofill/personal_data_manager.h"
18 #include "chrome/browser/sync/glue/model_associator.h" 16 #include "chrome/browser/sync/glue/model_associator.h"
19 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" 17 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h"
20 #include "chrome/browser/webdata/autofill_entry.h" 18 #include "chrome/browser/webdata/autofill_entry.h"
21 19
22 class AutofillProfile; 20 class AutofillProfile;
23 21
22 class Profile;
24 class ProfileSyncService; 23 class ProfileSyncService;
25 class WebDatabase; 24 class WebDatabase;
26 25
27 namespace sync_api { 26 namespace sync_api {
28 class ReadNode; 27 class ReadNode;
29 class WriteTransaction; 28 class WriteTransaction;
30 } 29 }
31 30
32 namespace browser_sync { 31 namespace browser_sync {
33 32
34 class AutofillChangeProcessor; 33 class AutofillChangeProcessor;
35 class UnrecoverableErrorHandler; 34 class UnrecoverableErrorHandler;
36 35
37 extern const char kAutofillTag[]; 36 extern const char kAutofillTag[];
38 extern const char kAutofillProfileNamespaceTag[]; 37 extern const char kAutofillProfileNamespaceTag[];
39 extern const char kAutofillEntryNamespaceTag[]; 38 extern const char kAutofillEntryNamespaceTag[];
40 39
41 // Contains all model association related logic: 40 // Contains all model association related logic:
42 // * Algorithm to associate autofill model and sync model. 41 // * Algorithm to associate autofill model and sync model.
43 // We do not check if we have local data before this run; we always 42 // We do not check if we have local data before this run; we always
44 // merge and sync. 43 // merge and sync.
45 class AutofillModelAssociator 44 class AutofillModelAssociator
46 : public PerDataTypeAssociatorInterface<std::string, std::string> { 45 : public PerDataTypeAssociatorInterface<std::string, std::string> {
47 public: 46 public:
48 static syncable::ModelType model_type() { return syncable::AUTOFILL; } 47 static syncable::ModelType model_type() { return syncable::AUTOFILL; }
49 AutofillModelAssociator(ProfileSyncService* sync_service, 48 AutofillModelAssociator(ProfileSyncService* sync_service,
50 WebDatabase* web_database, 49 WebDatabase* web_database,
51 PersonalDataManager* data_manager); 50 Profile* profile);
52 virtual ~AutofillModelAssociator(); 51 virtual ~AutofillModelAssociator();
53 52
54 // PerDataTypeAssociatorInterface implementation. 53 // PerDataTypeAssociatorInterface implementation.
55 // 54 //
56 // Iterates through the sync model looking for matched pairs of items. 55 // Iterates through the sync model looking for matched pairs of items.
57 virtual bool AssociateModels(SyncError* error); 56 virtual bool AssociateModels(SyncError* error);
58 57
59 // Clears all associations. 58 // Clears all associations.
60 virtual bool DisassociateModels(SyncError* error); 59 virtual bool DisassociateModels(SyncError* error);
61 60
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 DataBundle* bundle, 160 DataBundle* bundle,
162 const sync_api::ReadNode& node, 161 const sync_api::ReadNode& node,
163 const std::vector<AutofillProfile*>& all_profiles_from_db); 162 const std::vector<AutofillProfile*>& all_profiles_from_db);
164 163
165 // Called at various points in model association to determine if the 164 // Called at various points in model association to determine if the
166 // user requested an abort. 165 // user requested an abort.
167 bool IsAbortPending(); 166 bool IsAbortPending();
168 167
169 ProfileSyncService* sync_service_; 168 ProfileSyncService* sync_service_;
170 WebDatabase* web_database_; 169 WebDatabase* web_database_;
171 PersonalDataManager* personal_data_; 170 Profile* profile_;
172 int64 autofill_node_id_; 171 int64 autofill_node_id_;
173 172
174 AutofillToSyncIdMap id_map_; 173 AutofillToSyncIdMap id_map_;
175 SyncIdToAutofillMap id_map_inverse_; 174 SyncIdToAutofillMap id_map_inverse_;
176 175
177 // Abort association pending flag and lock. If this is set to true 176 // Abort association pending flag and lock. If this is set to true
178 // (via the AbortAssociation method), return from the 177 // (via the AbortAssociation method), return from the
179 // AssociateModels method as soon as possible. 178 // AssociateModels method as soon as possible.
180 base::Lock abort_association_pending_lock_; 179 base::Lock abort_association_pending_lock_;
181 bool abort_association_pending_; 180 bool abort_association_pending_;
182 181
183 DISALLOW_COPY_AND_ASSIGN(AutofillModelAssociator); 182 DISALLOW_COPY_AND_ASSIGN(AutofillModelAssociator);
184 }; 183 };
185 184
186 } // namespace browser_sync 185 } // namespace browser_sync
187 186
188 #endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_MODEL_ASSOCIATOR_H_ 187 #endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_MODEL_ASSOCIATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698