Index: components/autofill/browser/webdata/autofill_webdata_backend.cc |
diff --git a/components/autofill/browser/webdata/autofill_webdata_backend.cc b/components/autofill/browser/webdata/autofill_webdata_backend.cc |
index 71866c59f624f1506bbbdba9e7b51cc23adae7bd..a045e6bd580efebc43140641616b4c14f172510c 100644 |
--- a/components/autofill/browser/webdata/autofill_webdata_backend.cc |
+++ b/components/autofill/browser/webdata/autofill_webdata_backend.cc |
@@ -9,6 +9,7 @@ |
#include "components/autofill/browser/autofill_country.h" |
#include "components/autofill/browser/autofill_profile.h" |
#include "components/autofill/browser/credit_card.h" |
+#include "components/autofill/browser/webdata/autofill_backend_delegate.h" |
#include "components/autofill/browser/webdata/autofill_change.h" |
#include "components/autofill/browser/webdata/autofill_entry.h" |
#include "components/autofill/browser/webdata/autofill_table.h" |
@@ -20,7 +21,9 @@ using base::Time; |
using content::BrowserThread; |
namespace autofill { |
-AutofillWebDataBackend::AutofillWebDataBackend() { |
+ |
+AutofillWebDataBackend::AutofillWebDataBackend() |
+ : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
} |
void AutofillWebDataBackend::AddObserver( |
@@ -35,7 +38,19 @@ void AutofillWebDataBackend::RemoveObserver( |
db_observer_list_.RemoveObserver(observer); |
} |
+void AutofillWebDataBackend::GetDelegate( |
+ const AutofillWebDataService::DelegateOnDBCallback& callback, |
+ base::WeakPtr<WebDatabase> db) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
+ if (!delegate_.get()) |
+ delegate_.reset(new AutofillBackendDelegate( |
+ db, weak_ptr_factory_.GetWeakPtr())); |
+ callback.Run(delegate_.get()); |
+} |
+ |
AutofillWebDataBackend::~AutofillWebDataBackend() { |
+ delegate_.reset(); |
+ weak_ptr_factory_.InvalidateWeakPtrs(); |
erikwright (departed)
2013/04/25 19:06:10
Not necessary - this is done by ~WeakPtrFactory.
|
} |
WebDatabase::State AutofillWebDataBackend::AddFormElementsImpl( |
@@ -313,4 +328,4 @@ void AutofillWebDataBackend::DestroyAutofillCreditCardResult( |
STLDeleteElements(&credit_cards); |
} |
-} |
+} // namespace autofill |