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

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

Issue 12494020: Remove knowledge of Chrome-specific SyncableService classes from WebDataService. (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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(const ProfileErrorCallback& callback) 65 WebDataService::WebDataService(const ProfileErrorCallback& callback)
67 : WebDataServiceBase(callback), 66 : WebDataServiceBase(callback) {
68 autocomplete_syncable_service_(NULL),
69 autofill_profile_syncable_service_(NULL) {
70 } 67 }
71 68
72 // static 69 // static
73 void WebDataService::NotifyOfMultipleAutofillChanges( 70 void WebDataService::NotifyOfMultipleAutofillChanges(
74 WebDataService* web_data_service) { 71 WebDataService* web_data_service) {
75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
76 73
77 if (!web_data_service) 74 if (!web_data_service)
78 return; 75 return;
79 76
80 BrowserThread::PostTask( 77 BrowserThread::PostTask(
81 BrowserThread::UI, FROM_HERE, 78 BrowserThread::UI, FROM_HERE,
82 Bind(&NotifyOfMultipleAutofillChangesTask, 79 Bind(&NotifyOfMultipleAutofillChangesTask,
83 make_scoped_refptr(web_data_service))); 80 make_scoped_refptr(web_data_service)));
84 } 81 }
85 82
86 void WebDataService::ShutdownOnUIThread() {
87 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
88 Bind(&WebDataService::ShutdownSyncableServices, this));
89 WebDataServiceBase::ShutdownOnUIThread();
90 }
91
92 void WebDataService::Init(const base::FilePath& path) {
93 WebDataServiceBase::Init(path);
94 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
95 Bind(&WebDataService::InitializeSyncableServices, this));
96 }
97
98 ////////////////////////////////////////////////////////////////////////////// 83 //////////////////////////////////////////////////////////////////////////////
99 // 84 //
100 // Keywords. 85 // Keywords.
101 // 86 //
102 ////////////////////////////////////////////////////////////////////////////// 87 //////////////////////////////////////////////////////////////////////////////
103 88
104 void WebDataService::AddKeyword(const TemplateURLData& data) { 89 void WebDataService::AddKeyword(const TemplateURLData& data) {
105 wdbs_->ScheduleDBTask( 90 wdbs_->ScheduleDBTask(
106 FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, data)); 91 FROM_HERE, Bind(&WebDataService::AddKeywordImpl, this, data));
107 } 92 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 255
271 void WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetween( 256 void WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetween(
272 const Time& delete_begin, 257 const Time& delete_begin,
273 const Time& delete_end) { 258 const Time& delete_end) {
274 wdbs_->ScheduleDBTask(FROM_HERE, Bind( 259 wdbs_->ScheduleDBTask(FROM_HERE, Bind(
275 &WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl, 260 &WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl,
276 this, delete_begin, delete_end)); 261 this, delete_begin, delete_end));
277 } 262 }
278 263
279 WebDataService::~WebDataService() { 264 WebDataService::~WebDataService() {
280 DCHECK(!autocomplete_syncable_service_);
281 DCHECK(!autofill_profile_syncable_service_);
282 } 265 }
283 266
284 //////////////////////////////////////////////////////////////////////////////// 267 ////////////////////////////////////////////////////////////////////////////////
285 //
286 // The following methods are executed on the DB thread.
287 //
288 ////////////////////////////////////////////////////////////////////////////////
289
290 void WebDataService::InitializeSyncableServices() {
291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
292 DCHECK(!autocomplete_syncable_service_);
293 DCHECK(!autofill_profile_syncable_service_);
294
295 autocomplete_syncable_service_ = new AutocompleteSyncableService(this);
296 autofill_profile_syncable_service_ = new AutofillProfileSyncableService(this);
297 }
298
299 void WebDataService::ShutdownSyncableServices() {
300 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
301
302 delete autocomplete_syncable_service_;
303 autocomplete_syncable_service_ = NULL;
304 delete autofill_profile_syncable_service_;
305 autofill_profile_syncable_service_ = NULL;
306 }
307
308 ////////////////////////////////////////////////////////////////////////////////
309 // 268 //
310 // Keywords implementation. 269 // Keywords implementation.
311 // 270 //
312 //////////////////////////////////////////////////////////////////////////////// 271 ////////////////////////////////////////////////////////////////////////////////
313 272
314 WebDatabase::State WebDataService::AddKeywordImpl( 273 WebDatabase::State WebDataService::AddKeywordImpl(
315 const TemplateURLData& data, WebDatabase* db) { 274 const TemplateURLData& data, WebDatabase* db) {
316 KeywordTable::FromWebDatabase(db)->AddKeyword(data); 275 KeywordTable::FromWebDatabase(db)->AddKeyword(data);
317 return WebDatabase::COMMIT_NEEDED; 276 return WebDatabase::COMMIT_NEEDED;
318 } 277 }
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 content::Source<WebDataService>(this), 631 content::Source<WebDataService>(this),
673 content::Details<AutofillProfileChange>(&change)); 632 content::Details<AutofillProfileChange>(&change));
674 } 633 }
675 // Note: It is the caller's responsibility to post notifications for any 634 // Note: It is the caller's responsibility to post notifications for any
676 // changes, e.g. by calling the Refresh() method of PersonalDataManager. 635 // changes, e.g. by calling the Refresh() method of PersonalDataManager.
677 return WebDatabase::COMMIT_NEEDED; 636 return WebDatabase::COMMIT_NEEDED;
678 } 637 }
679 return WebDatabase::COMMIT_NOT_NEEDED; 638 return WebDatabase::COMMIT_NOT_NEEDED;
680 } 639 }
681 640
682 AutofillProfileSyncableService*
683 WebDataService::GetAutofillProfileSyncableService() const {
684 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
685 DCHECK(autofill_profile_syncable_service_); // Make sure we're initialized.
686
687 return autofill_profile_syncable_service_;
688 }
689
690 AutocompleteSyncableService* WebDataService::GetAutocompleteSyncableService()
691 const {
692 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
693 DCHECK(autocomplete_syncable_service_); // Make sure we're initialized.
694
695 return autocomplete_syncable_service_;
696 }
697
698 void WebDataService::DestroyAutofillProfileResult(const WDTypedResult* result) { 641 void WebDataService::DestroyAutofillProfileResult(const WDTypedResult* result) {
699 DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT); 642 DCHECK(result->GetType() == AUTOFILL_PROFILES_RESULT);
700 const WDResult<std::vector<AutofillProfile*> >* r = 643 const WDResult<std::vector<AutofillProfile*> >* r =
701 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result); 644 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result);
702 std::vector<AutofillProfile*> profiles = r->GetValue(); 645 std::vector<AutofillProfile*> profiles = r->GetValue();
703 STLDeleteElements(&profiles); 646 STLDeleteElements(&profiles);
704 } 647 }
705 648
706 void WebDataService::DestroyAutofillCreditCardResult( 649 void WebDataService::DestroyAutofillCreditCardResult(
707 const WDTypedResult* result) { 650 const WDTypedResult* result) {
708 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT); 651 DCHECK(result->GetType() == AUTOFILL_CREDITCARDS_RESULT);
709 const WDResult<std::vector<CreditCard*> >* r = 652 const WDResult<std::vector<CreditCard*> >* r =
710 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); 653 static_cast<const WDResult<std::vector<CreditCard*> >*>(result);
711 654
712 std::vector<CreditCard*> credit_cards = r->GetValue(); 655 std::vector<CreditCard*> credit_cards = r->GetValue();
713 STLDeleteElements(&credit_cards); 656 STLDeleteElements(&credit_cards);
714 } 657 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698