DescriptionEnsure Java DistilledPagePrefs observers can only be added once.
The Java DistilledPagePrefs observers are wrapped in a
native observer, which is only deleted when the observer is
removed again. Since the reference to this native observer
wrapper is kept in a Java map with the real Java observer as
the key, the second time addObserver(foo) is called with the
same observer, the first reference is lost, and the native
object is leaked.
For example, the following would leak a native object:
addObserver(foo);
addObserver(foo);
removeObserver(foo);
removeObserver(foo);
It is already safe to remove an observer if it is not
currently an observer, and this CL ensures that an observer
can only be added once, so the second calls to
addObserver(foo) and removeObserver(foo) will be no-ops.
addObserver and removeObserver will return a boolean based
on whether they have successfully completed the operation.
BUG=383630
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=287911
Patch Set 1 #
Total comments: 2
Patch Set 2 : Changed return value of remove/add observer, added test #
Total comments: 4
Patch Set 3 : brackets and tabbing #
Total comments: 4
Patch Set 4 : styling #
Messages
Total messages: 14 (0 generated)
|