Bug 756734 - Move checks inside Runnables to avoid race conditions. r=mfinkle
authorBrian Nicholson <bnicholson@mozilla.com>
Tue, 22 May 2012 18:32:32 -0700
changeset 94652 2ef3e8cef10230d6f0e605398f170fde1451cc8a
parent 94651 99878dcae029c1ef815b0246a2719476ea2f4bde
child 94653 021554387271c34a3859e397b4c7d714d0cbb79a
push id22732
push useremorley@mozilla.com
push dateWed, 23 May 2012 09:43:13 +0000
treeherdermozilla-central@aa2b52bd0374 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs756734
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 756734 - Move checks inside Runnables to avoid race conditions. r=mfinkle
mobile/android/base/GeckoApp.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -956,23 +956,22 @@ abstract public class GeckoApp
                 mMainHandler.post(new Runnable() {
                     public void run() {
                         dialogBuilder.show();
                     }
                 });
             } else if (event.equals("CharEncoding:State")) {
                 final boolean visible = message.getString("visible").equals("true");
                 GeckoPreferences.setCharEncodingState(visible);
-                if (sMenu != null) {
-                    mMainHandler.post(new Runnable() {
-                        public void run() {
+                mMainHandler.post(new Runnable() {
+                    public void run() {
+                        if (sMenu != null)
                             sMenu.findItem(R.id.char_encoding).setVisible(visible);
-                        }
-                    });
-                }
+                    }
+                });
             } else if (event.equals("Update:Restart")) {
                 doRestart("org.mozilla.gecko.restart_update");
             } else if (event.equals("Tab:ViewportMetadata")) {
                 int tabId = message.getInt("tabID");
                 Tab tab = Tabs.getInstance().getTab(tabId);
                 if (tab == null)
                     return;
                 tab.setAllowZoom(message.getBoolean("allowZoom"));
@@ -984,33 +983,31 @@ abstract public class GeckoApp
                 if (controller != null && Tabs.getInstance().isSelectedTab(tab)) {
                     controller.setAllowZoom(tab.getAllowZoom());
                     controller.setDefaultZoom(tab.getDefaultZoom());
                     controller.setMinZoom(tab.getMinZoom());
                     controller.setMaxZoom(tab.getMaxZoom());
                 }
             } else if (event.equals("Tab:HasTouchListener")) {
                 int tabId = message.getInt("tabID");
-                Tab tab = Tabs.getInstance().getTab(tabId);
+                final Tab tab = Tabs.getInstance().getTab(tabId);
                 tab.setHasTouchListeners(true);
-                if (Tabs.getInstance().isSelectedTab(tab)) {
-                    mMainHandler.post(new Runnable() {
-                        public void run() {
+                mMainHandler.post(new Runnable() {
+                    public void run() {
+                        if (Tabs.getInstance().isSelectedTab(tab))
                             mLayerController.getView().getTouchEventHandler().setWaitForTouchListeners(true);
-                        }
-                    });
-                }
+                    }
+                });
             } else if (event.equals("Session:StatePurged")) {
-                if (mAboutHomeContent != null) {
-                    mMainHandler.post(new Runnable() {
-                        public void run() {
+                mMainHandler.post(new Runnable() {
+                    public void run() {
+                        if (mAboutHomeContent != null)
                             mAboutHomeContent.setLastTabsVisibility(false);
-                        }
-                    });
-                }
+                    }
+                });
             } else if (event.equals("Bookmark:Insert")) {
                 final String url = message.getString("url");
                 final String title = message.getString("title");
                 mMainHandler.post(new Runnable() {
                     public void run() {
                         Toast.makeText(GeckoApp.mAppContext, R.string.bookmark_added, Toast.LENGTH_SHORT).show();
                         GeckoAppShell.getHandler().post(new Runnable() {
                             public void run() {