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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/TracingControllerAndroid.java

Issue 386983002: Correct the usage of finalize in TracingControllerAndroid class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated as per comments Created 6 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.content.BroadcastReceiver; 7 import android.content.BroadcastReceiver;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.IntentFilter; 10 import android.content.IntentFilter;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 public void getCategoryGroups() { 235 public void getCategoryGroups() {
236 // Lazy initialize the native side, to allow construction before the lib rary is loaded. 236 // Lazy initialize the native side, to allow construction before the lib rary is loaded.
237 initializeNativeControllerIfNeeded(); 237 initializeNativeControllerIfNeeded();
238 if (!nativeGetKnownCategoryGroupsAsync(mNativeTracingControllerAndroid)) { 238 if (!nativeGetKnownCategoryGroupsAsync(mNativeTracingControllerAndroid)) {
239 Log.e(TAG, "Unable to fetch tracing record groups list."); 239 Log.e(TAG, "Unable to fetch tracing record groups list.");
240 } 240 }
241 } 241 }
242 242
243 @Override 243 @Override
244 protected void finalize() { 244 protected void finalize() {
245 // Ensure that destroy() was called.
246 assert mNativeTracingControllerAndroid == 0;
247 }
248
249 /**
250 * Clean up the C++ side of this class.
251 * After the call, this class instance shouldn't be used.
252 */
253 public void destroy() {
245 if (mNativeTracingControllerAndroid != 0) { 254 if (mNativeTracingControllerAndroid != 0) {
246 nativeDestroy(mNativeTracingControllerAndroid); 255 nativeDestroy(mNativeTracingControllerAndroid);
247 mNativeTracingControllerAndroid = 0; 256 mNativeTracingControllerAndroid = 0;
248 } 257 }
249 } 258 }
250 259
251 private void logAndToastError(String str) { 260 private void logAndToastError(String str) {
252 Log.e(TAG, str); 261 Log.e(TAG, str);
253 if (mShowToasts) Toast.makeText(mContext, str, Toast.LENGTH_SHORT).show( ); 262 if (mShowToasts) Toast.makeText(mContext, str, Toast.LENGTH_SHORT).show( );
254 } 263 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 310
302 private long mNativeTracingControllerAndroid; 311 private long mNativeTracingControllerAndroid;
303 private native long nativeInit(); 312 private native long nativeInit();
304 private native void nativeDestroy(long nativeTracingControllerAndroid); 313 private native void nativeDestroy(long nativeTracingControllerAndroid);
305 private native boolean nativeStartTracing( 314 private native boolean nativeStartTracing(
306 long nativeTracingControllerAndroid, String categories, boolean reco rdContinuously); 315 long nativeTracingControllerAndroid, String categories, boolean reco rdContinuously);
307 private native void nativeStopTracing(long nativeTracingControllerAndroid, S tring filename); 316 private native void nativeStopTracing(long nativeTracingControllerAndroid, S tring filename);
308 private native boolean nativeGetKnownCategoryGroupsAsync(long nativeTracingC ontrollerAndroid); 317 private native boolean nativeGetKnownCategoryGroupsAsync(long nativeTracingC ontrollerAndroid);
309 private native String nativeGetDefaultCategories(); 318 private native String nativeGetDefaultCategories();
310 } 319 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698