New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 875176 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Aug 21
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

The public detach method in password controller seems useless

Project Member Reported by scottwu@chromium.org, Aug 17

Issue description

Currently the public detach method in password controller is called from three places:
1. webStateDestroyed callback in PasswordTabHelper class.
2. dealloc method of PasswordController class.
3. webStateDestroyed callback in PasswordController class.

Thus, this method will be called 3 times when a tab is closed, which is kind of duplication.

The detach call in PasswordTabHelper class should be safely removed, since they are observing the same webState.
If webStateDestroyed is guaranteed to be called (Is this true?), there is no need to repeat that in dealloc again.
Also it is not recommended to send message to self in dealloc method, per http://go/objc-style#avoid-messaging-the-current-object-within-initializers-and-dealloc

What's more, the public detach method is harmful because it introduces the possibility of an additional state between a normal webState and a destroyed webState. That is to say, if detach method is called before webStateDestroyed is called, the webState ivar will be set to nil and all observers will be removed, but it is NOT yet destroyed. The current code in password controller have an isWebStateDestroyed property to indicate this situation, when some logic like passwordManager->OnPasswordFormSubmitted() is still able to proceed even if the webState is already set to nil. 

It will be nice if we can remove the public detach method and move the logic into webStateDestroyed callback of Password Controller directly. So that all the complicity coming with it can be simplified.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Aug 20

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5f6d548aeb092a512dcfdbc15d56b87507918eba

commit 5f6d548aeb092a512dcfdbc15d56b87507918eba
Author: Scott Wu <scottwu@chromium.org>
Date: Mon Aug 20 10:36:01 2018

Remove the public detach method from password controller.

Please see detail description in the bug.

Bug:  875176 
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ib6c09079db1475deca5983a929335eda6e1bf1b3
Reviewed-on: https://chromium-review.googlesource.com/1179546
Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: Hiroshi Ichikawa <ichikawa@chromium.org>
Commit-Queue: Scott Wu <scottwu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584397}
[modify] https://crrev.com/5f6d548aeb092a512dcfdbc15d56b87507918eba/ios/chrome/browser/passwords/password_controller.h
[modify] https://crrev.com/5f6d548aeb092a512dcfdbc15d56b87507918eba/ios/chrome/browser/passwords/password_controller.mm
[modify] https://crrev.com/5f6d548aeb092a512dcfdbc15d56b87507918eba/ios/chrome/browser/passwords/password_controller_unittest.mm
[modify] https://crrev.com/5f6d548aeb092a512dcfdbc15d56b87507918eba/ios/chrome/browser/passwords/password_tab_helper.mm

Status: Assigned (was: Untriaged)
Is it fixed?
Status: Fixed (was: Assigned)
Yes, it is fixed, thanks!

Sign in to add a comment