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

Side by Side Diff: components/autofill/core/browser/webdata/autocomplete_syncable_service.cc

Issue 2908973003: Replace deprecated base::NonThreadSafe in components/autofill in favor of SequenceChecker. (Closed)
Patch Set: Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service .h" 5 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service .h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 AutocompleteSyncableService::AutocompleteSyncableService( 67 AutocompleteSyncableService::AutocompleteSyncableService(
68 AutofillWebDataBackend* web_data_backend) 68 AutofillWebDataBackend* web_data_backend)
69 : web_data_backend_(web_data_backend), scoped_observer_(this) { 69 : web_data_backend_(web_data_backend), scoped_observer_(this) {
70 DCHECK(web_data_backend_); 70 DCHECK(web_data_backend_);
71 71
72 scoped_observer_.Add(web_data_backend_); 72 scoped_observer_.Add(web_data_backend_);
73 } 73 }
74 74
75 AutocompleteSyncableService::~AutocompleteSyncableService() { 75 AutocompleteSyncableService::~AutocompleteSyncableService() {
76 DCHECK(CalledOnValidThread()); 76 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
77 } 77 }
78 78
79 // static 79 // static
80 void AutocompleteSyncableService::CreateForWebDataServiceAndBackend( 80 void AutocompleteSyncableService::CreateForWebDataServiceAndBackend(
81 AutofillWebDataService* web_data_service, 81 AutofillWebDataService* web_data_service,
82 AutofillWebDataBackend* web_data_backend) { 82 AutofillWebDataBackend* web_data_backend) {
83 web_data_service->GetDBUserData()->SetUserData( 83 web_data_service->GetDBUserData()->SetUserData(
84 UserDataKey(), 84 UserDataKey(),
85 base::WrapUnique(new AutocompleteSyncableService(web_data_backend))); 85 base::WrapUnique(new AutocompleteSyncableService(web_data_backend)));
86 } 86 }
(...skipping 12 matching lines...) Expand all
99 void AutocompleteSyncableService::InjectStartSyncFlare( 99 void AutocompleteSyncableService::InjectStartSyncFlare(
100 const syncer::SyncableService::StartSyncFlare& flare) { 100 const syncer::SyncableService::StartSyncFlare& flare) {
101 flare_ = flare; 101 flare_ = flare;
102 } 102 }
103 103
104 syncer::SyncMergeResult AutocompleteSyncableService::MergeDataAndStartSyncing( 104 syncer::SyncMergeResult AutocompleteSyncableService::MergeDataAndStartSyncing(
105 syncer::ModelType type, 105 syncer::ModelType type,
106 const syncer::SyncDataList& initial_sync_data, 106 const syncer::SyncDataList& initial_sync_data,
107 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor, 107 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor,
108 std::unique_ptr<syncer::SyncErrorFactory> error_handler) { 108 std::unique_ptr<syncer::SyncErrorFactory> error_handler) {
109 DCHECK(CalledOnValidThread()); 109 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
110 DCHECK(!sync_processor_); 110 DCHECK(!sync_processor_);
111 DCHECK(sync_processor); 111 DCHECK(sync_processor);
112 DCHECK(error_handler); 112 DCHECK(error_handler);
113 113
114 syncer::SyncMergeResult merge_result(type); 114 syncer::SyncMergeResult merge_result(type);
115 error_handler_ = std::move(error_handler); 115 error_handler_ = std::move(error_handler);
116 std::vector<AutofillEntry> entries; 116 std::vector<AutofillEntry> entries;
117 if (!LoadAutofillData(&entries)) { 117 if (!LoadAutofillData(&entries)) {
118 merge_result.set_error(error_handler_->CreateAndUploadError( 118 merge_result.set_error(error_handler_->CreateAndUploadError(
119 FROM_HERE, 119 FROM_HERE,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // Otherwise, an item that Sync is not yet aware of might expire, causing a 160 // Otherwise, an item that Sync is not yet aware of might expire, causing a
161 // Sync error when that item's deletion is propagated to Sync. 161 // Sync error when that item's deletion is propagated to Sync.
162 web_data_backend_->RemoveExpiredFormElements(); 162 web_data_backend_->RemoveExpiredFormElements();
163 163
164 web_data_backend_->NotifyThatSyncHasStarted(type); 164 web_data_backend_->NotifyThatSyncHasStarted(type);
165 165
166 return merge_result; 166 return merge_result;
167 } 167 }
168 168
169 void AutocompleteSyncableService::StopSyncing(syncer::ModelType type) { 169 void AutocompleteSyncableService::StopSyncing(syncer::ModelType type) {
170 DCHECK(CalledOnValidThread()); 170 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
171 DCHECK_EQ(syncer::AUTOFILL, type); 171 DCHECK_EQ(syncer::AUTOFILL, type);
172 172
173 sync_processor_.reset(); 173 sync_processor_.reset();
174 error_handler_.reset(); 174 error_handler_.reset();
175 } 175 }
176 176
177 syncer::SyncDataList AutocompleteSyncableService::GetAllSyncData( 177 syncer::SyncDataList AutocompleteSyncableService::GetAllSyncData(
178 syncer::ModelType type) const { 178 syncer::ModelType type) const {
179 DCHECK(CalledOnValidThread()); 179 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
180 DCHECK(sync_processor_); 180 DCHECK(sync_processor_);
181 DCHECK_EQ(type, syncer::AUTOFILL); 181 DCHECK_EQ(type, syncer::AUTOFILL);
182 182
183 syncer::SyncDataList current_data; 183 syncer::SyncDataList current_data;
184 184
185 std::vector<AutofillEntry> entries; 185 std::vector<AutofillEntry> entries;
186 if (!LoadAutofillData(&entries)) 186 if (!LoadAutofillData(&entries))
187 return current_data; 187 return current_data;
188 188
189 for (const AutofillEntry& it : entries) 189 for (const AutofillEntry& it : entries)
190 current_data.push_back(CreateSyncData(it)); 190 current_data.push_back(CreateSyncData(it));
191 191
192 return current_data; 192 return current_data;
193 } 193 }
194 194
195 syncer::SyncError AutocompleteSyncableService::ProcessSyncChanges( 195 syncer::SyncError AutocompleteSyncableService::ProcessSyncChanges(
196 const tracked_objects::Location& from_here, 196 const tracked_objects::Location& from_here,
197 const syncer::SyncChangeList& change_list) { 197 const syncer::SyncChangeList& change_list) {
198 DCHECK(CalledOnValidThread()); 198 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
199 DCHECK(sync_processor_); 199 DCHECK(sync_processor_);
200 200
201 if (!sync_processor_) { 201 if (!sync_processor_) {
202 syncer::SyncError error(FROM_HERE, 202 syncer::SyncError error(FROM_HERE,
203 syncer::SyncError::DATATYPE_ERROR, 203 syncer::SyncError::DATATYPE_ERROR,
204 "Models not yet associated.", 204 "Models not yet associated.",
205 syncer::AUTOFILL); 205 syncer::AUTOFILL);
206 return error; 206 return error;
207 } 207 }
208 208
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 } 284 }
285 285
286 bool AutocompleteSyncableService::LoadAutofillData( 286 bool AutocompleteSyncableService::LoadAutofillData(
287 std::vector<AutofillEntry>* entries) const { 287 std::vector<AutofillEntry>* entries) const {
288 return GetAutofillTable()->GetAllAutofillEntries(entries); 288 return GetAutofillTable()->GetAllAutofillEntries(entries);
289 } 289 }
290 290
291 bool AutocompleteSyncableService::SaveChangesToWebData( 291 bool AutocompleteSyncableService::SaveChangesToWebData(
292 const std::vector<AutofillEntry>& new_entries) { 292 const std::vector<AutofillEntry>& new_entries) {
293 DCHECK(CalledOnValidThread()); 293 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
294 if (!GetAutofillTable()->UpdateAutofillEntries(new_entries)) 294 if (!GetAutofillTable()->UpdateAutofillEntries(new_entries))
295 return false; 295 return false;
296 296
297 web_data_backend_->NotifyOfMultipleAutofillChanges(); 297 web_data_backend_->NotifyOfMultipleAutofillChanges();
298 return true; 298 return true;
299 } 299 }
300 300
301 // Creates or updates an autocomplete entry based on |data|. 301 // Creates or updates an autocomplete entry based on |data|.
302 void AutocompleteSyncableService::CreateOrUpdateEntry( 302 void AutocompleteSyncableService::CreateOrUpdateEntry(
303 const syncer::SyncData& data, 303 const syncer::SyncData& data,
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 } 421 }
422 422
423 // static 423 // static
424 std::string AutocompleteSyncableService::KeyToTag(const std::string& name, 424 std::string AutocompleteSyncableService::KeyToTag(const std::string& name,
425 const std::string& value) { 425 const std::string& value) {
426 std::string prefix(kAutofillEntryNamespaceTag); 426 std::string prefix(kAutofillEntryNamespaceTag);
427 return prefix + net::EscapePath(name) + "|" + net::EscapePath(value); 427 return prefix + net::EscapePath(name) + "|" + net::EscapePath(value);
428 } 428 }
429 429
430 } // namespace autofill 430 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698