| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 $if DART2JS | 7 $if DART2JS |
| 8 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS native "Wind
ow,DOMWindow" { | 8 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS native "Wind
ow,DOMWindow" { |
| 9 $else | 9 $else |
| 10 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 10 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 /** | 26 /** |
| 27 * Lookup a port by its [name]. Return null if no port is | 27 * Lookup a port by its [name]. Return null if no port is |
| 28 * registered under [name]. | 28 * registered under [name]. |
| 29 */ | 29 */ |
| 30 SendPortSync lookupPort(String name) { | 30 SendPortSync lookupPort(String name) { |
| 31 var portStr = document.documentElement.attributes['dart-port:$name']; | 31 var portStr = document.documentElement.attributes['dart-port:$name']; |
| 32 if (portStr == null) { | 32 if (portStr == null) { |
| 33 return null; | 33 return null; |
| 34 } | 34 } |
| 35 var port = json.parse(portStr); | 35 var port = JSON.decode(portStr); |
| 36 return _deserialize(port); | 36 return _deserialize(port); |
| 37 } | 37 } |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * Register a [port] on this window under the given [name]. This | 40 * Register a [port] on this window under the given [name]. This |
| 41 * port may be retrieved by any isolate (or JavaScript script) | 41 * port may be retrieved by any isolate (or JavaScript script) |
| 42 * running in this window. | 42 * running in this window. |
| 43 */ | 43 */ |
| 44 void registerPort(String name, var port) { | 44 void registerPort(String name, var port) { |
| 45 var serialized = _serialize(port); | 45 var serialized = _serialize(port); |
| 46 document.documentElement.attributes['dart-port:$name'] = | 46 document.documentElement.attributes['dart-port:$name'] = |
| 47 json.stringify(serialized); | 47 JSON.encode(serialized); |
| 48 } | 48 } |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Deregister a [port] on this window under the given [name]. This | 51 * Deregister a [port] on this window under the given [name]. This |
| 52 * port may be retrieved by any isolate (or JavaScript script) | 52 * port may be retrieved by any isolate (or JavaScript script) |
| 53 * running in this window. | 53 * running in this window. |
| 54 */ | 54 */ |
| 55 void deregisterPort(String name) { | 55 void deregisterPort(String name) { |
| 56 document.documentElement.attributes.remove('dart-port:$name'); | 56 document.documentElement.attributes.remove('dart-port:$name'); |
| 57 } | 57 } |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 return wrapped.returnValue; | 348 return wrapped.returnValue; |
| 349 }); | 349 }); |
| 350 | 350 |
| 351 return controller.stream; | 351 return controller.stream; |
| 352 } | 352 } |
| 353 | 353 |
| 354 String getEventType(EventTarget target) { | 354 String getEventType(EventTarget target) { |
| 355 return _eventType; | 355 return _eventType; |
| 356 } | 356 } |
| 357 } | 357 } |
| OLD | NEW |