Bug 803700 - Remove unnecesary finalizers. r=blassey
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 22 Oct 2012 10:15:35 -0400
changeset 111163 ad3b66486ce34ebe0bd9d4ee18fd0afe1ee7d3e2
parent 111162 666a61b83149deb6aa89198e1f1098871b9e925c
child 111164 a2cdb1000e515efccf4884531088f62dd79b9a8b
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersblassey
bugs803700
milestone19.0a1
Bug 803700 - Remove unnecesary finalizers. r=blassey
mobile/android/base/Tab.java
mobile/android/base/gfx/BufferedCairoImage.java
mobile/android/base/gfx/CheckerboardImage.java
mobile/android/base/gfx/LayerRenderer.java
mobile/android/base/gfx/ScreenshotLayer.java
--- a/mobile/android/base/Tab.java
+++ b/mobile/android/base/Tab.java
@@ -163,20 +163,16 @@ public class Tab {
     }
 
     public Bitmap getThumbnailBitmap() {
         if (mThumbnailBitmap != null)
             return mThumbnailBitmap;
         return mThumbnailBitmap = Bitmap.createBitmap(Tabs.getThumbnailWidth(), Tabs.getThumbnailHeight(), Bitmap.Config.RGB_565);
     }
 
-    public void finalize() {
-        freeBuffer();
-    }
-
     synchronized void freeBuffer() {
         DirectBufferAllocator.free(mThumbnailBuffer);
         mThumbnailBuffer = null;
     }
 
     public void updateThumbnail(final Bitmap b) {
         final Tab tab = this;
         GeckoAppShell.getHandler().post(new Runnable() {
--- a/mobile/android/base/gfx/BufferedCairoImage.java
+++ b/mobile/android/base/gfx/BufferedCairoImage.java
@@ -30,24 +30,16 @@ public class BufferedCairoImage extends 
         setBitmap(bitmap);
     }
 
     private void freeBuffer() {
         DirectBufferAllocator.free(mBuffer);
         mBuffer = null;
     }
 
-    protected void finalize() throws Throwable {
-        try {
-            freeBuffer();
-        } finally {
-            super.finalize();
-        }
-    }
-
     @Override
     public void destroy() {
         try {
             freeBuffer();
         } catch (Exception ex) {
             Log.e(LOGTAG, "error clearing buffer: ", ex);
         }
     }
--- a/mobile/android/base/gfx/CheckerboardImage.java
+++ b/mobile/android/base/gfx/CheckerboardImage.java
@@ -110,26 +110,16 @@ public class CheckerboardImage extends C
     private short convertTo16Bit(int color) {
         int r = Color.red(color) >> 3, g = Color.green(color) >> 2, b = Color.blue(color) >> 3;
         int c = ((r << 11) | (g << 5) | b);
         // Swap endianness.
         return (short)((c >> 8) | ((c & 0xff) << 8));
     }
 
     @Override
-    protected void finalize() throws Throwable {
-        try {
-            DirectBufferAllocator.free(mBuffer);
-            mBuffer = null;
-        } finally {
-            super.finalize();
-        }
-    }
-
-    @Override
     public void destroy() {
         try {
             DirectBufferAllocator.free(mBuffer);
             mBuffer = null;
         } catch (Exception ex) {
             Log.e(LOGTAG, "error clearing buffer: ", ex);
         }
     }
--- a/mobile/android/base/gfx/LayerRenderer.java
+++ b/mobile/android/base/gfx/LayerRenderer.java
@@ -167,27 +167,16 @@ public class LayerRenderer implements Ta
         // coordinates in draw() commands.
         mCoordByteBuffer = DirectBufferAllocator.allocate(COORD_BUFFER_SIZE * 4);
         mCoordByteBuffer.order(ByteOrder.nativeOrder());
         mCoordBuffer = mCoordByteBuffer.asFloatBuffer();
 
         Tabs.registerOnTabsChangedListener(this);
     }
 
-    @Override
-    protected void finalize() throws Throwable {
-        try {
-            DirectBufferAllocator.free(mCoordByteBuffer);
-            mCoordByteBuffer = null;
-            mCoordBuffer = null;
-        } finally {
-            super.finalize();
-        }
-    }
-
     public void destroy() {
         DirectBufferAllocator.free(mCoordByteBuffer);
         mCoordByteBuffer = null;
         mCoordBuffer = null;
         mScreenshotLayer.destroy();
         mBackgroundLayer.destroy();
         mShadowLayer.destroy();
         mHorizScrollLayer.destroy();
--- a/mobile/android/base/gfx/ScreenshotLayer.java
+++ b/mobile/android/base/gfx/ScreenshotLayer.java
@@ -101,26 +101,16 @@ public class ScreenshotLayer extends Sin
         /** Creates a buffered Cairo image from a byte buffer. */
         public ScreenshotImage(ByteBuffer inBuffer, int inWidth, int inHeight, int inFormat) {
             mBuffer = inBuffer;
             mSize = new IntSize(inWidth, inHeight);
             mFormat = inFormat;
         }
 
         @Override
-        protected void finalize() throws Throwable {
-            try {
-                DirectBufferAllocator.free(mBuffer);
-                mBuffer = null;
-            } finally {
-                super.finalize();
-            }
-        }
-
-        @Override
         public synchronized void destroy() {
             try {
                 DirectBufferAllocator.free(mBuffer);
                 mBuffer = null;
             } catch (Exception ex) {
                 Log.e(LOGTAG, "error clearing buffers: ", ex);
             }
         }