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/webdata/autocomplete_syncable_service.cc

Issue 10696087: [Sync] Move ModelType and related classes to 'syncer' namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort headers, update copyrights Created 8 years, 5 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) 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 "chrome/browser/webdata/autocomplete_syncable_service.h" 5 #include "chrome/browser/webdata/autocomplete_syncable_service.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 AutocompleteSyncableService::~AutocompleteSyncableService() { 101 AutocompleteSyncableService::~AutocompleteSyncableService() {
102 DCHECK(CalledOnValidThread()); 102 DCHECK(CalledOnValidThread());
103 } 103 }
104 104
105 AutocompleteSyncableService::AutocompleteSyncableService() 105 AutocompleteSyncableService::AutocompleteSyncableService()
106 : web_data_service_(NULL) { 106 : web_data_service_(NULL) {
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
108 } 108 }
109 109
110 syncer::SyncError AutocompleteSyncableService::MergeDataAndStartSyncing( 110 syncer::SyncError AutocompleteSyncableService::MergeDataAndStartSyncing(
111 syncable::ModelType type, 111 syncer::ModelType type,
112 const syncer::SyncDataList& initial_sync_data, 112 const syncer::SyncDataList& initial_sync_data,
113 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 113 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
114 scoped_ptr<syncer::SyncErrorFactory> error_handler) { 114 scoped_ptr<syncer::SyncErrorFactory> error_handler) {
115 DCHECK(CalledOnValidThread()); 115 DCHECK(CalledOnValidThread());
116 DCHECK(!sync_processor_.get()); 116 DCHECK(!sync_processor_.get());
117 DCHECK(sync_processor.get()); 117 DCHECK(sync_processor.get());
118 DCHECK(error_handler.get()); 118 DCHECK(error_handler.get());
119 VLOG(1) << "Associating Autocomplete: MergeDataAndStartSyncing"; 119 VLOG(1) << "Associating Autocomplete: MergeDataAndStartSyncing";
120 120
121 error_handler_ = error_handler.Pass(); 121 error_handler_ = error_handler.Pass();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // trigger a notification to propagate the deletion to Sync. 166 // trigger a notification to propagate the deletion to Sync.
167 web_data_service_->RemoveExpiredFormElements(); 167 web_data_service_->RemoveExpiredFormElements();
168 } 168 }
169 169
170 syncer::SyncError error = 170 syncer::SyncError error =
171 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes); 171 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
172 172
173 return error; 173 return error;
174 } 174 }
175 175
176 void AutocompleteSyncableService::StopSyncing(syncable::ModelType type) { 176 void AutocompleteSyncableService::StopSyncing(syncer::ModelType type) {
177 DCHECK(CalledOnValidThread()); 177 DCHECK(CalledOnValidThread());
178 DCHECK_EQ(syncable::AUTOFILL, type); 178 DCHECK_EQ(syncer::AUTOFILL, type);
179 179
180 sync_processor_.reset(NULL); 180 sync_processor_.reset(NULL);
181 error_handler_.reset(); 181 error_handler_.reset();
182 } 182 }
183 183
184 syncer::SyncDataList AutocompleteSyncableService::GetAllSyncData( 184 syncer::SyncDataList AutocompleteSyncableService::GetAllSyncData(
185 syncable::ModelType type) const { 185 syncer::ModelType type) const {
186 DCHECK(CalledOnValidThread()); 186 DCHECK(CalledOnValidThread());
187 DCHECK(sync_processor_.get()); 187 DCHECK(sync_processor_.get());
188 DCHECK_EQ(type, syncable::AUTOFILL); 188 DCHECK_EQ(type, syncer::AUTOFILL);
189 189
190 syncer::SyncDataList current_data; 190 syncer::SyncDataList current_data;
191 191
192 std::vector<AutofillEntry> entries; 192 std::vector<AutofillEntry> entries;
193 if (!LoadAutofillData(&entries)) 193 if (!LoadAutofillData(&entries))
194 return current_data; 194 return current_data;
195 195
196 for (std::vector<AutofillEntry>::iterator it = entries.begin(); 196 for (std::vector<AutofillEntry>::iterator it = entries.begin();
197 it != entries.end(); ++it) { 197 it != entries.end(); ++it) {
198 current_data.push_back(CreateSyncData(*it)); 198 current_data.push_back(CreateSyncData(*it));
199 } 199 }
200 200
201 return current_data; 201 return current_data;
202 } 202 }
203 203
204 syncer::SyncError AutocompleteSyncableService::ProcessSyncChanges( 204 syncer::SyncError AutocompleteSyncableService::ProcessSyncChanges(
205 const tracked_objects::Location& from_here, 205 const tracked_objects::Location& from_here,
206 const syncer::SyncChangeList& change_list) { 206 const syncer::SyncChangeList& change_list) {
207 DCHECK(CalledOnValidThread()); 207 DCHECK(CalledOnValidThread());
208 DCHECK(sync_processor_.get()); 208 DCHECK(sync_processor_.get());
209 209
210 if (!sync_processor_.get()) { 210 if (!sync_processor_.get()) {
211 syncer::SyncError error(FROM_HERE, "Models not yet associated.", 211 syncer::SyncError error(FROM_HERE, "Models not yet associated.",
212 syncable::AUTOFILL); 212 syncer::AUTOFILL);
213 return error; 213 return error;
214 } 214 }
215 215
216 // Data is loaded only if we get new ADD/UPDATE change. 216 // Data is loaded only if we get new ADD/UPDATE change.
217 std::vector<AutofillEntry> entries; 217 std::vector<AutofillEntry> entries;
218 scoped_ptr<AutocompleteEntryMap> db_entries; 218 scoped_ptr<AutocompleteEntryMap> db_entries;
219 std::vector<AutofillEntry> new_entries; 219 std::vector<AutofillEntry> new_entries;
220 220
221 syncer::SyncError list_processing_error; 221 syncer::SyncError list_processing_error;
222 222
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 UTF16ToUTF8(entry.key().value()))); 449 UTF16ToUTF8(entry.key().value())));
450 return syncer::SyncData::CreateLocalData(tag, tag, autofill_specifics); 450 return syncer::SyncData::CreateLocalData(tag, tag, autofill_specifics);
451 } 451 }
452 452
453 // static 453 // static
454 std::string AutocompleteSyncableService::KeyToTag(const std::string& name, 454 std::string AutocompleteSyncableService::KeyToTag(const std::string& name,
455 const std::string& value) { 455 const std::string& value) {
456 std::string ns(kAutofillEntryNamespaceTag); 456 std::string ns(kAutofillEntryNamespaceTag);
457 return ns + net::EscapePath(name) + "|" + net::EscapePath(value); 457 return ns + net::EscapePath(name) + "|" + net::EscapePath(value);
458 } 458 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/autocomplete_syncable_service.h ('k') | chrome/browser/webdata/autofill_profile_syncable_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698