Index: sdk/lib/developer/timeline.dart |
diff --git a/sdk/lib/developer/timeline.dart b/sdk/lib/developer/timeline.dart |
index fbdad8bef73f81375aaf5980233af052d7717919..b6118af6eabf3a337c7f9a5b1a36b864e1e7798d 100644 |
--- a/sdk/lib/developer/timeline.dart |
+++ b/sdk/lib/developer/timeline.dart |
@@ -23,6 +23,11 @@ class Timeline { |
'name', |
'Must be a String'); |
} |
+ if (!_isDartStreamEnabled()) { |
+ // Push a null onto the stack and return. |
+ _stack.add(null); |
+ return; |
+ } |
var block = new _SyncBlock._(name, _getTraceClock(), _getThreadCpuClock()); |
if (arguments is Map) { |
block._appendArguments(arguments); |
@@ -41,6 +46,10 @@ class Timeline { |
} |
// Pop top item off of stack. |
var block = _stack.removeLast(); |
+ if (block == null) { |
+ // Dart stream was disabled when startSync was called. |
+ return; |
+ } |
// Finish it. |
block.finish(); |
} |
@@ -55,6 +64,10 @@ class Timeline { |
'name', |
'Must be a String'); |
} |
+ if (!_isDartStreamEnabled()) { |
+ // Stream is disabled. |
+ return; |
+ } |
Map instantArguments; |
if (arguments is Map) { |
instantArguments = new Map.from(arguments); |
@@ -278,6 +291,9 @@ String _argumentsAsJson(Map arguments) { |
return JSON.encode(arguments); |
} |
+/// Returns true if the Dart Timeline stream is enabled. |
+external bool _isDartStreamEnabled(); |
+ |
/// Returns the next async task id. |
external int _getNextAsyncId(); |