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

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

Issue 12805007: wd5-syncableServices for try only (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wd5-syncableServices with debug test fix Created 7 years, 9 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/autofill_profile_syncable_service.h" 5 #include "chrome/browser/webdata/autofill_profile_syncable_service.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 15 matching lines...) Expand all
26 26
27 namespace { 27 namespace {
28 28
29 std::string LimitData(const std::string& data) { 29 std::string LimitData(const std::string& data) {
30 std::string sanitized_value(data); 30 std::string sanitized_value(data);
31 if (sanitized_value.length() > AutofillTable::kMaxDataLength) 31 if (sanitized_value.length() > AutofillTable::kMaxDataLength)
32 sanitized_value.resize(AutofillTable::kMaxDataLength); 32 sanitized_value.resize(AutofillTable::kMaxDataLength);
33 return sanitized_value; 33 return sanitized_value;
34 } 34 }
35 35
36 void* UserDataKey() {
37 // Use the address of a static that COMDAT folding won't ever fold
38 // with something else.
39 static int user_data_key = 0;
40 return reinterpret_cast<void*>(&user_data_key);
41 }
42
36 } // namespace 43 } // namespace
37 44
38 const char kAutofillProfileTag[] = "google_chrome_autofill_profiles"; 45 const char kAutofillProfileTag[] = "google_chrome_autofill_profiles";
39 46
40 AutofillProfileSyncableService::AutofillProfileSyncableService( 47 AutofillProfileSyncableService::AutofillProfileSyncableService(
41 WebDataService* web_data_service) 48 WebDataService* web_data_service)
42 : web_data_service_(web_data_service) { 49 : web_data_service_(web_data_service) {
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
44 DCHECK(web_data_service_); 51 DCHECK(web_data_service_);
45 notification_registrar_.Add( 52 notification_registrar_.Add(
46 this, 53 this,
47 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, 54 chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED,
48 content::Source<WebDataService>(web_data_service_)); 55 content::Source<WebDataService>(web_data_service_));
49 } 56 }
50 57
51 AutofillProfileSyncableService::~AutofillProfileSyncableService() { 58 AutofillProfileSyncableService::~AutofillProfileSyncableService() {
52 DCHECK(CalledOnValidThread()); 59 DCHECK(CalledOnValidThread());
53 } 60 }
54 61
62 // static
63 void AutofillProfileSyncableService::CreateForWebDataService(
64 WebDataService* web_data) {
65 web_data->GetDBUserData()->SetUserData(
66 UserDataKey(), new AutofillProfileSyncableService(web_data));
67 }
68
69 // static
70 AutofillProfileSyncableService*
71 AutofillProfileSyncableService::FromWebDataService(
72 WebDataService* service) {
73 return static_cast<AutofillProfileSyncableService*>(
74 service->GetDBUserData()->GetUserData(UserDataKey()));
75 }
76
55 AutofillProfileSyncableService::AutofillProfileSyncableService() 77 AutofillProfileSyncableService::AutofillProfileSyncableService()
56 : web_data_service_(NULL) { 78 : web_data_service_(NULL) {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
58 } 80 }
59 81
60 syncer::SyncMergeResult 82 syncer::SyncMergeResult
61 AutofillProfileSyncableService::MergeDataAndStartSyncing( 83 AutofillProfileSyncableService::MergeDataAndStartSyncing(
62 syncer::ModelType type, 84 syncer::ModelType type,
63 const syncer::SyncDataList& initial_sync_data, 85 const syncer::SyncDataList& initial_sync_data,
64 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 86 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 } 561 }
540 562
541 bool AutofillProfileSyncableService::MergeProfile( 563 bool AutofillProfileSyncableService::MergeProfile(
542 const AutofillProfile& merge_from, 564 const AutofillProfile& merge_from,
543 AutofillProfile* merge_into) { 565 AutofillProfile* merge_into) {
544 merge_into->OverwriteWithOrAddTo(merge_from); 566 merge_into->OverwriteWithOrAddTo(merge_from);
545 return (merge_into->Compare(merge_from) != 0); 567 return (merge_into->Compare(merge_from) != 0);
546 } 568 }
547 569
548 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const { 570 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const {
549 return web_data_service_->GetDatabase()->GetAutofillTable(); 571 return AutofillTable::FromWebDatabase(web_data_service_->GetDatabase());
550 } 572 }
551 573
552 AutofillProfileSyncableService::DataBundle::DataBundle() {} 574 AutofillProfileSyncableService::DataBundle::DataBundle() {}
553 575
554 AutofillProfileSyncableService::DataBundle::~DataBundle() { 576 AutofillProfileSyncableService::DataBundle::~DataBundle() {
555 } 577 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/autofill_profile_syncable_service.h ('k') | chrome/browser/webdata/autofill_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698