Bug 726379 - Remove CheckBookmarkTask, use a simple Runnable. r=sriram a=blocking-fennec
authorGian-Carlo Pascutto <gpascutto@mozilla.com>
Thu, 19 Apr 2012 16:41:53 +0200
changeset 95273 2d335134f808ee73bfff826989ff430b90e95185
parent 95272 1008d821954027da80f841b151e134c4a4c01b74
child 95274 12a595c5d7a40ec2e3a9d46d45b28a136060ea8a
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssriram, blocking-fennec
bugs726379
milestone14.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 726379 - Remove CheckBookmarkTask, use a simple Runnable. r=sriram a=blocking-fennec
mobile/android/base/Tab.java
--- a/mobile/android/base/Tab.java
+++ b/mobile/android/base/Tab.java
@@ -77,17 +77,16 @@ public final class Tab {
     private Drawable mThumbnail;
     private List<HistoryEntry> mHistory;
     private int mHistoryIndex;
     private int mParentId;
     private boolean mExternal;
     private boolean mBookmark;
     private HashMap<String, DoorHanger> mDoorHangers;
     private long mFaviconLoadId;
-    private CheckBookmarkTask mCheckBookmarkTask;
     private String mDocumentURI;
     private String mContentType;
     private boolean mHasTouchListeners;
     private ArrayList<View> mPluginViews;
     private HashMap<Surface, Layer> mPluginLayers;
     private ContentResolver mContentResolver;
     private ContentObserver mContentObserver;
     private int mState;
@@ -368,27 +367,26 @@ public final class Tab {
         Log.i(LOGTAG, "Updated favicon URL for tab with id: " + mId);
     }
 
     public void updateSecurityMode(String mode) {
         mSecurityMode = mode;
     }
 
     private void updateBookmark() {
-        GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
-            public void run() {
-                if (mCheckBookmarkTask != null)
-                    mCheckBookmarkTask.cancel(false);
+        final String url = getURL();
+        if (url == null)
+            return;
 
-                String url = getURL();
-                if (url == null)
-                    return;
-
-                mCheckBookmarkTask = new CheckBookmarkTask(url);
-                mCheckBookmarkTask.execute();
+        GeckoBackgroundThread.getHandler().post(new Runnable() {
+            public void run() {
+                boolean bookmark = BrowserDB.isBookmark(mContentResolver, url);
+                if (url.equals(getURL())) {
+                    mBookmark = bookmark;
+                }
             }
         });
     }
 
     public void addBookmark() {
         GeckoAppShell.getHandler().post(new Runnable() {
             public void run() {
                 String url = getURL();
@@ -519,50 +517,16 @@ public final class Tab {
             }
             mHistoryIndex = index;
         } else if (event.equals("Purge")) {
             mHistory.clear();
             mHistoryIndex = -1;
         }
     }
 
-    private final class CheckBookmarkTask extends AsyncTask<Void, Void, Boolean> {
-        private final String mUrl;
-
-        public CheckBookmarkTask(String url) {
-            mUrl = url;
-        }
-
-        @Override
-        protected Boolean doInBackground(Void... unused) {
-            return BrowserDB.isBookmark(mContentResolver, mUrl);
-        }
-
-        @Override
-        protected void onCancelled() {
-            mCheckBookmarkTask = null;
-        }
-
-        @Override
-        protected void onPostExecute(final Boolean isBookmark) {
-            mCheckBookmarkTask = null;
-
-            GeckoApp.mAppContext.runOnUiThread(new Runnable() {
-                public void run() {
-                    // Ignore this task if it's not about the current
-                    // tab URL anymore.
-                    if (!mUrl.equals(getURL()))
-                        return;
-
-                    mBookmark = isBookmark.booleanValue();
-                }
-            });
-        }
-    }
-
     private void saveThumbnailToDB(BitmapDrawable thumbnail) {
         try {
             String url = getURL();
             if (url == null)
                 return;
 
             BrowserDB.updateThumbnailForUrl(mContentResolver, url, thumbnail);
         } catch (Exception e) {