| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 @DomName('IDBFactory.deleteDatabase') | 50 @DomName('IDBFactory.deleteDatabase') |
| 51 Future<IdbFactory> deleteDatabase(String name, | 51 Future<IdbFactory> deleteDatabase(String name, |
| 52 {void onBlocked(Event)}) { | 52 {void onBlocked(Event)}) { |
| 53 try { | 53 try { |
| 54 var request = $dom_deleteDatabase(name); | 54 var request = $dom_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 return _completeRequest(request); | 59 var completer = new Completer.sync(); |
| 60 request.onSuccess.listen((e) { |
| 61 completer.complete(this); |
| 62 }); |
| 63 request.onError.listen((e) { |
| 64 completer.completeError(e); |
| 65 }); |
| 66 return completer.future; |
| 60 } catch (e, stacktrace) { | 67 } catch (e, stacktrace) { |
| 61 return new Future.error(e, stacktrace); | 68 return new Future.error(e, stacktrace); |
| 62 } | 69 } |
| 63 } | 70 } |
| 64 | 71 |
| 65 @DomName('IDBFactory.getDatabaseNames') | 72 @DomName('IDBFactory.getDatabaseNames') |
| 66 @SupportedBrowser(SupportedBrowser.CHROME) | 73 @SupportedBrowser(SupportedBrowser.CHROME) |
| 67 @Experimental | 74 @Experimental |
| 68 Future<List<String>> getDatabaseNames() { | 75 Future<List<String>> getDatabaseNames() { |
| 69 try { | 76 try { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 100 // TODO: make sure that completer.complete is synchronous as transactions | 107 // TODO: make sure that completer.complete is synchronous as transactions |
| 101 // may be committed if the result is not processed immediately. | 108 // may be committed if the result is not processed immediately. |
| 102 request.onSuccess.listen((e) { | 109 request.onSuccess.listen((e) { |
| 103 completer.complete(request.result); | 110 completer.complete(request.result); |
| 104 }); | 111 }); |
| 105 request.onError.listen((e) { | 112 request.onError.listen((e) { |
| 106 completer.completeError(e); | 113 completer.completeError(e); |
| 107 }); | 114 }); |
| 108 return completer.future; | 115 return completer.future; |
| 109 } | 116 } |
| OLD | NEW |