Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Issue 426153006: Ensure Java DistilledPagePrefs observers can only be added once. (Closed)

Created:
6 years, 4 months ago by sunangel
Modified:
6 years, 4 months ago
Reviewers:
robliao, nyquist, rgustafson
CC:
chromium-reviews, smaslo, nyquist
Project:
chromium
Visibility:
Public.

Description

Ensure 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 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+32 lines, -6 lines) Patch
M chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java View 1 2 1 chunk +16 lines, -0 lines 0 comments Download
M components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java View 1 2 3 1 chunk +16 lines, -6 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
sunangel
Should be a quick CL.
6 years, 4 months ago (2014-07-30 21:56:48 UTC) #1
sunangel
Should be a quick CL.
6 years, 4 months ago (2014-07-30 21:56:49 UTC) #2
nyquist
Remember to have a newline after the first line in the description. Also, could you ...
6 years, 4 months ago (2014-07-30 22:08:13 UTC) #3
sunangel
https://codereview.chromium.org/426153006/diff/1/components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java File components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java (right): https://codereview.chromium.org/426153006/diff/1/components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java#newcode69 components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java:69: if (mObserverMap.get(obs) == null) { On 2014/07/30 22:08:12, nyquist ...
6 years, 4 months ago (2014-07-30 23:09:20 UTC) #4
sunangel
New patch for consistency of return for AddObserver and RemoveObserver
6 years, 4 months ago (2014-07-31 00:42:02 UTC) #5
robliao
https://codereview.chromium.org/426153006/diff/40001/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java File chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java (right): https://codereview.chromium.org/426153006/diff/40001/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java#newcode105 chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java:105: // Delete the observer the first time. Fix tab ...
6 years, 4 months ago (2014-07-31 00:51:37 UTC) #6
sunangel
https://codereview.chromium.org/426153006/diff/40001/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java File chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java (right): https://codereview.chromium.org/426153006/diff/40001/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java#newcode105 chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java:105: // Delete the observer the first time. On 2014/07/31 ...
6 years, 4 months ago (2014-07-31 01:44:29 UTC) #7
robliao
lgtm
6 years, 4 months ago (2014-07-31 17:20:26 UTC) #8
nyquist
mostly lg https://codereview.chromium.org/426153006/diff/60001/components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java File components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java (right): https://codereview.chromium.org/426153006/diff/60001/components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java#newcode70 components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java:70: * @return true if the observerMap was ...
6 years, 4 months ago (2014-08-01 04:30:39 UTC) #9
sunangel
https://codereview.chromium.org/426153006/diff/60001/components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java File components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java (right): https://codereview.chromium.org/426153006/diff/60001/components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java#newcode70 components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java:70: * @return true if the observerMap was changed as ...
6 years, 4 months ago (2014-08-04 19:56:25 UTC) #10
nyquist
lgtm Maybe you could add a sentence to the description about adding a return value ...
6 years, 4 months ago (2014-08-06 21:51:49 UTC) #11
sunangel
The CQ bit was checked by sunangel@chromium.org
6 years, 4 months ago (2014-08-06 22:08:09 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/sunangel@chromium.org/426153006/80001
6 years, 4 months ago (2014-08-06 22:09:41 UTC) #13
commit-bot: I haz the power
6 years, 4 months ago (2014-08-07 00:10:08 UTC) #14
Message was sent while issue was closed.
Change committed as 287911

Powered by Google App Engine
This is Rietveld 408576698