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

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

Issue 7967024: Profile shouldn't own PersonalDataManager (Closed) Base URL: svn://svn.chromium.org/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
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 #ifndef CHROME_BROWSER_SYNC_GLUE_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ 4 #ifndef CHROME_BROWSER_SYNC_GLUE_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_
5 #define CHROME_BROWSER_SYNC_GLUE_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ 5 #define CHROME_BROWSER_SYNC_GLUE_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_
6 #pragma once 6 #pragma once
7 7
8 #include <map> 8 #include <map>
9 #include <set>
10 #include <string> 9 #include <string>
11 #include <vector> 10 #include <vector>
12 11
13 #include "base/basictypes.h" 12 #include "base/basictypes.h"
14 #include "base/memory/ref_counted.h" 13 #include "base/memory/scoped_vector.h"
15 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
16 #include "base/threading/non_thread_safe.h" 15 #include "base/threading/non_thread_safe.h"
17 #include "chrome/browser/autofill/personal_data_manager.h"
18 #include "chrome/browser/sync/api/sync_change.h" 16 #include "chrome/browser/sync/api/sync_change.h"
19 #include "chrome/browser/sync/api/sync_data.h" 17 #include "chrome/browser/sync/api/sync_data.h"
20 #include "chrome/browser/sync/api/sync_error.h" 18 #include "chrome/browser/sync/api/sync_error.h"
21 #include "chrome/browser/sync/api/syncable_service.h" 19 #include "chrome/browser/sync/api/syncable_service.h"
22 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" 20 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h"
23 #include "chrome/browser/webdata/autofill_change.h" 21 #include "chrome/browser/webdata/autofill_change.h"
24 #include "chrome/browser/webdata/autofill_entry.h" 22 #include "chrome/browser/webdata/autofill_entry.h"
25 #include "content/common/content_notification_types.h" 23 #include "content/common/content_notification_types.h"
26 #include "content/common/notification_observer.h" 24 #include "content/common/notification_observer.h"
27 #include "content/common/notification_registrar.h" 25 #include "content/common/notification_registrar.h"
(...skipping 12 matching lines...) Expand all
40 38
41 // The sync implementation for AutofillProfiles. 39 // The sync implementation for AutofillProfiles.
42 // MergeDataAndStartSyncing() called first, it does cloud->local and 40 // MergeDataAndStartSyncing() called first, it does cloud->local and
43 // local->cloud syncs. Then for each cloud change we receive 41 // local->cloud syncs. Then for each cloud change we receive
44 // ProcessSyncChanges() and for each local change Observe() is called. 42 // ProcessSyncChanges() and for each local change Observe() is called.
45 class AutofillProfileSyncableService 43 class AutofillProfileSyncableService
46 : public SyncableService, 44 : public SyncableService,
47 public NotificationObserver, 45 public NotificationObserver,
48 public base::NonThreadSafe { 46 public base::NonThreadSafe {
49 public: 47 public:
50 AutofillProfileSyncableService(WebDatabase* web_database, 48 AutofillProfileSyncableService(WebDatabase* web_database, Profile* profile);
51 PersonalDataManager* data_manager,
52 Profile* profile);
53 virtual ~AutofillProfileSyncableService(); 49 virtual ~AutofillProfileSyncableService();
54 50
55 static syncable::ModelType model_type() { return syncable::AUTOFILL_PROFILE; } 51 static syncable::ModelType model_type() { return syncable::AUTOFILL_PROFILE; }
56 52
57 // SyncableService implementation. 53 // SyncableService implementation.
58 virtual SyncError MergeDataAndStartSyncing( 54 virtual SyncError MergeDataAndStartSyncing(
59 syncable::ModelType type, 55 syncable::ModelType type,
60 const SyncDataList& initial_sync_data, 56 const SyncDataList& initial_sync_data,
61 SyncChangeProcessor* sync_processor) OVERRIDE; 57 SyncChangeProcessor* sync_processor) OVERRIDE;
62 virtual void StopSyncing(syncable::ModelType type) OVERRIDE; 58 virtual void StopSyncing(syncable::ModelType type) OVERRIDE;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // Creates SyncData based on supplied |profile|. 126 // Creates SyncData based on supplied |profile|.
131 static SyncData CreateData(const AutofillProfile& profile); 127 static SyncData CreateData(const AutofillProfile& profile);
132 128
133 // For unit-tests. 129 // For unit-tests.
134 AutofillProfileSyncableService(); 130 AutofillProfileSyncableService();
135 void set_sync_processor(SyncChangeProcessor* sync_processor) { 131 void set_sync_processor(SyncChangeProcessor* sync_processor) {
136 sync_processor_ = sync_processor; 132 sync_processor_ = sync_processor;
137 } 133 }
138 134
139 WebDatabase* web_database_; 135 WebDatabase* web_database_;
140 PersonalDataManager* personal_data_; 136 Profile* profile_;
141 NotificationRegistrar notification_registrar_; 137 NotificationRegistrar notification_registrar_;
142 138
143 // Cached Autofill profiles. *Warning* deleted profiles are still in the 139 // Cached Autofill profiles. *Warning* deleted profiles are still in the
144 // vector - use the |profiles_map_| to iterate through actual profiles. 140 // vector - use the |profiles_map_| to iterate through actual profiles.
145 ScopedVector<AutofillProfile> profiles_; 141 ScopedVector<AutofillProfile> profiles_;
146 GUIDToProfileMap profiles_map_; 142 GUIDToProfileMap profiles_map_;
147 143
148 SyncChangeProcessor* sync_processor_; 144 SyncChangeProcessor* sync_processor_;
149 145
150 DISALLOW_COPY_AND_ASSIGN(AutofillProfileSyncableService); 146 DISALLOW_COPY_AND_ASSIGN(AutofillProfileSyncableService);
151 }; 147 };
152 148
153 // This object is used in unit-tests as well, so it defined here. 149 // This object is used in unit-tests as well, so it defined here.
154 struct AutofillProfileSyncableService::DataBundle { 150 struct AutofillProfileSyncableService::DataBundle {
155 DataBundle(); 151 DataBundle();
156 ~DataBundle(); 152 ~DataBundle();
157 153
158 std::vector<std::string> profiles_to_delete; 154 std::vector<std::string> profiles_to_delete;
159 std::vector<AutofillProfile*> profiles_to_update; 155 std::vector<AutofillProfile*> profiles_to_update;
160 std::vector<AutofillProfile*> profiles_to_add; 156 std::vector<AutofillProfile*> profiles_to_add;
161 }; 157 };
162 158
163 } // namespace browser_sync 159 } // namespace browser_sync
164 160
165 #endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_ 161 #endif // CHROME_BROWSER_SYNC_GLUE_AUTOFILL_PROFILE_SYNCABLE_SERVICE_H_
166
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698