OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.base; | 5 package org.chromium.base; |
6 | 6 |
7 import android.os.Looper; | 7 import android.os.Looper; |
8 import android.os.MessageQueue; | 8 import android.os.MessageQueue; |
9 import android.os.SystemClock; | 9 import android.os.SystemClock; |
10 import android.util.Log; | 10 import android.util.Log; |
(...skipping 20 matching lines...) Expand all Loading... |
31 public void println(final String line) { | 31 public void println(final String line) { |
32 if (line.startsWith(">")) { | 32 if (line.startsWith(">")) { |
33 beginHandling(line); | 33 beginHandling(line); |
34 } else { | 34 } else { |
35 assert line.startsWith("<"); | 35 assert line.startsWith("<"); |
36 endHandling(line); | 36 endHandling(line); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 void beginHandling(final String line) { | 40 void beginHandling(final String line) { |
41 if (sEnabled) nativeBeginToplevel(); | 41 if (sEnabled) { |
| 42 // Android Looper formats |line| as ">>>>> Dispatching to (TARGE
T) [...]" since at |
| 43 // least 2009 (Donut). Extracts the TARGET part of the message. |
| 44 int start = line.indexOf('(', 21); // strlen(">>>>> Dispatching
to ") |
| 45 int end = start == -1 ? -1 : line.indexOf(')', start); |
| 46 String target = end != -1 ? line.substring(start + 1, end) : ""; |
| 47 nativeBeginToplevel(target); |
| 48 } |
42 } | 49 } |
43 | 50 |
44 void endHandling(final String line) { | 51 void endHandling(final String line) { |
45 if (sEnabled) nativeEndToplevel(); | 52 if (sEnabled) nativeEndToplevel(); |
46 } | 53 } |
47 } | 54 } |
48 | 55 |
49 /** | 56 /** |
50 * A class that records, traces and logs statistics about the UI thead's Loo
per. | 57 * A class that records, traces and logs statistics about the UI thead's Loo
per. |
51 * The output of this class can be used in a number of interesting ways: | 58 * The output of this class can be used in a number of interesting ways: |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 EarlyTraceEvent.end(name); | 307 EarlyTraceEvent.end(name); |
301 if (sEnabled) nativeEnd(name, arg); | 308 if (sEnabled) nativeEnd(name, arg); |
302 } | 309 } |
303 | 310 |
304 private static native void nativeRegisterEnabledObserver(); | 311 private static native void nativeRegisterEnabledObserver(); |
305 private static native void nativeStartATrace(); | 312 private static native void nativeStartATrace(); |
306 private static native void nativeStopATrace(); | 313 private static native void nativeStopATrace(); |
307 private static native void nativeInstant(String name, String arg); | 314 private static native void nativeInstant(String name, String arg); |
308 private static native void nativeBegin(String name, String arg); | 315 private static native void nativeBegin(String name, String arg); |
309 private static native void nativeEnd(String name, String arg); | 316 private static native void nativeEnd(String name, String arg); |
310 private static native void nativeBeginToplevel(); | 317 private static native void nativeBeginToplevel(String target); |
311 private static native void nativeEndToplevel(); | 318 private static native void nativeEndToplevel(); |
312 private static native void nativeStartAsync(String name, long id); | 319 private static native void nativeStartAsync(String name, long id); |
313 private static native void nativeFinishAsync(String name, long id); | 320 private static native void nativeFinishAsync(String name, long id); |
314 } | 321 } |
OLD | NEW |