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

Unified Diff: sdk/lib/profiler/profiler.dart

Issue 266913010: Refactor 'dart:profiler' UserTag API (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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
Index: sdk/lib/profiler/profiler.dart
diff --git a/sdk/lib/profiler/profiler.dart b/sdk/lib/profiler/profiler.dart
index 56614ddec0c5cc7fb4db5bee186b9b692463b43d..ff07673335f8d06431aebd896a35af585f6d5cd9 100644
--- a/sdk/lib/profiler/profiler.dart
+++ b/sdk/lib/profiler/profiler.dart
@@ -14,8 +14,12 @@ abstract class UserTag {
/// Label of [this].
String get label;
- /// Make [this] the current tag for the isolate.
- makeCurrent();
+ /// Make [this] the current tag for the isolate. Returns the current tag
+ /// before setting.
+ UserTag makeCurrent();
+
+ /// The default [UserTag] with label 'Default'.
+ static UserTag get defaultTag => _FakeUserTag._defaultTag;
}
// This is a fake implementation of UserTag so that code can compile and run
@@ -45,22 +49,18 @@ class _FakeUserTag implements UserTag {
final String label;
- makeCurrent() {
+ UserTag makeCurrent() {
+ var old = _currentTag;
_currentTag = this;
+ return _currentTag;
Ivan Posva 2014/05/06 16:43:06 Shouldn't you be returning old here?
Cutch 2014/05/06 17:00:25 Done.
}
+
+ static final UserTag _defaultTag = new _FakeUserTag('Default');
}
-var _currentTag = null;
+var _currentTag = _FakeUserTag._defaultTag;
/// Returns the current [UserTag] for the isolate.
UserTag getCurrentTag() {
return _currentTag;
}
-
-/// Sets the current [UserTag] for the isolate to null. Returns current tag
-/// before clearing.
-UserTag clearCurrentTag() {
- var old = _currentTag;
- _currentTag = null;
- return old;
-}

Powered by Google App Engine
This is Rietveld 408576698