| 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_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 7 $(ANNOTATIONS)$(CLASS_MODIFIERS)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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 try { | 53 try { |
| 54 var request = _deleteDatabase(name); | 54 var request = _deleteDatabase(name); |
| 55 | 55 |
| 56 if (onBlocked != null) { | 56 if (onBlocked != null) { |
| 57 request.onBlocked.listen(onBlocked); | 57 request.onBlocked.listen(onBlocked); |
| 58 } | 58 } |
| 59 var completer = new Completer.sync(); | 59 var completer = new Completer.sync(); |
| 60 request.onSuccess.listen((e) { | 60 request.onSuccess.listen((e) { |
| 61 completer.complete(this); | 61 completer.complete(this); |
| 62 }); | 62 }); |
| 63 request.onError.listen((e) { | 63 request.onError.listen(completer.completeError); |
| 64 completer.completeError(e); | |
| 65 }); | |
| 66 return completer.future; | 64 return completer.future; |
| 67 } catch (e, stacktrace) { | 65 } catch (e, stacktrace) { |
| 68 return new Future.error(e, stacktrace); | 66 return new Future.error(e, stacktrace); |
| 69 } | 67 } |
| 70 } | 68 } |
| 71 | 69 |
| 72 @DomName('IDBFactory.getDatabaseNames') | 70 @DomName('IDBFactory.getDatabaseNames') |
| 73 @SupportedBrowser(SupportedBrowser.CHROME) | 71 @SupportedBrowser(SupportedBrowser.CHROME) |
| 74 @Experimental() | 72 @Experimental() |
| 75 Future<List<String>> getDatabaseNames() { | 73 Future<List<String>> getDatabaseNames() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 102 * Ties a request to a completer, so the completer is completed when it succeeds | 100 * Ties a request to a completer, so the completer is completed when it succeeds |
| 103 * and errors out when the request errors. | 101 * and errors out when the request errors. |
| 104 */ | 102 */ |
| 105 Future _completeRequest(Request request) { | 103 Future _completeRequest(Request request) { |
| 106 var completer = new Completer.sync(); | 104 var completer = new Completer.sync(); |
| 107 // TODO: make sure that completer.complete is synchronous as transactions | 105 // TODO: make sure that completer.complete is synchronous as transactions |
| 108 // may be committed if the result is not processed immediately. | 106 // may be committed if the result is not processed immediately. |
| 109 request.onSuccess.listen((e) { | 107 request.onSuccess.listen((e) { |
| 110 completer.complete(request.result); | 108 completer.complete(request.result); |
| 111 }); | 109 }); |
| 112 request.onError.listen((e) { | 110 request.onError.listen(completer.completeError); |
| 113 completer.completeError(e); | |
| 114 }); | |
| 115 return completer.future; | 111 return completer.future; |
| 116 } | 112 } |
| OLD | NEW |