| 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 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 8 /** | 8 /** |
| 9 * Checks to see if Indexed DB is supported on the current platform. | 9 * Checks to see if Indexed DB is supported on the current platform. |
| 10 */ | 10 */ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } catch (e, stacktrace) { | 73 } catch (e, stacktrace) { |
| 74 return new Future.immediateError(e, stacktrace); | 74 return new Future.immediateError(e, stacktrace); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * Checks to see if getDatabaseNames is supported by the current platform. | 79 * Checks to see if getDatabaseNames is supported by the current platform. |
| 80 */ | 80 */ |
| 81 bool get supportsDatabaseNames { | 81 bool get supportsDatabaseNames { |
| 82 $if DART2JS | 82 $if DART2JS |
| 83 return JS('bool', '!!(#.getDatabaseNames || #.webkitGetDatabaseNames)', | 83 return supported && JS('bool', |
| 84 this, this); | 84 '!!(#.getDatabaseNames || #.webkitGetDatabaseNames)', this, this); |
| 85 $else | 85 $else |
| 86 return true; | 86 return true; |
| 87 $endif | 87 $endif |
| 88 } | 88 } |
| 89 | 89 |
| 90 $!MEMBERS | 90 $!MEMBERS |
| 91 } | 91 } |
| 92 | 92 |
| 93 | 93 |
| 94 /** | 94 /** |
| 95 * Ties a request to a completer, so the completer is completed when it succeeds | 95 * Ties a request to a completer, so the completer is completed when it succeeds |
| 96 * and errors out when the request errors. | 96 * and errors out when the request errors. |
| 97 */ | 97 */ |
| 98 Future _completeRequest(Request request) { | 98 Future _completeRequest(Request request) { |
| 99 var completer = new Completer(); | 99 var completer = new Completer(); |
| 100 // TODO: make sure that completer.complete is synchronous as transactions | 100 // TODO: make sure that completer.complete is synchronous as transactions |
| 101 // may be committed if the result is not processed immediately. | 101 // may be committed if the result is not processed immediately. |
| 102 request.onSuccess.listen((e) { | 102 request.onSuccess.listen((e) { |
| 103 completer.complete(request.result); | 103 completer.complete(request.result); |
| 104 }); | 104 }); |
| 105 request.onError.listen((e) { | 105 request.onError.listen((e) { |
| 106 completer.completeError(e); | 106 completer.completeError(e); |
| 107 }); | 107 }); |
| 108 return completer.future; | 108 return completer.future; |
| 109 } | 109 } |
| OLD | NEW |