diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 05:16:29 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 05:16:29 +0000 |
commit | f2a6ec64e7ee1bd87111919344094f86e0602c52 (patch) | |
tree | 36a117c9a3779fa7a62f7aa217415da53aa86c2c | |
parent | a3f4684f67993ab52f7bee525436c77e2eb826b4 (diff) | |
download | chromium_src-f2a6ec64e7ee1bd87111919344094f86e0602c52.zip chromium_src-f2a6ec64e7ee1bd87111919344094f86e0602c52.tar.gz chromium_src-f2a6ec64e7ee1bd87111919344094f86e0602c52.tar.bz2 |
[pyauto] FillAutofillProfile should not crash with Debug builds
Delete NotificationRegistar on the DB thread.
Also fix AddSavedPassword/RemoveSavedPassword which follow the same model.
BUG=127261
TEST=autofill.py
NOTRY=true
R=dennisjeffrey@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10388038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135987 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.cc | 19 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.h | 8 |
2 files changed, 14 insertions, 13 deletions
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 26a5d2d..051e773 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -1693,8 +1693,9 @@ void PasswordStoreLoginsChangedObserver::Init() { void PasswordStoreLoginsChangedObserver::RegisterObserversTask() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); - registrar_.Add(this, chrome::NOTIFICATION_LOGINS_CHANGED, - content::NotificationService::AllSources()); + registrar_.reset(new content::NotificationRegistrar); + registrar_->Add(this, chrome::NOTIFICATION_LOGINS_CHANGED, + content::NotificationService::AllSources()); done_event_.Signal(); } @@ -1704,6 +1705,7 @@ void PasswordStoreLoginsChangedObserver::Observe( const content::NotificationDetails& details) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); DCHECK(type == chrome::NOTIFICATION_LOGINS_CHANGED); + registrar_.reset(); // Must be done from the DB thread. PasswordStoreChangeList* change_details = content::Details<PasswordStoreChangeList>(details).ptr(); if (change_details->size() != 1 || @@ -1718,8 +1720,6 @@ void PasswordStoreLoginsChangedObserver::Observe( return; } - registrar_.RemoveAll(); // Must be done from the DB thread. - // Notify the UI thread that we're done listening. BrowserThread::PostTask( BrowserThread::UI, @@ -2183,10 +2183,11 @@ void AutofillChangedObserver::Init() { void AutofillChangedObserver::RegisterObserversTask() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); - registrar_.Add(this, chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED, - content::NotificationService::AllSources()); - registrar_.Add(this, chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, - content::NotificationService::AllSources()); + registrar_.reset(new content::NotificationRegistrar); + registrar_->Add(this, chrome::NOTIFICATION_AUTOFILL_CREDIT_CARD_CHANGED, + content::NotificationService::AllSources()); + registrar_->Add(this, chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, + content::NotificationService::AllSources()); done_event_.Signal(); } @@ -2205,7 +2206,7 @@ void AutofillChangedObserver::Observe( } if (num_profiles_ <= 0 && num_credit_cards_ <= 0) { - registrar_.RemoveAll(); // Must be done from the DB thread. + registrar_.reset(); // Must be done from the DB thread. // Notify the UI thread that we're done listening for all relevant // autofill notifications. diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h index 2b3c7d2..ea0e1d6 100644 --- a/chrome/browser/automation/automation_provider_observers.h +++ b/chrome/browser/automation/automation_provider_observers.h @@ -1183,7 +1183,6 @@ class PasswordStoreLoginsChangedObserver IPC::Message* reply_message, PasswordStoreChange::Type expected_type, const std::string& result_key); - virtual ~PasswordStoreLoginsChangedObserver(); // Schedules a task on the DB thread to register the appropriate observers. virtual void Init(); @@ -1196,6 +1195,7 @@ class PasswordStoreLoginsChangedObserver private: friend struct content::BrowserThread::DeleteOnThread< content::BrowserThread::UI>; + ~PasswordStoreLoginsChangedObserver(); friend class base::DeleteHelper<PasswordStoreLoginsChangedObserver>; // Registers the appropriate observers. Called on the DB thread. @@ -1210,7 +1210,7 @@ class PasswordStoreLoginsChangedObserver base::WeakPtr<AutomationProvider> automation_; scoped_ptr<IPC::Message> reply_message_; - content::NotificationRegistrar registrar_; + scoped_ptr<content::NotificationRegistrar> registrar_; PasswordStoreChange::Type expected_type_; std::string result_key_; @@ -1407,7 +1407,6 @@ class AutofillChangedObserver IPC::Message* reply_message, int num_profiles, int num_credit_cards); - virtual ~AutofillChangedObserver(); // Schedules a task on the DB thread to register the appropriate observers. virtual void Init(); @@ -1420,6 +1419,7 @@ class AutofillChangedObserver private: friend struct content::BrowserThread::DeleteOnThread< content::BrowserThread::UI>; + ~AutofillChangedObserver(); friend class base::DeleteHelper<AutofillChangedObserver>; // Registers the appropriate observers. Called on the DB thread. @@ -1431,7 +1431,7 @@ class AutofillChangedObserver base::WeakPtr<AutomationProvider> automation_; scoped_ptr<IPC::Message> reply_message_; - content::NotificationRegistrar registrar_; + scoped_ptr<content::NotificationRegistrar> registrar_; int num_profiles_; int num_credit_cards_; |