| OLD | NEW |
| 1 library dart.dom.indexed_db; | 1 library dart.dom.indexed_db; |
| 2 | 2 |
| 3 import 'dart:async'; | 3 import 'dart:async'; |
| 4 import 'dart:html'; | 4 import 'dart:html'; |
| 5 import 'dart:html_common'; | 5 import 'dart:html_common'; |
| 6 import 'dart:nativewrappers'; | 6 import 'dart:nativewrappers'; |
| 7 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 7 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 8 // for details. All rights reserved. Use of this source code is governed by a | 8 // for details. All rights reserved. Use of this source code is governed by a |
| 9 // BSD-style license that can be found in the LICENSE file. | 9 // BSD-style license that can be found in the LICENSE file. |
| 10 | 10 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 try { | 305 try { |
| 306 var request = _deleteDatabase(name); | 306 var request = _deleteDatabase(name); |
| 307 | 307 |
| 308 if (onBlocked != null) { | 308 if (onBlocked != null) { |
| 309 request.onBlocked.listen(onBlocked); | 309 request.onBlocked.listen(onBlocked); |
| 310 } | 310 } |
| 311 var completer = new Completer.sync(); | 311 var completer = new Completer.sync(); |
| 312 request.onSuccess.listen((e) { | 312 request.onSuccess.listen((e) { |
| 313 completer.complete(this); | 313 completer.complete(this); |
| 314 }); | 314 }); |
| 315 request.onError.listen((e) { | 315 request.onError.listen(completer.completeError); |
| 316 completer.completeError(e); | |
| 317 }); | |
| 318 return completer.future; | 316 return completer.future; |
| 319 } catch (e, stacktrace) { | 317 } catch (e, stacktrace) { |
| 320 return new Future.error(e, stacktrace); | 318 return new Future.error(e, stacktrace); |
| 321 } | 319 } |
| 322 } | 320 } |
| 323 | 321 |
| 324 @DomName('IDBFactory.getDatabaseNames') | 322 @DomName('IDBFactory.getDatabaseNames') |
| 325 @SupportedBrowser(SupportedBrowser.CHROME) | 323 @SupportedBrowser(SupportedBrowser.CHROME) |
| 326 @Experimental() | 324 @Experimental() |
| 327 Future<List<String>> getDatabaseNames() { | 325 Future<List<String>> getDatabaseNames() { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 * Ties a request to a completer, so the completer is completed when it succeeds | 373 * Ties a request to a completer, so the completer is completed when it succeeds |
| 376 * and errors out when the request errors. | 374 * and errors out when the request errors. |
| 377 */ | 375 */ |
| 378 Future _completeRequest(Request request) { | 376 Future _completeRequest(Request request) { |
| 379 var completer = new Completer.sync(); | 377 var completer = new Completer.sync(); |
| 380 // TODO: make sure that completer.complete is synchronous as transactions | 378 // TODO: make sure that completer.complete is synchronous as transactions |
| 381 // may be committed if the result is not processed immediately. | 379 // may be committed if the result is not processed immediately. |
| 382 request.onSuccess.listen((e) { | 380 request.onSuccess.listen((e) { |
| 383 completer.complete(request.result); | 381 completer.complete(request.result); |
| 384 }); | 382 }); |
| 385 request.onError.listen((e) { | 383 request.onError.listen(completer.completeError); |
| 386 completer.completeError(e); | |
| 387 }); | |
| 388 return completer.future; | 384 return completer.future; |
| 389 } | 385 } |
| 390 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 386 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 391 // for details. All rights reserved. Use of this source code is governed by a | 387 // for details. All rights reserved. Use of this source code is governed by a |
| 392 // BSD-style license that can be found in the LICENSE file. | 388 // BSD-style license that can be found in the LICENSE file. |
| 393 | 389 |
| 394 | 390 |
| 395 @DomName('IDBIndex') | 391 @DomName('IDBIndex') |
| 396 @Unstable() | 392 @Unstable() |
| 397 class Index extends NativeFieldWrapperClass1 { | 393 class Index extends NativeFieldWrapperClass1 { |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 /** | 793 /** |
| 798 * Helper for iterating over cursors in a request. | 794 * Helper for iterating over cursors in a request. |
| 799 */ | 795 */ |
| 800 static Stream<Cursor> _cursorStreamFromResult(Request request, | 796 static Stream<Cursor> _cursorStreamFromResult(Request request, |
| 801 bool autoAdvance) { | 797 bool autoAdvance) { |
| 802 // TODO: need to guarantee that the controller provides the values | 798 // TODO: need to guarantee that the controller provides the values |
| 803 // immediately as waiting until the next tick will cause the transaction to | 799 // immediately as waiting until the next tick will cause the transaction to |
| 804 // close. | 800 // close. |
| 805 var controller = new StreamController(sync: true); | 801 var controller = new StreamController(sync: true); |
| 806 | 802 |
| 807 request.onError.listen((e) { | 803 //TODO: Report stacktrace once issue 4061 is resolved. |
| 808 //TODO: Report stacktrace once issue 4061 is resolved. | 804 request.onError.listen(controller.addError); |
| 809 controller.addError(e); | |
| 810 }); | |
| 811 | 805 |
| 812 request.onSuccess.listen((e) { | 806 request.onSuccess.listen((e) { |
| 813 Cursor cursor = request.result; | 807 Cursor cursor = request.result; |
| 814 if (cursor == null) { | 808 if (cursor == null) { |
| 815 controller.close(); | 809 controller.close(); |
| 816 } else { | 810 } else { |
| 817 controller.add(cursor); | 811 controller.add(cursor); |
| 818 if (autoAdvance == true && controller.hasListener) { | 812 if (autoAdvance == true && controller.hasListener) { |
| 819 cursor.next(); | 813 cursor.next(); |
| 820 } | 814 } |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 | 1039 |
| 1046 // WARNING: Do not edit - generated code. | 1040 // WARNING: Do not edit - generated code. |
| 1047 | 1041 |
| 1048 | 1042 |
| 1049 @DocsEditable() | 1043 @DocsEditable() |
| 1050 @DomName('IDBAny') | 1044 @DomName('IDBAny') |
| 1051 @deprecated // nonstandard | 1045 @deprecated // nonstandard |
| 1052 abstract class _IDBAny extends NativeFieldWrapperClass1 { | 1046 abstract class _IDBAny extends NativeFieldWrapperClass1 { |
| 1053 | 1047 |
| 1054 } | 1048 } |
| OLD | NEW |