Index: base/android/java/src/org/chromium/base/TraceEvent.java |
diff --git a/base/android/java/src/org/chromium/base/TraceEvent.java b/base/android/java/src/org/chromium/base/TraceEvent.java |
index 878275c2b80a60b28a8b763a53cdc5441d3c0a83..95d01dcef21e26d75c3c8d57c0d25eb7ed56e0ff 100644 |
--- a/base/android/java/src/org/chromium/base/TraceEvent.java |
+++ b/base/android/java/src/org/chromium/base/TraceEvent.java |
@@ -16,8 +16,8 @@ import org.chromium.base.annotations.JNINamespace; |
* Java mirror of Chrome trace event API. See base/trace_event/trace_event.h. Unlike the native |
* version, Java does not have stack objects, so a TRACE_EVENT() which does both TRACE_EVENT_BEGIN() |
* and TRACE_EVENT_END() in ctor/dtor is not possible. |
- * It is OK to use tracing before the native library has loaded, but such traces will |
- * be ignored. (Perhaps we could devise to buffer them up in future?). |
+ * It is OK to use tracing before the native library has loaded, in a slightly restricted fashion. |
+ * @see EarlyTraceEvent for details. |
*/ |
@JNINamespace("base::android") |
public class TraceEvent { |
@@ -179,6 +179,7 @@ public class TraceEvent { |
*/ |
@CalledByNative |
public static void setEnabled(boolean enabled) { |
+ if (enabled) EarlyTraceEvent.disable(); |
sEnabled = enabled; |
// Android M+ systrace logs this on its own. Only log it if not writing to Android systrace. |
if (sATraceEnabled) return; |
@@ -187,6 +188,15 @@ public class TraceEvent { |
} |
/** |
+ * May enable early tracing depending on the environment. |
+ * |
+ * Must be called after the command-line has been read. |
+ */ |
+ public static void maybeEnableEarlyTracing() { |
+ EarlyTraceEvent.maybeEnable(); |
+ } |
+ |
+ /** |
* Enables or disabled Android systrace path of Chrome tracing. If enabled, all Chrome |
* traces will be also output to Android systrace. Because of the overhead of Android |
* systrace, this is for WebView only. |
@@ -254,7 +264,7 @@ public class TraceEvent { |
* @param name The name of the event. |
*/ |
public static void begin(String name) { |
- if (sEnabled) nativeBegin(name, null); |
+ begin(name, null); |
} |
/** |
@@ -263,6 +273,7 @@ public class TraceEvent { |
* @param arg The arguments of the event. |
*/ |
public static void begin(String name, String arg) { |
+ EarlyTraceEvent.begin(name); |
if (sEnabled) nativeBegin(name, arg); |
} |
@@ -271,7 +282,7 @@ public class TraceEvent { |
* @param name The name of the event. |
*/ |
public static void end(String name) { |
- if (sEnabled) nativeEnd(name, null); |
+ end(name, null); |
} |
/** |
@@ -280,6 +291,7 @@ public class TraceEvent { |
* @param arg The arguments of the event. |
*/ |
public static void end(String name, String arg) { |
+ EarlyTraceEvent.end(name); |
if (sEnabled) nativeEnd(name, arg); |
} |