Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: tool/input_sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart

Issue 1909193002: Cleanup dart:indexed_db, dart:svg, and dart:js errrors. update dart:html with extra generic methods. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /** 1 /**
2 * A client-side key-value store with support for indexes. 2 * A client-side key-value store with support for indexes.
3 * 3 *
4 * Many browsers support IndexedDB—a web standard for 4 * Many browsers support IndexedDB—a web standard for
5 * an indexed database. 5 * an indexed database.
6 * By storing data on the client in an IndexedDB, 6 * By storing data on the client in an IndexedDB,
7 * a web app gets some advantages, such as faster performance and persistence. 7 * a web app gets some advantages, such as faster performance and persistence.
8 * To find out which browsers support IndexedDB, 8 * To find out which browsers support IndexedDB,
9 * refer to [Can I Use?](http://caniuse.com/#feat=indexeddb) 9 * refer to [Can I Use?](http://caniuse.com/#feat=indexeddb)
10 * 10 *
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 request.onBlocked.listen(onBlocked); 546 request.onBlocked.listen(onBlocked);
547 } 547 }
548 return _completeRequest(request); 548 return _completeRequest(request);
549 } catch (e, stacktrace) { 549 } catch (e, stacktrace) {
550 return new Future.error(e, stacktrace); 550 return new Future.error(e, stacktrace);
551 } 551 }
552 } 552 }
553 553
554 @DomName('IDBFactory.deleteDatabase') 554 @DomName('IDBFactory.deleteDatabase')
555 Future<IdbFactory> deleteDatabase(String name, 555 Future<IdbFactory> deleteDatabase(String name,
556 {void onBlocked(Event)}) { 556 {void onBlocked(Event e)}) {
557 try { 557 try {
558 var request = _deleteDatabase(name); 558 var request = _deleteDatabase(name);
559 559
560 if (onBlocked != null) { 560 if (onBlocked != null) {
561 request.onBlocked.listen(onBlocked); 561 request.onBlocked.listen(onBlocked);
562 } 562 }
563 var completer = new Completer.sync(); 563 var completer = new Completer<IdbFactory>.sync();
564 request.onSuccess.listen((e) { 564 request.onSuccess.listen((e) {
565 completer.complete(this); 565 completer.complete(this);
566 }); 566 });
567 request.onError.listen(completer.completeError); 567 request.onError.listen(completer.completeError);
568 return completer.future; 568 return completer.future;
569 } catch (e, stacktrace) { 569 } catch (e, stacktrace) {
570 return new Future.error(e, stacktrace); 570 return new Future.error(e, stacktrace);
571 } 571 }
572 } 572 }
573 573
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 @Creates('DomStringList') 623 @Creates('DomStringList')
624 Request _webkitGetDatabaseNames() native; 624 Request _webkitGetDatabaseNames() native;
625 625
626 } 626 }
627 627
628 628
629 /** 629 /**
630 * Ties a request to a completer, so the completer is completed when it succeeds 630 * Ties a request to a completer, so the completer is completed when it succeeds
631 * and errors out when the request errors. 631 * and errors out when the request errors.
632 */ 632 */
633 Future _completeRequest(Request request) { 633 Future/*<T>*/ _completeRequest/*<T>*/(Request request) {
634 var completer = new Completer.sync(); 634 var completer = new Completer/*<T>*/.sync();
635 // TODO: make sure that completer.complete is synchronous as transactions 635 // TODO: make sure that completer.complete is synchronous as transactions
636 // may be committed if the result is not processed immediately. 636 // may be committed if the result is not processed immediately.
637 request.onSuccess.listen((e) { 637 request.onSuccess.listen((e) {
638 completer.complete(request.result); 638 completer.complete(request.result as dynamic/*=T*/);
639 }); 639 });
640 request.onError.listen(completer.completeError); 640 request.onError.listen(completer.completeError);
641 return completer.future; 641 return completer.future;
642 } 642 }
643 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 643 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
644 // for details. All rights reserved. Use of this source code is governed by a 644 // for details. All rights reserved. Use of this source code is governed by a
645 // BSD-style license that can be found in the LICENSE file. 645 // BSD-style license that can be found in the LICENSE file.
646 646
647 647
648 @DomName('IDBIndex') 648 @DomName('IDBIndex')
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 Request _count(Object key) native; 767 Request _count(Object key) native;
768 768
769 @JSName('get') 769 @JSName('get')
770 @DomName('IDBIndex.get') 770 @DomName('IDBIndex.get')
771 @DocsEditable() 771 @DocsEditable()
772 @Returns('Request') 772 @Returns('Request')
773 @Creates('Request') 773 @Creates('Request')
774 @annotation_Creates_SerializedScriptValue 774 @annotation_Creates_SerializedScriptValue
775 Request _get(Object key) native; 775 Request _get(Object key) native;
776 776
777 @DomName('IDBIndex.getAll')
778 @DocsEditable()
779 @Experimental() // untriaged
780 Request getAll(Object range, [int maxCount]) native;
781
782 @DomName('IDBIndex.getAllKeys')
783 @DocsEditable()
784 @Experimental() // untriaged
785 Request getAllKeys(Object range, [int maxCount]) native;
786
777 @JSName('getKey') 787 @JSName('getKey')
778 @DomName('IDBIndex.getKey') 788 @DomName('IDBIndex.getKey')
779 @DocsEditable() 789 @DocsEditable()
780 @Returns('Request') 790 @Returns('Request')
781 @Creates('Request') 791 @Creates('Request')
782 @annotation_Creates_SerializedScriptValue 792 @annotation_Creates_SerializedScriptValue
783 @Creates('ObjectStore') 793 @Creates('ObjectStore')
784 Request _getKey(Object key) native; 794 Request _getKey(Object key) native;
785 795
786 @JSName('openCursor') 796 @JSName('openCursor')
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 @DocsEditable() 1075 @DocsEditable()
1066 Request _clear() native; 1076 Request _clear() native;
1067 1077
1068 @JSName('count') 1078 @JSName('count')
1069 @DomName('IDBObjectStore.count') 1079 @DomName('IDBObjectStore.count')
1070 @DocsEditable() 1080 @DocsEditable()
1071 Request _count(Object key) native; 1081 Request _count(Object key) native;
1072 1082
1073 @DomName('IDBObjectStore.createIndex') 1083 @DomName('IDBObjectStore.createIndex')
1074 @DocsEditable() 1084 @DocsEditable()
1075 Index _createIndex(String name, keyPath, [Map options]) { 1085 Index _createIndex(String name, Object keyPath, [Map options]) {
1076 if ((keyPath is String || keyPath == null) && options == null) { 1086 if (options != null) {
1077 return _createIndex_1(name, keyPath); 1087 var options_1 = convertDartToNative_Dictionary(options);
1088 return _createIndex_1(name, keyPath, options_1);
1078 } 1089 }
1079 if (options != null && (keyPath is String || keyPath == null)) { 1090 return _createIndex_2(name, keyPath);
1080 var options_1 = convertDartToNative_Dictionary(options);
1081 return _createIndex_2(name, keyPath, options_1);
1082 }
1083 if ((keyPath is List<String> || keyPath == null) && options == null) {
1084 List keyPath_1 = convertDartToNative_StringArray(keyPath);
1085 return _createIndex_3(name, keyPath_1);
1086 }
1087 if (options != null && (keyPath is List<String> || keyPath == null)) {
1088 List keyPath_1 = convertDartToNative_StringArray(keyPath);
1089 var options_2 = convertDartToNative_Dictionary(options);
1090 return _createIndex_4(name, keyPath_1, options_2);
1091 }
1092 throw new ArgumentError("Incorrect number or type of arguments");
1093 } 1091 }
1094 @JSName('createIndex') 1092 @JSName('createIndex')
1095 @DomName('IDBObjectStore.createIndex') 1093 @DomName('IDBObjectStore.createIndex')
1096 @DocsEditable() 1094 @DocsEditable()
1097 Index _createIndex_1(name, String keyPath) native; 1095 Index _createIndex_1(name, keyPath, options) native;
1098 @JSName('createIndex') 1096 @JSName('createIndex')
1099 @DomName('IDBObjectStore.createIndex') 1097 @DomName('IDBObjectStore.createIndex')
1100 @DocsEditable() 1098 @DocsEditable()
1101 Index _createIndex_2(name, String keyPath, options) native; 1099 Index _createIndex_2(name, keyPath) native;
1102 @JSName('createIndex')
1103 @DomName('IDBObjectStore.createIndex')
1104 @DocsEditable()
1105 Index _createIndex_3(name, List keyPath) native;
1106 @JSName('createIndex')
1107 @DomName('IDBObjectStore.createIndex')
1108 @DocsEditable()
1109 Index _createIndex_4(name, List keyPath, options) native;
1110 1100
1111 @JSName('delete') 1101 @JSName('delete')
1112 @DomName('IDBObjectStore.delete') 1102 @DomName('IDBObjectStore.delete')
1113 @DocsEditable() 1103 @DocsEditable()
1114 Request _delete(Object key) native; 1104 Request _delete(Object key) native;
1115 1105
1116 @DomName('IDBObjectStore.deleteIndex') 1106 @DomName('IDBObjectStore.deleteIndex')
1117 @DocsEditable() 1107 @DocsEditable()
1118 void deleteIndex(String name) native; 1108 void deleteIndex(String name) native;
1119 1109
1120 @JSName('get') 1110 @JSName('get')
1121 @DomName('IDBObjectStore.get') 1111 @DomName('IDBObjectStore.get')
1122 @DocsEditable() 1112 @DocsEditable()
1123 @Returns('Request') 1113 @Returns('Request')
1124 @Creates('Request') 1114 @Creates('Request')
1125 @annotation_Creates_SerializedScriptValue 1115 @annotation_Creates_SerializedScriptValue
1126 Request _get(Object key) native; 1116 Request _get(Object key) native;
1127 1117
1118 @DomName('IDBObjectStore.getAll')
1119 @DocsEditable()
1120 @Experimental() // untriaged
1121 Request getAll(Object range, [int maxCount]) native;
1122
1123 @DomName('IDBObjectStore.getAllKeys')
1124 @DocsEditable()
1125 @Experimental() // untriaged
1126 Request getAllKeys(Object range, [int maxCount]) native;
1127
1128 @DomName('IDBObjectStore.index') 1128 @DomName('IDBObjectStore.index')
1129 @DocsEditable() 1129 @DocsEditable()
1130 Index index(String name) native; 1130 Index index(String name) native;
1131 1131
1132 @JSName('openCursor') 1132 @JSName('openCursor')
1133 @DomName('IDBObjectStore.openCursor') 1133 @DomName('IDBObjectStore.openCursor')
1134 @DocsEditable() 1134 @DocsEditable()
1135 @Returns('Request') 1135 @Returns('Request')
1136 @Creates('Request') 1136 @Creates('Request')
1137 @Creates('Cursor') 1137 @Creates('Cursor')
(...skipping 30 matching lines...) Expand all
1168 @DocsEditable() 1168 @DocsEditable()
1169 @Returns('Request') 1169 @Returns('Request')
1170 @Creates('Request') 1170 @Creates('Request')
1171 @_annotation_Creates_IDBKey 1171 @_annotation_Creates_IDBKey
1172 Request _put_2(value) native; 1172 Request _put_2(value) native;
1173 1173
1174 1174
1175 /** 1175 /**
1176 * Helper for iterating over cursors in a request. 1176 * Helper for iterating over cursors in a request.
1177 */ 1177 */
1178 static Stream<Cursor> _cursorStreamFromResult(Request request, 1178 static Stream/*<T>*/ _cursorStreamFromResult/*<T extends Cursor>*/(Request req uest,
1179 bool autoAdvance) { 1179 bool autoAdvance) {
1180 // TODO: need to guarantee that the controller provides the values 1180 // TODO: need to guarantee that the controller provides the values
1181 // immediately as waiting until the next tick will cause the transaction to 1181 // immediately as waiting until the next tick will cause the transaction to
1182 // close. 1182 // close.
1183 var controller = new StreamController(sync: true); 1183 var controller = new StreamController/*<T>*/(sync: true);
1184 1184
1185 //TODO: Report stacktrace once issue 4061 is resolved. 1185 //TODO: Report stacktrace once issue 4061 is resolved.
1186 request.onError.listen(controller.addError); 1186 request.onError.listen(controller.addError);
1187 1187
1188 request.onSuccess.listen((e) { 1188 request.onSuccess.listen((e) {
1189 Cursor cursor = request.result; 1189 var cursor = request.result as dynamic /*=T*/;
1190 if (cursor == null) { 1190 if (cursor == null) {
1191 controller.close(); 1191 controller.close();
1192 } else { 1192 } else {
1193 controller.add(cursor); 1193 controller.add(cursor);
1194 if (autoAdvance == true && controller.hasListener) { 1194 if (autoAdvance == true && controller.hasListener) {
1195 cursor.next(); 1195 cursor.next();
1196 } 1196 }
1197 } 1197 }
1198 }); 1198 });
1199 return controller.stream; 1199 return controller.stream;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 final Database db; 1387 final Database db;
1388 1388
1389 @DomName('IDBTransaction.error') 1389 @DomName('IDBTransaction.error')
1390 @DocsEditable() 1390 @DocsEditable()
1391 final DomError error; 1391 final DomError error;
1392 1392
1393 @DomName('IDBTransaction.mode') 1393 @DomName('IDBTransaction.mode')
1394 @DocsEditable() 1394 @DocsEditable()
1395 final String mode; 1395 final String mode;
1396 1396
1397 @DomName('IDBTransaction.objectStoreNames')
1398 @DocsEditable()
1399 @Experimental() // untriaged
1400 @Returns('DomStringList')
1401 @Creates('DomStringList')
1402 final List<String> objectStoreNames;
1403
1397 @DomName('IDBTransaction.abort') 1404 @DomName('IDBTransaction.abort')
1398 @DocsEditable() 1405 @DocsEditable()
1399 void abort() native; 1406 void abort() native;
1400 1407
1401 @DomName('IDBTransaction.objectStore') 1408 @DomName('IDBTransaction.objectStore')
1402 @DocsEditable() 1409 @DocsEditable()
1403 ObjectStore objectStore(String name) native; 1410 ObjectStore objectStore(String name) native;
1404 1411
1405 /// Stream of `abort` events handled by this [Transaction]. 1412 /// Stream of `abort` events handled by this [Transaction].
1406 @DomName('IDBTransaction.onabort') 1413 @DomName('IDBTransaction.onabort')
(...skipping 17 matching lines...) Expand all
1424 1431
1425 1432
1426 @DocsEditable() 1433 @DocsEditable()
1427 @DomName('IDBVersionChangeEvent') 1434 @DomName('IDBVersionChangeEvent')
1428 @Unstable() 1435 @Unstable()
1429 @Native("IDBVersionChangeEvent") 1436 @Native("IDBVersionChangeEvent")
1430 class VersionChangeEvent extends Event { 1437 class VersionChangeEvent extends Event {
1431 // To suppress missing implicit constructor warnings. 1438 // To suppress missing implicit constructor warnings.
1432 factory VersionChangeEvent._() { throw new UnsupportedError("Not supported"); } 1439 factory VersionChangeEvent._() { throw new UnsupportedError("Not supported"); }
1433 1440
1441 @DomName('IDBVersionChangeEvent.IDBVersionChangeEvent')
1442 @DocsEditable()
1443 factory VersionChangeEvent(String type, [Map eventInitDict]) {
1444 if (eventInitDict != null) {
1445 var eventInitDict_1 = convertDartToNative_Dictionary(eventInitDict);
1446 return VersionChangeEvent._create_1(type, eventInitDict_1);
1447 }
1448 return VersionChangeEvent._create_2(type);
1449 }
1450 static VersionChangeEvent _create_1(type, eventInitDict) => JS('VersionChangeE vent', 'new IDBVersionChangeEvent(#,#)', type, eventInitDict);
1451 static VersionChangeEvent _create_2(type) => JS('VersionChangeEvent', 'new IDB VersionChangeEvent(#)', type);
1452
1434 @DomName('IDBVersionChangeEvent.dataLoss') 1453 @DomName('IDBVersionChangeEvent.dataLoss')
1435 @DocsEditable() 1454 @DocsEditable()
1436 @Experimental() // untriaged 1455 @Experimental() // untriaged
1437 final String dataLoss; 1456 final String dataLoss;
1438 1457
1439 @DomName('IDBVersionChangeEvent.dataLossMessage') 1458 @DomName('IDBVersionChangeEvent.dataLossMessage')
1440 @DocsEditable() 1459 @DocsEditable()
1441 @Experimental() // untriaged 1460 @Experimental() // untriaged
1442 final String dataLossMessage; 1461 final String dataLossMessage;
1443 1462
1444 @DomName('IDBVersionChangeEvent.newVersion') 1463 @DomName('IDBVersionChangeEvent.newVersion')
1445 @DocsEditable() 1464 @DocsEditable()
1446 @Creates('int|String|Null') 1465 @Creates('int|String|Null')
1447 @Returns('int|String|Null') 1466 @Returns('int|String|Null')
1448 final int newVersion; 1467 final int newVersion;
1449 1468
1450 @DomName('IDBVersionChangeEvent.oldVersion') 1469 @DomName('IDBVersionChangeEvent.oldVersion')
1451 @DocsEditable() 1470 @DocsEditable()
1452 @Creates('int|String|Null') 1471 @Creates('int|String|Null')
1453 @Returns('int|String|Null') 1472 @Returns('int|String|Null')
1454 final int oldVersion; 1473 final int oldVersion;
1455 } 1474 }
OLDNEW
« no previous file with comments | « tool/input_sdk/lib/html/dart2js/html_dart2js.dart ('k') | tool/input_sdk/lib/js/dart2js/js_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698