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

Unified Diff: base/android/java/src/org/chromium/base/TraceEvent.java

Issue 1188623002: Avoid redundant Looper tracing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: early-out Created 5 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3d3b11a04196cf40fe1179c3104eacd22c3285b7..9ace4a17de5187c6d7571f9b52cc4eb5a87756b0 100644
--- a/base/android/java/src/org/chromium/base/TraceEvent.java
+++ b/base/android/java/src/org/chromium/base/TraceEvent.java
@@ -20,6 +20,7 @@ import android.util.Printer;
public class TraceEvent {
private static volatile boolean sEnabled = false;
+ private static volatile boolean sATraceEnabled = false; // True when taking an Android systrace.
private static class BasicLooperMonitor implements Printer {
@Override
@@ -176,6 +177,8 @@ public class TraceEvent {
@CalledByNative
public static void setEnabled(boolean enabled) {
sEnabled = enabled;
+ // Android M+ systrace logs this on its own. Only log it if not writing to Android systrace.
+ if (sATraceEnabled) return;
ThreadUtils.getUiThreadLooper().setMessageLogging(
enabled ? LooperMonitorHolder.sInstance : null);
}
@@ -186,10 +189,15 @@ public class TraceEvent {
* systrace, this is for WebView only.
*/
public static void setATraceEnabled(boolean enabled) {
- if (sEnabled == enabled) return;
+ if (sATraceEnabled == enabled) return;
+ sATraceEnabled = enabled;
if (enabled) {
+ // Calls TraceEvent.setEnabled(true) via
+ // TraceLog::EnabledStateObserver::OnTraceLogEnabled
nativeStartATrace();
} else {
+ // Calls TraceEvent.setEnabled(false) via
+ // TraceLog::EnabledStateObserver::OnTraceLogDisabled
nativeStopATrace();
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698