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

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

Issue 12695015: Split Autofill webdata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/web_data_service.h" 5 #include "chrome/browser/webdata/web_data_service.h"
6 6
7 #include "base/stl_util.h"
7 #include "chrome/browser/search_engines/template_url.h" 8 #include "chrome/browser/search_engines/template_url.h"
8 #include "chrome/browser/webdata/autocomplete_syncable_service.h"
9 #include "chrome/browser/webdata/autofill_change.h" 9 #include "chrome/browser/webdata/autofill_change.h"
10 #include "chrome/browser/webdata/autofill_entry.h" 10 #include "chrome/browser/webdata/autofill_entry.h"
11 #include "chrome/browser/webdata/autofill_profile_syncable_service.h"
12 #include "chrome/browser/webdata/autofill_table.h" 11 #include "chrome/browser/webdata/autofill_table.h"
13 #include "chrome/browser/webdata/keyword_table.h" 12 #include "chrome/browser/webdata/keyword_table.h"
14 #include "chrome/browser/webdata/logins_table.h" 13 #include "chrome/browser/webdata/logins_table.h"
15 #include "chrome/browser/webdata/token_service_table.h" 14 #include "chrome/browser/webdata/token_service_table.h"
16 #include "chrome/browser/webdata/web_apps_table.h" 15 #include "chrome/browser/webdata/web_apps_table.h"
17 #include "chrome/browser/webdata/web_database_service.h" 16 #include "chrome/browser/webdata/web_database_service.h"
18 #include "chrome/browser/webdata/web_intents_table.h" 17 #include "chrome/browser/webdata/web_intents_table.h"
19 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
20 #include "components/autofill/browser/autofill_country.h" 19 #include "components/autofill/browser/autofill_country.h"
21 #include "components/autofill/browser/autofill_profile.h" 20 #include "components/autofill/browser/autofill_profile.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 55
57 WDAppImagesResult::~WDAppImagesResult() {} 56 WDAppImagesResult::~WDAppImagesResult() {}
58 57
59 WDKeywordsResult::WDKeywordsResult() 58 WDKeywordsResult::WDKeywordsResult()
60 : default_search_provider_id(0), 59 : default_search_provider_id(0),
61 builtin_keyword_version(0) { 60 builtin_keyword_version(0) {
62 } 61 }
63 62
64 WDKeywordsResult::~WDKeywordsResult() {} 63 WDKeywordsResult::~WDKeywordsResult() {}
65 64
66 WebDataService::WebDataService() 65 WebDataService::WebDataService(scoped_refptr<WebDatabaseService> wdbs,
Jói 2013/03/19 20:53:58 Indentation again; both indent to ( or both indent
Cait (Slow) 2013/03/20 22:21:10 Done.
67 : autocomplete_syncable_service_(NULL), 66 const ProfileErrorCallback& callback)
68 autofill_profile_syncable_service_(NULL) { 67 : WebDataServiceBase(wdbs, callback) {
69 } 68 }
70 69
71 // static 70 // static
72 void WebDataService::NotifyOfMultipleAutofillChanges( 71 void WebDataService::NotifyOfMultipleAutofillChanges(
73 WebDataService* web_data_service) { 72 WebDataService* web_data_service) {
74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
75 74
76 if (!web_data_service) 75 if (!web_data_service)
77 return; 76 return;
78 77
79 BrowserThread::PostTask( 78 BrowserThread::PostTask(
80 BrowserThread::UI, FROM_HERE, 79 BrowserThread::UI, FROM_HERE,
81 Bind(&NotifyOfMultipleAutofillChangesTask, 80 Bind(&NotifyOfMultipleAutofillChangesTask,
82 make_scoped_refptr(web_data_service))); 81 make_scoped_refptr(web_data_service)));
83 } 82 }
84 83
85 void WebDataService::ShutdownOnUIThread() {
86 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
87 Bind(&WebDataService::ShutdownSyncableServices, this));
88 WebDataServiceBase::ShutdownOnUIThread();
89 }
90
91 void WebDataService::Init(const base::FilePath& path) {
92 WebDataServiceBase::Init(path);
93 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
94 Bind(&WebDataService::InitializeSyncableServices, this));
95 }
96
97 ////////////////////////////////////////////////////////////////////////////// 84 //////////////////////////////////////////////////////////////////////////////
98 // 85 //
99 // Keywords. 86 // Keywords.
100 // 87 //
101 ////////////////////////////////////////////////////////////////////////////// 88 //////////////////////////////////////////////////////////////////////////////
102 89
103 void WebDataService::AddKeyword(const TemplateURLData& data) { 90 void WebDataService::AddKeyword(const TemplateURLData& data) {
104 wdbs_->ScheduleDBTask( 91 wdbs_->ScheduleDBTask(
105 FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, data)); 92 FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, data));
106 } 93 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 255 }
269 256
270 void WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetween( 257 void WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetween(
271 const Time& delete_begin, 258 const Time& delete_begin,
272 const Time& delete_end) { 259 const Time& delete_end) {
273 wdbs_->ScheduleDBTask(FROM_HERE, Bind( 260 wdbs_->ScheduleDBTask(FROM_HERE, Bind(
274 &WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl, 261 &WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl,
275 this, delete_begin, delete_end)); 262 this, delete_begin, delete_end));
276 } 263 }
277 264
265 WebDataService::WebDataService()
266 : WebDataServiceBase(NULL, ProfileErrorCallback()) {
267 }
268
278 WebDataService::~WebDataService() { 269 WebDataService::~WebDataService() {
279 DCHECK(!autocomplete_syncable_service_);
280 DCHECK(!autofill_profile_syncable_service_);
281 } 270 }
282 271
283 //////////////////////////////////////////////////////////////////////////////// 272 ////////////////////////////////////////////////////////////////////////////////
284 //
285 // The following methods are executed on the DB thread.
286 //
287 ////////////////////////////////////////////////////////////////////////////////
288
289 void WebDataService::InitializeSyncableServices() {
290 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
291 DCHECK(!autocomplete_syncable_service_);
292 DCHECK(!autofill_profile_syncable_service_);
293
294 autocomplete_syncable_service_ = new AutocompleteSyncableService(this);
295 autofill_profile_syncable_service_ = new AutofillProfileSyncableService(this);
296 }
297
298 void WebDataService::ShutdownSyncableServices() {
299 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
300
301 delete autocomplete_syncable_service_;
302 autocomplete_syncable_service_ = NULL;
303 delete autofill_profile_syncable_service_;
304 autofill_profile_syncable_service_ = NULL;
305 }
306
307 ////////////////////////////////////////////////////////////////////////////////
308 // 273 //
309 // Keywords implementation. 274 // Keywords implementation.
310 // 275 //
311 //////////////////////////////////////////////////////////////////////////////// 276 ////////////////////////////////////////////////////////////////////////////////
312 277
313 WebDatabase::State WebDataService::AddKeywordImpl( 278 WebDatabase::State WebDataService::AddKeywordImpl(
314 const TemplateURLData& data, WebDatabase* db) { 279 const TemplateURLData& data, WebDatabase* db) {
315 db->GetKeywordTable()->AddKeyword(data); 280 db->GetKeywordTable()->AddKeyword(data);
316 return WebDatabase::COMMIT_NEEDED; 281 return WebDatabase::COMMIT_NEEDED;
317 } 282 }
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 content::Source<WebDataService>(this), 632 content::Source<WebDataService>(this),
668 content::Details<AutofillProfileChange>(&change)); 633 content::Details<AutofillProfileChange>(&change));
669 } 634 }
670 // Note: It is the caller's responsibility to post notifications for any 635 // Note: It is the caller's responsibility to post notifications for any
671 // changes, e.g. by calling the Refresh() method of PersonalDataManager. 636 // changes, e.g. by calling the Refresh() method of PersonalDataManager.
672 return WebDatabase::COMMIT_NEEDED; 637 return WebDatabase::COMMIT_NEEDED;
673 } 638 }
674 return WebDatabase::COMMIT_NOT_NEEDED; 639 return WebDatabase::COMMIT_NOT_NEEDED;
675 } 640 }
676 641
677 AutofillProfileSyncableService*
678 WebDataService::GetAutofillProfileSyncableService() const {
679 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
680 DCHECK(autofill_profile_syncable_service_); // Make sure we're initialized.
681
682 return autofill_profile_syncable_service_;
683 }
684
685 AutocompleteSyncableService* WebDataService::GetAutocompleteSyncableService()
686 const {
687 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
688 DCHECK(autocomplete_syncable_service_); // Make sure we're initialized.
689
690 return autocomplete_syncable_service_;
691 }
692
693 void WebDataService::DestroyAutofillProfileResult(const WDTypedResult* result) { 642 void WebDataService::DestroyAutofillProfileResult(const WDTypedResult* result) {
694 DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT); 643 DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT);
695 const WDResult<std::vector<AutofillProfile*> >* r = 644 const WDResult<std::vector<AutofillProfile*> >* r =
696 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result); 645 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result);
697 std::vector<AutofillProfile*> profiles = r->GetValue(); 646 std::vector<AutofillProfile*> profiles = r->GetValue();
698 STLDeleteElements(&profiles); 647 STLDeleteElements(&profiles);
699 } 648 }
700 649
701 void WebDataService::DestroyAutofillCreditCardResult( 650 void WebDataService::DestroyAutofillCreditCardResult(
702 const WDTypedResult* result) { 651 const WDTypedResult* result) {
703 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); 652 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT);
704 const WDResult<std::vector<CreditCard*> >* r = 653 const WDResult<std::vector<CreditCard*> >* r =
705 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); 654 static_cast<const WDResult<std::vector<CreditCard*> >*>(result);
706 655
707 std::vector<CreditCard*> credit_cards = r->GetValue(); 656 std::vector<CreditCard*> credit_cards = r->GetValue();
708 STLDeleteElements(&credit_cards); 657 STLDeleteElements(&credit_cards);
709 } 658 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698