Index: content/public/android/java/src/org/chromium/content/browser/TracingControllerAndroid.java |
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 514ab6ae324d36872a47248a1e149b9712789aa7..1ee5c5ee7545088518cd237a434dd9fca86a6175 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 |
@@ -41,6 +41,35 @@ import java.util.TimeZone; |
*/ |
@JNINamespace("content") |
public class TracingControllerAndroid { |
+ /** |
+ * Options for tracing. |
+ */ |
+ public enum TraceOptions { |
+ /** |
+ * Record traces until when the trace buffer is full, or stop tracing is called, |
+ * whichever comes first. The buffer size is defined in base/debug/trace_event_impl.cc. |
+ */ |
+ RECORD_UNTIL_FULL("record-until-full"), |
dsinclair
2014/07/28 18:52:36
Are we required to duplicate the options into ther
nednguyen
2014/07/28 20:27:22
This will call the nativeStartTracing(..) method w
|
+ |
+ /** |
+ * Record traces continuously until stop tracing is called using a trace buffer ring |
+ * buffer. When the ring buffer is full, oldest trace events are dropped so latest |
+ * trace events can be added. The ring buffer size is defined in |
+ * base/debug/trace_event_impl.cc. |
+ */ |
+ RECORD_CONTINUOUSLY("record-continuously"), |
+ ; |
+ |
+ private final String mText; |
+ |
+ private TraceOptions(String text) { |
+ mText = text; |
+ } |
+ |
+ public String toString() { |
+ return mText; |
+ } |
+ } |
private static final String TAG = "TracingControllerAndroid"; |
@@ -143,11 +172,11 @@ public class TracingControllerAndroid { |
/** |
* Start profiling to a new file in the Downloads directory. |
* |
- * Calls #startTracing(String, boolean, String, boolean) with a new timestamped filename. |
- * @see #startTracing(String, boolean, String, boolean) |
+ * Calls #startTracing(String, boolean, String, TraceOptions) with a new timestamped filename. |
+ * @see #startTracing(String, boolean, String, TraceOptions) |
*/ |
public boolean startTracing(boolean showToasts, String categories, |
- boolean recordContinuously) { |
+ TraceOptions traceOptions) { |
mShowToasts = showToasts; |
String filePath = generateTracingFilePath(); |
@@ -155,7 +184,7 @@ public class TracingControllerAndroid { |
logAndToastError( |
mContext.getString(R.string.profiler_no_storage_toast)); |
} |
- return startTracing(filePath, showToasts, categories, recordContinuously); |
+ return startTracing(filePath, showToasts, categories, traceOptions); |
} |
private void initializeNativeControllerIfNeeded() { |
@@ -177,11 +206,11 @@ public class TracingControllerAndroid { |
* notifications about the profiling system. |
* @param categories Which categories to trace. See TracingControllerAndroid::BeginTracing() |
* (in content/public/browser/trace_controller.h) for the format. |
- * @param recordContinuously Record until the user ends the trace. The trace buffer is fixed |
+ * @param traceOptions Record until the user ends the trace. The trace buffer is fixed |
* size and we use it as a ring buffer during recording. |
*/ |
public boolean startTracing(String filename, boolean showToasts, String categories, |
- boolean recordContinuously) { |
+ TraceOptions traceOptions) { |
mShowToasts = showToasts; |
if (isTracing()) { |
// Don't need a toast because this shouldn't happen via the UI. |
@@ -191,7 +220,7 @@ public class TracingControllerAndroid { |
// Lazy initialize the native side, to allow construction before the library is loaded. |
initializeNativeControllerIfNeeded(); |
if (!nativeStartTracing(mNativeTracingControllerAndroid, categories, |
- recordContinuously)) { |
+ traceOptions.toString())) { |
logAndToastError(mContext.getString(R.string.profiler_error_toast)); |
return false; |
} |
@@ -290,13 +319,14 @@ public class TracingControllerAndroid { |
categories = categories.replaceFirst( |
DEFAULT_CHROME_CATEGORIES_PLACE_HOLDER, nativeGetDefaultCategories()); |
} |
- boolean recordContinuously = |
- intent.getStringExtra(RECORD_CONTINUOUSLY_EXTRA) != null; |
+ TraceOptions traceOptions = |
+ intent.getStringExtra(RECORD_CONTINUOUSLY_EXTRA) == null ? |
+ TraceOptions.RECORD_UNTIL_FULL : TraceOptions.RECORD_CONTINUOUSLY; |
String filename = intent.getStringExtra(FILE_EXTRA); |
if (filename != null) { |
- startTracing(filename, true, categories, recordContinuously); |
+ startTracing(filename, true, categories, traceOptions); |
} else { |
- startTracing(true, categories, recordContinuously); |
+ startTracing(true, categories, traceOptions); |
} |
} else if (intent.getAction().endsWith(ACTION_STOP)) { |
stopTracing(); |
@@ -312,7 +342,7 @@ public class TracingControllerAndroid { |
private native long nativeInit(); |
private native void nativeDestroy(long nativeTracingControllerAndroid); |
private native boolean nativeStartTracing( |
- long nativeTracingControllerAndroid, String categories, boolean recordContinuously); |
+ long nativeTracingControllerAndroid, String categories, String traceOptions); |
private native void nativeStopTracing(long nativeTracingControllerAndroid, String filename); |
private native boolean nativeGetKnownCategoryGroupsAsync(long nativeTracingControllerAndroid); |
private native String nativeGetDefaultCategories(); |