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

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

Issue 8184001: The AutofillProfileSyncableService's lifetime should be managed by the WebDataService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ 5 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
6 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ 6 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
17 #include "chrome/browser/search_engines/template_url_id.h" 17 #include "chrome/browser/search_engines/template_url_id.h"
18 #include "content/browser/browser_thread.h" 18 #include "content/browser/browser_thread.h"
19 #include "sql/init_status.h" 19 #include "sql/init_status.h"
20 20
21 class AutofillChange; 21 class AutofillChange;
22 class AutofillProfile; 22 class AutofillProfile;
23 class AutofillProfileSyncableService;
23 class CreditCard; 24 class CreditCard;
24 class GURL; 25 class GURL;
25 #if defined(OS_WIN) 26 #if defined(OS_WIN)
26 struct IE7PasswordInfo; 27 struct IE7PasswordInfo;
27 #endif 28 #endif
28 class MessageLoop; 29 class MessageLoop;
29 class Profile; 30 class Profile;
30 class SkBitmap; 31 class SkBitmap;
31 class TemplateURL; 32 class TemplateURL;
32 class WebDatabase; 33 class WebDatabase;
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 // OnWebDataServiceRequestDone of |consumer| gets called when the request is 506 // OnWebDataServiceRequestDone of |consumer| gets called when the request is
506 // finished, with the credit cards included in the argument |result|. The 507 // finished, with the credit cards included in the argument |result|. The
507 // consumer owns the credit cards. 508 // consumer owns the credit cards.
508 Handle GetCreditCards(WebDataServiceConsumer* consumer); 509 Handle GetCreditCards(WebDataServiceConsumer* consumer);
509 510
510 // Removes Autofill records from the database. 511 // Removes Autofill records from the database.
511 void RemoveAutofillProfilesAndCreditCardsModifiedBetween( 512 void RemoveAutofillProfilesAndCreditCardsModifiedBetween(
512 const base::Time& delete_begin, 513 const base::Time& delete_begin,
513 const base::Time& delete_end); 514 const base::Time& delete_end);
514 515
516 // TODO(georgey): Add support for autocomplete as well: http://crbug.com/95759
517 // Returns the syncable service for Autofill addresses and credit cards stored
518 // in this table.
akalin 2011/10/11 21:24:38 Add comment saying that the returned APSS is owned
Ilya Sherman 2011/10/11 22:17:34 Done.
519 virtual AutofillProfileSyncableService*
520 GetAutofillProfileSyncableService() const;
521
515 // Testing 522 // Testing
516 #ifdef UNIT_TEST 523 #ifdef UNIT_TEST
517 void set_failed_init(bool value) { failed_init_ = value; } 524 void set_failed_init(bool value) { failed_init_ = value; }
518 #endif 525 #endif
519 526
520 protected: 527 protected:
521 friend class TemplateURLServiceTest; 528 friend class TemplateURLServiceTest;
522 friend class TemplateURLServiceTestingProfile; 529 friend class TemplateURLServiceTestingProfile;
523 friend class WebDataServiceTest; 530 friend class WebDataServiceTest;
524 friend class WebDataRequest; 531 friend class WebDataRequest;
(...skipping 21 matching lines...) Expand all
546 553
547 typedef GenericRequest2<std::vector<const TemplateURL*>, 554 typedef GenericRequest2<std::vector<const TemplateURL*>,
548 std::vector<TemplateURL*> > SetKeywordsRequest; 555 std::vector<TemplateURL*> > SetKeywordsRequest;
549 556
550 // Invoked on the main thread if initializing the db fails. 557 // Invoked on the main thread if initializing the db fails.
551 void DBInitFailed(sql::InitStatus init_status); 558 void DBInitFailed(sql::InitStatus init_status);
552 559
553 // Initialize the database, if it hasn't already been initialized. 560 // Initialize the database, if it hasn't already been initialized.
554 void InitializeDatabaseIfNecessary(); 561 void InitializeDatabaseIfNecessary();
555 562
563 // Initialize any syncable services.
564 void InitializeSyncableServices();
565
556 // The notification method. 566 // The notification method.
557 void NotifyDatabaseLoadedOnUIThread(); 567 void NotifyDatabaseLoadedOnUIThread();
558 568
559 // Commit any pending transaction and deletes the database. 569 // Commit any pending transaction and deletes the database.
560 void ShutdownDatabase(); 570 void ShutdownDatabase();
561 571
572 // Deletes the syncable services.
573 void ShutdownSyncableServices();
574
562 // Commit the current transaction and creates a new one. 575 // Commit the current transaction and creates a new one.
563 void Commit(); 576 void Commit();
564 577
565 // Schedule a task on our worker thread. 578 // Schedule a task on our worker thread.
566 void ScheduleTask(const base::Closure& task); 579 void ScheduleTask(const base::Closure& task);
567 580
568 // Schedule a commit if one is not already pending. 581 // Schedule a commit if one is not already pending.
569 void ScheduleCommit(); 582 void ScheduleCommit();
570 583
571 // Return the next request handle. 584 // Return the next request handle.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 void GetCreditCardsImpl(WebDataRequest* request); 670 void GetCreditCardsImpl(WebDataRequest* request);
658 void RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl( 671 void RemoveAutofillProfilesAndCreditCardsModifiedBetweenImpl(
659 GenericRequest2<base::Time, base::Time>* request); 672 GenericRequest2<base::Time, base::Time>* request);
660 673
661 // True once initialization has started. 674 // True once initialization has started.
662 bool is_running_; 675 bool is_running_;
663 676
664 // The path with which to initialize the database. 677 // The path with which to initialize the database.
665 FilePath path_; 678 FilePath path_;
666 679
667 // Our database. 680 // Our database. We own the |db_|, but don't use a |scoped_ptr| because the
681 // |db_| lifetime must be managed on the database thread.
668 WebDatabase* db_; 682 WebDatabase* db_;
669 683
684 // Syncable services for the database data. We own the services, but don't
685 // use |scoped_ptr|s because the lifetimes must be managed on the database
686 // thread.
687 // Currently only Autofill profiles (and credit cards) use the new Sync API,
688 // but all the database data should migrate to this API over time.
689 AutofillProfileSyncableService* autofill_profile_syncable_service_;
690
670 // Whether the database failed to initialize. We use this to avoid 691 // Whether the database failed to initialize. We use this to avoid
671 // continually trying to reinit. 692 // continually trying to reinit.
672 bool failed_init_; 693 bool failed_init_;
673 694
674 // Whether we should commit the database. 695 // Whether we should commit the database.
675 bool should_commit_; 696 bool should_commit_;
676 697
677 // A lock to protect pending requests and next request handle. 698 // A lock to protect pending requests and next request handle.
678 base::Lock pending_lock_; 699 base::Lock pending_lock_;
679 700
(...skipping 25 matching lines...) Expand all
705 // result can be NULL, if no result is expected or if the database could 726 // result can be NULL, if no result is expected or if the database could
706 // not be opened. The result object is destroyed after this call. 727 // not be opened. The result object is destroyed after this call.
707 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, 728 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h,
708 const WDTypedResult* result) = 0; 729 const WDTypedResult* result) = 0;
709 730
710 protected: 731 protected:
711 virtual ~WebDataServiceConsumer() {} 732 virtual ~WebDataServiceConsumer() {}
712 }; 733 };
713 734
714 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ 735 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698