| 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 f26b274165437d100d0f912eaf62d68f0c2a4e32..313309106a1943611dcaa4a09bc132cf7fecc5d5 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
|
| @@ -46,6 +46,7 @@ public class TracingControllerAndroid {
|
|
|
| private static final String ACTION_START = "GPU_PROFILER_START";
|
| private static final String ACTION_STOP = "GPU_PROFILER_STOP";
|
| + private static final String ACTION_GET_CATEGORY = "GPU_PROFILER_LIST_CATEGORY";
|
| private static final String FILE_EXTRA = "file";
|
| private static final String CATEGORIES_EXTRA = "categories";
|
| private static final String RECORD_CONTINUOUSLY_EXTRA = "continuous";
|
| @@ -152,6 +153,12 @@ public class TracingControllerAndroid {
|
| return startTracing(filePath, showToasts, categories, recordContinuously);
|
| }
|
|
|
| + private void initializeNativeControllerIfNeeded() {
|
| + if (mNativeTracingControllerAndroid == 0) {
|
| + mNativeTracingControllerAndroid = nativeInit();
|
| + }
|
| + }
|
| +
|
| /**
|
| * Start profiling to the specified file. Returns true on success.
|
| *
|
| @@ -177,9 +184,7 @@ public class TracingControllerAndroid {
|
| return false;
|
| }
|
| // Lazy initialize the native side, to allow construction before the library is loaded.
|
| - if (mNativeTracingControllerAndroid == 0) {
|
| - mNativeTracingControllerAndroid = nativeInit();
|
| - }
|
| + initializeNativeControllerIfNeeded();
|
| if (!nativeStartTracing(mNativeTracingControllerAndroid, categories,
|
| recordContinuously)) {
|
| logAndToastError(mContext.getString(R.string.profiler_error_toast));
|
| @@ -218,6 +223,29 @@ public class TracingControllerAndroid {
|
| mFilename = null;
|
| }
|
|
|
| + /**
|
| + * Get known category groups.
|
| + */
|
| + public void getCategoryGroups() {
|
| + // Lazy initialize the native side, to allow construction before the library is loaded.
|
| + initializeNativeControllerIfNeeded();
|
| + if (!nativeGetKnownCategoryGroupsAsync(mNativeTracingControllerAndroid)) {
|
| + onCategoryGroupsReceived(null);
|
| + return;
|
| + }
|
| + }
|
| +
|
| + /**
|
| + * Called by native code when we receive the result of ping for known category groups.
|
| + */
|
| + @CalledByNative
|
| + protected void onCategoryGroupsReceived(String categoryList) {
|
| + if (categoryList != null)
|
| + Log.i(TAG, "{\"traceCategoriesList\": " + categoryList + "}");
|
| + else
|
| + Log.i(TAG, "Failed to fetch tracing category list.");
|
| + }
|
| +
|
| @Override
|
| protected void finalize() {
|
| if (mNativeTracingControllerAndroid != 0) {
|
| @@ -240,6 +268,7 @@ public class TracingControllerAndroid {
|
| TracingIntentFilter(Context context) {
|
| addAction(context.getPackageName() + "." + ACTION_START);
|
| addAction(context.getPackageName() + "." + ACTION_STOP);
|
| + addAction(context.getPackageName() + "." + ACTION_GET_CATEGORY);
|
| }
|
| }
|
|
|
| @@ -264,6 +293,8 @@ public class TracingControllerAndroid {
|
| }
|
| } else if (intent.getAction().endsWith(ACTION_STOP)) {
|
| stopTracing();
|
| + } else if (intent.getAction().endsWith(ACTION_GET_CATEGORY)) {
|
| + getCategoryGroups();
|
| } else {
|
| Log.e(TAG, "Unexpected intent: " + intent);
|
| }
|
| @@ -276,5 +307,6 @@ public class TracingControllerAndroid {
|
| private native boolean nativeStartTracing(
|
| long nativeTracingControllerAndroid, String categories, boolean recordContinuously);
|
| private native void nativeStopTracing(long nativeTracingControllerAndroid, String filename);
|
| + private native boolean nativeGetKnownCategoryGroupsAsync(long nativeTracingControllerAndroid);
|
| private native String nativeGetDefaultCategories();
|
| }
|
|
|