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

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

Issue 257093004: [Android] Add an option to view the tracing record categories when running from python script. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor style cleanup! Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
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();
}

Powered by Google App Engine
This is Rietveld 408576698