Commit 887cfbc1 authored by Clemens Arbesser's avatar Clemens Arbesser Committed by Commit Bot

[Autofill Assistant] Login fetcher, remove listener on destruction

This CL ensures that the autofill assistant listener is removed.

Bug: 1007556
Change-Id: Id703f5ca610ab8982670814ed246248b6d7760b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1824079
Commit-Queue: Clemens Arbesser <arbesser@google.com>
Reviewed-by: default avatarMathias Carlen <mcarlen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699763}
parent b7ee0c52
......@@ -46,14 +46,21 @@ class WebsiteLoginFetcherImpl::PendingRequest
// This needs to be done asynchronously, because it will lead to the
// destruction of |this|, which needs to happen *after* this call has
// returned.
base::PostTask(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&PendingRequest::NotifyFinished,
weak_ptr_factory_.GetWeakPtr()));
if (notify_finished_callback_) {
base::PostTask(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&PendingRequest::NotifyFinished,
weak_ptr_factory_.GetWeakPtr(),
std::move(notify_finished_callback_)));
}
}
std::unique_ptr<password_manager::FormFetcher> form_fetcher_;
private:
void NotifyFinished() { std::move(notify_finished_callback_).Run(this); }
void NotifyFinished(
base::OnceCallback<void(const PendingRequest*)> callback) {
form_fetcher_->RemoveConsumer(this);
std::move(callback).Run(this);
}
base::OnceCallback<void(const PendingRequest*)> notify_finished_callback_;
base::WeakPtrFactory<PendingRequest> weak_ptr_factory_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment