Chromium Code Reviews| Index: sdk/lib/_internal/js_runtime/lib/developer_patch.dart |
| diff --git a/sdk/lib/_internal/js_runtime/lib/developer_patch.dart b/sdk/lib/_internal/js_runtime/lib/developer_patch.dart |
| index 541658b12897eabaea9dd4738af05f9d3195ed4e..4cefe98820cdd4dc8bd15be1b1d44265ec526b43 100644 |
| --- a/sdk/lib/_internal/js_runtime/lib/developer_patch.dart |
| +++ b/sdk/lib/_internal/js_runtime/lib/developer_patch.dart |
| @@ -46,7 +46,7 @@ _registerExtension(String method, ServiceExtensionHandler handler) { |
| } |
| @patch |
| -_postEvent(String eventKind, String eventData) { |
| +void _postEvent(String eventKind, String eventData) { |
|
Kevin Millikin (Google)
2017/01/04 15:31:04
Patch files cannot change the return type. In thi
|
| // TODO. |
| } |
| @@ -129,4 +129,51 @@ void _webServerControl(SendPort sendPort, bool enable) { |
| @patch |
| String _getIsolateIDFromSendPort(SendPort sendPort) { |
| return null; |
| -} |
| +} |
| + |
| +@patch |
| +class UserTag { |
| + @patch |
| + factory UserTag(String label) = _FakeUserTag; |
| + |
| + @patch |
| + static UserTag get defaultTag => _FakeUserTag._defaultTag; |
| +} |
| + |
| +class _FakeUserTag implements UserTag { |
|
Kevin Millikin (Google)
2017/01/04 15:31:04
This implementation machinery was in the SDK and i
|
| + static Map _instances = {}; |
| + |
| + _FakeUserTag.real(this.label); |
| + |
| + factory _FakeUserTag(String label) { |
| + // Canonicalize by name. |
| + var existingTag = _instances[label]; |
| + if (existingTag != null) { |
| + return existingTag; |
| + } |
| + // Throw an exception if we've reached the maximum number of user tags. |
| + if (_instances.length == UserTag.MAX_USER_TAGS) { |
| + throw new UnsupportedError( |
| + 'UserTag instance limit (${UserTag.MAX_USER_TAGS}) reached.'); |
| + } |
| + // Create a new instance and add it to the instance map. |
| + var instance = new _FakeUserTag.real(label); |
| + _instances[label] = instance; |
| + return instance; |
| + } |
| + |
| + final String label; |
| + |
| + UserTag makeCurrent() { |
| + var old = _currentTag; |
| + _currentTag = this; |
| + return old; |
| + } |
| + |
| + static final UserTag _defaultTag = new _FakeUserTag('Default'); |
| +} |
| + |
| +var _currentTag = _FakeUserTag._defaultTag; |
| + |
| +@patch |
| +UserTag getCurrentTag() => _currentTag; |