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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ScreenOrientationListener.java

Issue 182623003: ObserverList add/remove methods should return a boolean. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screen_orientation_listener
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/ScreenOrientationListener.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ScreenOrientationListener.java b/content/public/android/java/src/org/chromium/content/browser/ScreenOrientationListener.java
index 7e12861b129d8745c3025f5efc9c841fa0009e3a..37222b411953ff5e02cd7a93686e88fdc9219361 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ScreenOrientationListener.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ScreenOrientationListener.java
@@ -10,6 +10,7 @@ import android.content.res.Configuration;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
import android.os.Build;
+import android.util.Log;
import android.view.Surface;
import android.view.WindowManager;
@@ -192,12 +193,10 @@ class ScreenOrientationListener {
assert mAppContext == context.getApplicationContext();
assert mAppContext != null;
- // TODO(mlamouri): we should check if the observer was really added,
- // http://crbug.com/347557
- if (mObservers.hasObserver(observer)) {
+ if (!mObservers.addObserver(observer)) {
+ Log.w(TAG, "Adding an observer that is already present!");
return;
}
- mObservers.addObserver(observer);
mObserverCount++;
// If we got our first observer, we should start listening.
@@ -224,12 +223,10 @@ class ScreenOrientationListener {
* @param observer The observer that will no longer receive notification.
*/
public void removeObserver(ScreenOrientationObserver observer) {
- // TODO(mlamouri): we should check if the observer was really removed,
- // http://crbug.com/347557
- if (!mObservers.hasObserver(observer)) {
+ if (!mObservers.removeObserver(observer)) {
+ Log.w(TAG, "Removing an inexistent observer!");
return;
}
- mObservers.removeObserver(observer);
mObserverCount--;
if (mObserverCount == 0) {

Powered by Google App Engine
This is Rietveld 408576698