diff options
author | wajahat.s@samsung.com <wajahat.s@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-15 10:29:44 +0000 |
---|---|---|
committer | wajahat.s@samsung.com <wajahat.s@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-15 10:29:44 +0000 |
commit | 00e83ddc5768db1d6d784930e746bfb8a3c60c5e (patch) | |
tree | 75c3af86f76ba0a88541153739b476bc983605d5 | |
parent | 9c70c93c1ace3ae2e60ad8f9d0abe815e390fc6a (diff) | |
download | chromium_src-00e83ddc5768db1d6d784930e746bfb8a3c60c5e.zip chromium_src-00e83ddc5768db1d6d784930e746bfb8a3c60c5e.tar.gz chromium_src-00e83ddc5768db1d6d784930e746bfb8a3c60c5e.tar.bz2 |
Correct the usage of finalize in TracingControllerAndroid class.
TracingControllerAndroid should destroy its native instance when it
is done instead of relying on finalize() to destroy it, as vm does
not guaranteed finalize() will be called.
(source: http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#finalize%28%29)
Implement destroy() to immediately destroy native instance.
BUG=None.
Review URL: https://codereview.chromium.org/386983002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283177 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 12 insertions, 0 deletions
@@ -272,6 +272,7 @@ Mirela Budaes <mbudaes@adobe.com> Mitchell Rosen <mitchellwrosen@chromium.org> Mohamed I. Hammad <ibraaaa@gmail.com> Mohamed Mansour <m0.interactive@gmail.com> +Mohammed Wajahat Ali Siddiqui <wajahat.s@samsung.com> Mrunal Kapade <mrunal.kapade@intel.com> Myles C. Maxfield <mymax@amazon.com> Naiem Shaik <naiem.shaik@gmail.com> diff --git a/content/public/android/java/src/org/chromium/content/app/ContentApplication.java b/content/public/android/java/src/org/chromium/content/app/ContentApplication.java index 7b6f50e..b124224 100644 --- a/content/public/android/java/src/org/chromium/content/app/ContentApplication.java +++ b/content/public/android/java/src/org/chromium/content/app/ContentApplication.java @@ -56,6 +56,7 @@ public class ContentApplication extends BaseChromiumApplication { public void onTerminate() { try { getTracingController().unregisterReceiver(this); + getTracingController().destroy(); } catch (SecurityException e) { // Happens if the process is isolated. Ignore. } diff --git a/content/public/android/java/src/org/chromium/content/browser/TracingControllerAndroid.java b/content/public/android/java/src/org/chromium/content/browser/TracingControllerAndroid.java index b89205c..514ab6a 100644 --- a/content/public/android/java/src/org/chromium/content/browser/TracingControllerAndroid.java +++ b/content/public/android/java/src/org/chromium/content/browser/TracingControllerAndroid.java @@ -242,6 +242,15 @@ public class TracingControllerAndroid { @Override protected void finalize() { + // Ensure that destroy() was called. + assert mNativeTracingControllerAndroid == 0; + } + + /** + * Clean up the C++ side of this class. + * After the call, this class instance shouldn't be used. + */ + public void destroy() { if (mNativeTracingControllerAndroid != 0) { nativeDestroy(mNativeTracingControllerAndroid); mNativeTracingControllerAndroid = 0; diff --git a/content/public/android/javatests/src/org/chromium/content/browser/TracingControllerAndroidTest.java b/content/public/android/javatests/src/org/chromium/content/browser/TracingControllerAndroidTest.java index 8f98189..72d6c68 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/TracingControllerAndroidTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/TracingControllerAndroidTest.java @@ -61,5 +61,6 @@ public class TracingControllerAndroidTest extends ContentShellTestBase { // It says it stopped, so it should have written the output file. assertTrue(file.exists()); assertTrue(file.delete()); + tracingController.destroy(); } } |