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

Unified Diff: content/public/android/java/src/org/chromium/content/common/TraceEvent.java

Issue 12221047: Support JellyBean MR2 style of systrace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits Created 7 years, 10 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
« no previous file with comments | « content/common/android/trace_event_binding.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/common/TraceEvent.java
diff --git a/content/public/android/java/src/org/chromium/content/common/TraceEvent.java b/content/public/android/java/src/org/chromium/content/common/TraceEvent.java
index 67c5413093dbb453698e1106eb46b1f7f8fc97ee..74592e2d408aeeb914b3b0d7cf8677df736117db 100644
--- a/content/public/android/java/src/org/chromium/content/common/TraceEvent.java
+++ b/content/public/android/java/src/org/chromium/content/common/TraceEvent.java
@@ -37,6 +37,32 @@ public class TraceEvent {
}
}
+ static {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ try {
+ Class<?> systemPropertiesClass = Class.forName("android.os.SystemProperties");
+ Method addChangeCallbackMethod = systemPropertiesClass.getDeclaredMethod(
+ "addChangeCallback", Runnable.class);
+ addChangeCallbackMethod.invoke(null, new Runnable() {
+ @Override
+ public void run() {
+ setEnabledToMatchNative();
+ }
+ });
+ } catch (ClassNotFoundException e) {
+ Log.e("TraceEvent", "init", e);
+ } catch (NoSuchMethodException e) {
+ Log.e("TraceEvent", "init", e);
+ } catch (IllegalArgumentException e) {
+ Log.e("TraceEvent", "init", e);
+ } catch (IllegalAccessException e) {
+ Log.e("TraceEvent", "init", e);
+ } catch (InvocationTargetException e) {
+ Log.e("TraceEvent", "init", e);
+ }
+ }
+ }
+
/**
* Calling this will cause enabled() to be updated to match that set on the native side.
* The native library must be loaded before calling this method.
@@ -47,11 +73,22 @@ public class TraceEvent {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
try {
Class<?> traceClass = Class.forName("android.os.Trace");
- Method m = traceClass.getDeclaredMethod("isTagEnabled", Long.TYPE);
- Field f = traceClass.getField("TRACE_TAG_VIEW");
- boolean atraceEnabled = (Boolean) m.invoke(traceClass, f.getLong(null));
- if (atraceEnabled) nativeInitATrace();
- enabled = enabled || atraceEnabled;
+ long traceTagView = traceClass.getField("TRACE_TAG_VIEW").getLong(null);
+ String propertyTraceTagEnableFlags = (String) traceClass.getField(
+ "PROPERTY_TRACE_TAG_ENABLEFLAGS").get(null);
+
+ Class<?> systemPropertiesClass = Class.forName("android.os.SystemProperties");
+ Method systemPropertiesGetIntMethod = systemPropertiesClass.getDeclaredMethod(
Jay Civelli 2013/02/14 17:56:28 Nit: rename systemPropertiesGetLongMethod
Xianzhu 2013/02/14 18:00:55 Done.
+ "getLong", String.class, Long.TYPE);
+ long enabledFlags = (Long) systemPropertiesGetIntMethod.invoke(
+ null, propertyTraceTagEnableFlags, 0);
+ Log.d("TraceEvent", "New enabled flags: " + enabledFlags);
+ if ((enabledFlags & traceTagView) != 0) {
+ nativeStartATrace();
+ enabled = true;
+ } else {
+ nativeStopATrace();
+ }
} catch (ClassNotFoundException e) {
Log.e("TraceEvent", "setEnabledToMatchNative", e);
} catch (NoSuchMethodException e) {
@@ -236,7 +273,8 @@ public class TraceEvent {
}
private static native boolean nativeTraceEnabled();
- private static native void nativeInitATrace();
+ private static native void nativeStartATrace();
+ private static native void nativeStopATrace();
private static native void nativeInstant(String name, String arg);
private static native void nativeBegin(String name, String arg);
private static native void nativeEnd(String name, String arg);
« no previous file with comments | « content/common/android/trace_event_binding.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698