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

Side by Side Diff: sdk/lib/indexed_db/dartium/indexed_db_dartium.dart

Issue 14070010: Refactor Future constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added co19 issue number. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart ('k') | sdk/lib/io/directory_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 27 matching lines...) Expand all
38 // BSD-style license that can be found in the LICENSE file. 38 // BSD-style license that can be found in the LICENSE file.
39 39
40 40
41 @DomName('IDBCursor') 41 @DomName('IDBCursor')
42 class Cursor extends NativeFieldWrapperClass1 { 42 class Cursor extends NativeFieldWrapperClass1 {
43 @DomName('IDBCursor.delete') 43 @DomName('IDBCursor.delete')
44 Future delete() { 44 Future delete() {
45 try { 45 try {
46 return _completeRequest($dom_delete()); 46 return _completeRequest($dom_delete());
47 } catch (e, stacktrace) { 47 } catch (e, stacktrace) {
48 return new Future.immediateError(e, stacktrace); 48 return new Future.error(e, stacktrace);
49 } 49 }
50 } 50 }
51 51
52 @DomName('IDBCursor.value') 52 @DomName('IDBCursor.value')
53 Future update(value) { 53 Future update(value) {
54 try { 54 try {
55 return _completeRequest($dom_update(value)); 55 return _completeRequest($dom_update(value));
56 } catch (e, stacktrace) { 56 } catch (e, stacktrace) {
57 return new Future.immediateError(e, stacktrace); 57 return new Future.error(e, stacktrace);
58 } 58 }
59 } 59 }
60 60
61 Cursor.internal(); 61 Cursor.internal();
62 62
63 @DomName('IDBCursor.direction') 63 @DomName('IDBCursor.direction')
64 @DocsEditable 64 @DocsEditable
65 String get direction native "IDBCursor_direction_Getter"; 65 String get direction native "IDBCursor_direction_Getter";
66 66
67 @DomName('IDBCursor.key') 67 @DomName('IDBCursor.key')
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 */ 254 */
255 static bool get supported { 255 static bool get supported {
256 return true; 256 return true;
257 } 257 }
258 258
259 @DomName('IDBFactory.open') 259 @DomName('IDBFactory.open')
260 Future<Database> open(String name, 260 Future<Database> open(String name,
261 {int version, void onUpgradeNeeded(VersionChangeEvent), 261 {int version, void onUpgradeNeeded(VersionChangeEvent),
262 void onBlocked(Event)}) { 262 void onBlocked(Event)}) {
263 if ((version == null) != (onUpgradeNeeded == null)) { 263 if ((version == null) != (onUpgradeNeeded == null)) {
264 return new Future.immediateError(new ArgumentError( 264 return new Future.error(new ArgumentError(
265 'version and onUpgradeNeeded must be specified together')); 265 'version and onUpgradeNeeded must be specified together'));
266 } 266 }
267 try { 267 try {
268 var request; 268 var request;
269 if (version != null) { 269 if (version != null) {
270 request = $dom_open(name, version); 270 request = $dom_open(name, version);
271 } else { 271 } else {
272 request = $dom_open(name); 272 request = $dom_open(name);
273 } 273 }
274 274
275 if (onUpgradeNeeded != null) { 275 if (onUpgradeNeeded != null) {
276 request.onUpgradeNeeded.listen(onUpgradeNeeded); 276 request.onUpgradeNeeded.listen(onUpgradeNeeded);
277 } 277 }
278 if (onBlocked != null) { 278 if (onBlocked != null) {
279 request.onBlocked.listen(onBlocked); 279 request.onBlocked.listen(onBlocked);
280 } 280 }
281 return _completeRequest(request); 281 return _completeRequest(request);
282 } catch (e, stacktrace) { 282 } catch (e, stacktrace) {
283 return new Future.immediateError(e, stacktrace); 283 return new Future.error(e, stacktrace);
284 } 284 }
285 } 285 }
286 286
287 @DomName('IDBFactory.deleteDatabase') 287 @DomName('IDBFactory.deleteDatabase')
288 Future<IdbFactory> deleteDatabase(String name, 288 Future<IdbFactory> deleteDatabase(String name,
289 {void onBlocked(Event)}) { 289 {void onBlocked(Event)}) {
290 try { 290 try {
291 var request = $dom_deleteDatabase(name); 291 var request = $dom_deleteDatabase(name);
292 292
293 if (onBlocked != null) { 293 if (onBlocked != null) {
294 request.onBlocked.listen(onBlocked); 294 request.onBlocked.listen(onBlocked);
295 } 295 }
296 return _completeRequest(request); 296 return _completeRequest(request);
297 } catch (e, stacktrace) { 297 } catch (e, stacktrace) {
298 return new Future.immediateError(e, stacktrace); 298 return new Future.error(e, stacktrace);
299 } 299 }
300 } 300 }
301 301
302 @DomName('IDBFactory.getDatabaseNames') 302 @DomName('IDBFactory.getDatabaseNames')
303 @SupportedBrowser(SupportedBrowser.CHROME) 303 @SupportedBrowser(SupportedBrowser.CHROME)
304 @Experimental 304 @Experimental
305 Future<List<String>> getDatabaseNames() { 305 Future<List<String>> getDatabaseNames() {
306 try { 306 try {
307 var request = $dom_webkitGetDatabaseNames(); 307 var request = $dom_webkitGetDatabaseNames();
308 308
309 return _completeRequest(request); 309 return _completeRequest(request);
310 } catch (e, stacktrace) { 310 } catch (e, stacktrace) {
311 return new Future.immediateError(e, stacktrace); 311 return new Future.error(e, stacktrace);
312 } 312 }
313 } 313 }
314 314
315 /** 315 /**
316 * Checks to see if getDatabaseNames is supported by the current platform. 316 * Checks to see if getDatabaseNames is supported by the current platform.
317 */ 317 */
318 bool get supportsDatabaseNames { 318 bool get supportsDatabaseNames {
319 return true; 319 return true;
320 } 320 }
321 321
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 Future<int> count([key_OR_range]) { 381 Future<int> count([key_OR_range]) {
382 try { 382 try {
383 var request; 383 var request;
384 if (key_OR_range != null) { 384 if (key_OR_range != null) {
385 request = $dom_count(key_OR_range); 385 request = $dom_count(key_OR_range);
386 } else { 386 } else {
387 request = $dom_count(); 387 request = $dom_count();
388 } 388 }
389 return _completeRequest(request); 389 return _completeRequest(request);
390 } catch (e, stacktrace) { 390 } catch (e, stacktrace) {
391 return new Future.immediateError(e, stacktrace); 391 return new Future.error(e, stacktrace);
392 } 392 }
393 } 393 }
394 394
395 @DomName('IDBIndex.get') 395 @DomName('IDBIndex.get')
396 Future get(key) { 396 Future get(key) {
397 try { 397 try {
398 var request = $dom_get(key); 398 var request = $dom_get(key);
399 399
400 return _completeRequest(request); 400 return _completeRequest(request);
401 } catch (e, stacktrace) { 401 } catch (e, stacktrace) {
402 return new Future.immediateError(e, stacktrace); 402 return new Future.error(e, stacktrace);
403 } 403 }
404 } 404 }
405 405
406 @DomName('IDBIndex.getKey') 406 @DomName('IDBIndex.getKey')
407 Future getKey(key) { 407 Future getKey(key) {
408 try { 408 try {
409 var request = $dom_getKey(key); 409 var request = $dom_getKey(key);
410 410
411 return _completeRequest(request); 411 return _completeRequest(request);
412 } catch (e, stacktrace) { 412 } catch (e, stacktrace) {
413 return new Future.immediateError(e, stacktrace); 413 return new Future.error(e, stacktrace);
414 } 414 }
415 } 415 }
416 416
417 /** 417 /**
418 * Creates a stream of cursors over the records in this object store. 418 * Creates a stream of cursors over the records in this object store.
419 * 419 *
420 * See also: 420 * See also:
421 * 421 *
422 * * [ObjectStore.openCursor] 422 * * [ObjectStore.openCursor]
423 */ 423 */
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 Future add(value, [key]) { 742 Future add(value, [key]) {
743 try { 743 try {
744 var request; 744 var request;
745 if (key != null) { 745 if (key != null) {
746 request = $dom_add(value, key); 746 request = $dom_add(value, key);
747 } else { 747 } else {
748 request = $dom_add(value); 748 request = $dom_add(value);
749 } 749 }
750 return _completeRequest(request); 750 return _completeRequest(request);
751 } catch (e, stacktrace) { 751 } catch (e, stacktrace) {
752 return new Future.immediateError(e, stacktrace); 752 return new Future.error(e, stacktrace);
753 } 753 }
754 } 754 }
755 755
756 @DomName('IDBObjectStore.clear') 756 @DomName('IDBObjectStore.clear')
757 Future clear() { 757 Future clear() {
758 try { 758 try {
759 return _completeRequest($dom_clear()); 759 return _completeRequest($dom_clear());
760 } catch (e, stacktrace) { 760 } catch (e, stacktrace) {
761 return new Future.immediateError(e, stacktrace); 761 return new Future.error(e, stacktrace);
762 } 762 }
763 } 763 }
764 764
765 @DomName('IDBObjectStore.delete') 765 @DomName('IDBObjectStore.delete')
766 Future delete(key_OR_keyRange){ 766 Future delete(key_OR_keyRange){
767 try { 767 try {
768 return _completeRequest($dom_delete(key_OR_keyRange)); 768 return _completeRequest($dom_delete(key_OR_keyRange));
769 } catch (e, stacktrace) { 769 } catch (e, stacktrace) {
770 return new Future.immediateError(e, stacktrace); 770 return new Future.error(e, stacktrace);
771 } 771 }
772 } 772 }
773 773
774 @DomName('IDBObjectStore.count') 774 @DomName('IDBObjectStore.count')
775 Future<int> count([key_OR_range]) { 775 Future<int> count([key_OR_range]) {
776 try { 776 try {
777 var request; 777 var request;
778 if (key_OR_range != null) { 778 if (key_OR_range != null) {
779 request = $dom_count(key_OR_range); 779 request = $dom_count(key_OR_range);
780 } else { 780 } else {
781 request = $dom_count(); 781 request = $dom_count();
782 } 782 }
783 return _completeRequest(request); 783 return _completeRequest(request);
784 } catch (e, stacktrace) { 784 } catch (e, stacktrace) {
785 return new Future.immediateError(e, stacktrace); 785 return new Future.error(e, stacktrace);
786 } 786 }
787 } 787 }
788 788
789 @DomName('IDBObjectStore.put') 789 @DomName('IDBObjectStore.put')
790 Future put(value, [key]) { 790 Future put(value, [key]) {
791 try { 791 try {
792 var request; 792 var request;
793 if (key != null) { 793 if (key != null) {
794 request = $dom_put(value, key); 794 request = $dom_put(value, key);
795 } else { 795 } else {
796 request = $dom_put(value); 796 request = $dom_put(value);
797 } 797 }
798 return _completeRequest(request); 798 return _completeRequest(request);
799 } catch (e, stacktrace) { 799 } catch (e, stacktrace) {
800 return new Future.immediateError(e, stacktrace); 800 return new Future.error(e, stacktrace);
801 } 801 }
802 } 802 }
803 803
804 @DomName('IDBObjectStore.get') 804 @DomName('IDBObjectStore.get')
805 Future getObject(key) { 805 Future getObject(key) {
806 try { 806 try {
807 var request = $dom_get(key); 807 var request = $dom_get(key);
808 808
809 return _completeRequest(request); 809 return _completeRequest(request);
810 } catch (e, stacktrace) { 810 } catch (e, stacktrace) {
811 return new Future.immediateError(e, stacktrace); 811 return new Future.error(e, stacktrace);
812 } 812 }
813 } 813 }
814 814
815 /** 815 /**
816 * Creates a stream of cursors over the records in this object store. 816 * Creates a stream of cursors over the records in this object store.
817 * 817 *
818 * **The stream must be manually advanced by calling [Cursor.next] after 818 * **The stream must be manually advanced by calling [Cursor.next] after
819 * each item or by specifying autoAdvance to be true.** 819 * each item or by specifying autoAdvance to be true.**
820 * 820 *
821 * var cursors = objectStore.openCursor().listen( 821 * var cursors = objectStore.openCursor().listen(
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 1304
1305 // WARNING: Do not edit - generated code. 1305 // WARNING: Do not edit - generated code.
1306 1306
1307 1307
1308 @DocsEditable 1308 @DocsEditable
1309 @DomName('IDBAny') 1309 @DomName('IDBAny')
1310 abstract class _IDBAny extends NativeFieldWrapperClass1 { 1310 abstract class _IDBAny extends NativeFieldWrapperClass1 {
1311 _IDBAny.internal(); 1311 _IDBAny.internal();
1312 1312
1313 } 1313 }
OLDNEW
« no previous file with comments | « sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart ('k') | sdk/lib/io/directory_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698