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

Side by Side Diff: chrome/browser/webdata/autocomplete_syncable_service.cc

Issue 14018026: sync: SyncableService support for starting sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Haitao's comments Created 7 years, 7 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/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "components/autofill/browser/webdata/autofill_table.h" 10 #include "components/autofill/browser/webdata/autofill_table.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 web_data_service->GetDBUserData()->GetUserData(UserDataKey())); 120 web_data_service->GetDBUserData()->GetUserData(UserDataKey()));
121 } 121 }
122 122
123 AutocompleteSyncableService::AutocompleteSyncableService() 123 AutocompleteSyncableService::AutocompleteSyncableService()
124 : web_data_service_(NULL), 124 : web_data_service_(NULL),
125 ALLOW_THIS_IN_INITIALIZER_LIST(scoped_observer_(this)), 125 ALLOW_THIS_IN_INITIALIZER_LIST(scoped_observer_(this)),
126 cull_expired_entries_(false) { 126 cull_expired_entries_(false) {
127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
128 } 128 }
129 129
130
131 void AutocompleteSyncableService::InjectStartSyncFlare(
132 const syncer::StartSyncFlare& flare) {
133 flare_ = flare;
134 }
135
130 syncer::SyncMergeResult AutocompleteSyncableService::MergeDataAndStartSyncing( 136 syncer::SyncMergeResult AutocompleteSyncableService::MergeDataAndStartSyncing(
131 syncer::ModelType type, 137 syncer::ModelType type,
132 const syncer::SyncDataList& initial_sync_data, 138 const syncer::SyncDataList& initial_sync_data,
133 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 139 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
134 scoped_ptr<syncer::SyncErrorFactory> error_handler) { 140 scoped_ptr<syncer::SyncErrorFactory> error_handler) {
135 DCHECK(CalledOnValidThread()); 141 DCHECK(CalledOnValidThread());
136 DCHECK(!sync_processor_.get()); 142 DCHECK(!sync_processor_.get());
137 DCHECK(sync_processor.get()); 143 DCHECK(sync_processor.get());
138 DCHECK(error_handler.get()); 144 DCHECK(error_handler.get());
139 VLOG(1) << "Associating Autocomplete: MergeDataAndStartSyncing"; 145 VLOG(1) << "Associating Autocomplete: MergeDataAndStartSyncing";
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 307
302 return list_processing_error; 308 return list_processing_error;
303 } 309 }
304 310
305 void AutocompleteSyncableService::AutofillEntriesChanged( 311 void AutocompleteSyncableService::AutofillEntriesChanged(
306 const AutofillChangeList& changes) { 312 const AutofillChangeList& changes) {
307 // Check if sync is on. If we receive notification prior to the sync being set 313 // Check if sync is on. If we receive notification prior to the sync being set
308 // up we are going to process all when MergeData..() is called. If we receive 314 // up we are going to process all when MergeData..() is called. If we receive
309 // notification after the sync exited, it will be sinced next time Chrome 315 // notification after the sync exited, it will be sinced next time Chrome
310 // starts. 316 // starts.
311 if (sync_processor_.get()) 317 if (sync_processor_.get()) {
312 ActOnChanges(changes); 318 ActOnChanges(changes);
319 } else if (!flare_.is_null()) {
320 flare_.Run(syncer::AUTOFILL);
321 flare_.Reset();
322 }
313 } 323 }
314 324
315 bool AutocompleteSyncableService::LoadAutofillData( 325 bool AutocompleteSyncableService::LoadAutofillData(
316 std::vector<AutofillEntry>* entries) const { 326 std::vector<AutofillEntry>* entries) const {
317 return AutofillTable::FromWebDatabase( 327 return AutofillTable::FromWebDatabase(
318 web_data_service_->GetDatabase())->GetAllAutofillEntries(entries); 328 web_data_service_->GetDatabase())->GetAllAutofillEntries(entries);
319 } 329 }
320 330
321 bool AutocompleteSyncableService::SaveChangesToWebData( 331 bool AutocompleteSyncableService::SaveChangesToWebData(
322 const std::vector<AutofillEntry>& new_entries) { 332 const std::vector<AutofillEntry>& new_entries) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 UTF16ToUTF8(entry.key().value()))); 482 UTF16ToUTF8(entry.key().value())));
473 return syncer::SyncData::CreateLocalData(tag, tag, autofill_specifics); 483 return syncer::SyncData::CreateLocalData(tag, tag, autofill_specifics);
474 } 484 }
475 485
476 // static 486 // static
477 std::string AutocompleteSyncableService::KeyToTag(const std::string& name, 487 std::string AutocompleteSyncableService::KeyToTag(const std::string& name,
478 const std::string& value) { 488 const std::string& value) {
479 std::string ns(kAutofillEntryNamespaceTag); 489 std::string ns(kAutofillEntryNamespaceTag);
480 return ns + net::EscapePath(name) + "|" + net::EscapePath(value); 490 return ns + net::EscapePath(name) + "|" + net::EscapePath(value);
481 } 491 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698