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

Side by Side Diff: sdk/lib/indexed_db/dart2js/indexed_db_dart2js.dart

Issue 23055008: Making almost all dom_ methods private. Exceptions will be addressed in a later CL. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
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:typed_data'; 6 import 'dart:typed_data';
7 import 'dart:_js_helper' show Creates, Returns, JSName, Null; 7 import 'dart:_js_helper' show Creates, Returns, JSName, Null;
8 import 'dart:_foreign_helper' show JS; 8 import 'dart:_foreign_helper' show JS;
9 import 'dart:_interceptors' show Interceptor, JSExtendableArray; 9 import 'dart:_interceptors' show Interceptor, JSExtendableArray;
10 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 10 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // for details. All rights reserved. Use of this source code is governed by a 137 // for details. All rights reserved. Use of this source code is governed by a
138 // BSD-style license that can be found in the LICENSE file. 138 // BSD-style license that can be found in the LICENSE file.
139 139
140 140
141 @DomName('IDBCursor') 141 @DomName('IDBCursor')
142 @Unstable() 142 @Unstable()
143 class Cursor extends Interceptor native "IDBCursor" { 143 class Cursor extends Interceptor native "IDBCursor" {
144 @DomName('IDBCursor.delete') 144 @DomName('IDBCursor.delete')
145 Future delete() { 145 Future delete() {
146 try { 146 try {
147 return _completeRequest($dom_delete()); 147 return _completeRequest(_delete());
148 } catch (e, stacktrace) { 148 } catch (e, stacktrace) {
149 return new Future.error(e, stacktrace); 149 return new Future.error(e, stacktrace);
150 } 150 }
151 } 151 }
152 152
153 @DomName('IDBCursor.value') 153 @DomName('IDBCursor.value')
154 Future update(value) { 154 Future update(value) {
155 try { 155 try {
156 return _completeRequest($dom_update(value)); 156 return _completeRequest(_update(value));
157 } catch (e, stacktrace) { 157 } catch (e, stacktrace) {
158 return new Future.error(e, stacktrace); 158 return new Future.error(e, stacktrace);
159 } 159 }
160 } 160 }
161 161
162 162
163 @DomName('IDBCursor.direction') 163 @DomName('IDBCursor.direction')
164 @DocsEditable() 164 @DocsEditable()
165 final String direction; 165 final String direction;
166 166
(...skipping 15 matching lines...) Expand all
182 @Returns('ObjectStore|Index|Null') 182 @Returns('ObjectStore|Index|Null')
183 final dynamic source; 183 final dynamic source;
184 184
185 @DomName('IDBCursor.advance') 185 @DomName('IDBCursor.advance')
186 @DocsEditable() 186 @DocsEditable()
187 void advance(int count) native; 187 void advance(int count) native;
188 188
189 @JSName('delete') 189 @JSName('delete')
190 @DomName('IDBCursor.delete') 190 @DomName('IDBCursor.delete')
191 @DocsEditable() 191 @DocsEditable()
192 Request $dom_delete() native; 192 Request _delete() native;
193 193
194 @JSName('continue') 194 @JSName('continue')
195 @DomName('IDBCursor.continue') 195 @DomName('IDBCursor.continue')
196 @DocsEditable() 196 @DocsEditable()
197 void next([Object key]) native; 197 void next([Object key]) native;
198 198
199 @DomName('IDBCursor.update') 199 @DomName('IDBCursor.update')
200 @DocsEditable() 200 @DocsEditable()
201 Request $dom_update(/*any*/ value) { 201 Request _update(/*any*/ value) {
202 var value_1 = convertDartToNative_SerializedScriptValue(value); 202 var value_1 = convertDartToNative_SerializedScriptValue(value);
203 return _$dom_update_1(value_1); 203 return _update_1(value_1);
204 } 204 }
205 @JSName('update') 205 @JSName('update')
206 @DomName('IDBCursor.update') 206 @DomName('IDBCursor.update')
207 @DocsEditable() 207 @DocsEditable()
208 Request _$dom_update_1(value) native; 208 Request _update_1(value) native;
209 209
210 } 210 }
211 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 211 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
212 // for details. All rights reserved. Use of this source code is governed by a 212 // for details. All rights reserved. Use of this source code is governed by a
213 // BSD-style license that can be found in the LICENSE file. 213 // BSD-style license that can be found in the LICENSE file.
214 214
215 215
216 @DocsEditable() 216 @DocsEditable()
217 @DomName('IDBCursorWithValue') 217 @DomName('IDBCursorWithValue')
218 @Unstable() 218 @Unstable()
(...skipping 27 matching lines...) Expand all
246 ObjectStore createObjectStore(String name, 246 ObjectStore createObjectStore(String name,
247 {String keyPath, bool autoIncrement}) { 247 {String keyPath, bool autoIncrement}) {
248 var options = {}; 248 var options = {};
249 if (keyPath != null) { 249 if (keyPath != null) {
250 options['keyPath'] = keyPath; 250 options['keyPath'] = keyPath;
251 } 251 }
252 if (autoIncrement != null) { 252 if (autoIncrement != null) {
253 options['autoIncrement'] = autoIncrement; 253 options['autoIncrement'] = autoIncrement;
254 } 254 }
255 255
256 return $dom_createObjectStore(name, options); 256 return _createObjectStore(name, options);
257 } 257 }
258 258
259 Transaction transaction(storeName_OR_storeNames, String mode) { 259 Transaction transaction(storeName_OR_storeNames, String mode) {
260 if (mode != 'readonly' && mode != 'readwrite') { 260 if (mode != 'readonly' && mode != 'readwrite') {
261 throw new ArgumentError(mode); 261 throw new ArgumentError(mode);
262 } 262 }
263 263
264 // TODO(sra): Ensure storeName_OR_storeNames is a string or List<String>, 264 // TODO(sra): Ensure storeName_OR_storeNames is a string or List<String>,
265 // and copy to JavaScript array if necessary. 265 // and copy to JavaScript array if necessary.
266 266
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 @Creates('int|String|Null') 334 @Creates('int|String|Null')
335 @Returns('int|String|Null') 335 @Returns('int|String|Null')
336 final dynamic version; 336 final dynamic version;
337 337
338 @DomName('IDBDatabase.close') 338 @DomName('IDBDatabase.close')
339 @DocsEditable() 339 @DocsEditable()
340 void close() native; 340 void close() native;
341 341
342 @DomName('IDBDatabase.createObjectStore') 342 @DomName('IDBDatabase.createObjectStore')
343 @DocsEditable() 343 @DocsEditable()
344 ObjectStore $dom_createObjectStore(String name, [Map options]) { 344 ObjectStore _createObjectStore(String name, [Map options]) {
345 if (options != null) { 345 if (options != null) {
346 var options_1 = convertDartToNative_Dictionary(options); 346 var options_1 = convertDartToNative_Dictionary(options);
347 return _$dom_createObjectStore_1(name, options_1); 347 return _createObjectStore_1(name, options_1);
348 } 348 }
349 return _$dom_createObjectStore_2(name); 349 return _createObjectStore_2(name);
350 } 350 }
351 @JSName('createObjectStore') 351 @JSName('createObjectStore')
352 @DomName('IDBDatabase.createObjectStore') 352 @DomName('IDBDatabase.createObjectStore')
353 @DocsEditable() 353 @DocsEditable()
354 ObjectStore _$dom_createObjectStore_1(name, options) native; 354 ObjectStore _createObjectStore_1(name, options) native;
355 @JSName('createObjectStore') 355 @JSName('createObjectStore')
356 @DomName('IDBDatabase.createObjectStore') 356 @DomName('IDBDatabase.createObjectStore')
357 @DocsEditable() 357 @DocsEditable()
358 ObjectStore _$dom_createObjectStore_2(name) native; 358 ObjectStore _createObjectStore_2(name) native;
359 359
360 @DomName('IDBDatabase.deleteObjectStore') 360 @DomName('IDBDatabase.deleteObjectStore')
361 @DocsEditable() 361 @DocsEditable()
362 void deleteObjectStore(String name) native; 362 void deleteObjectStore(String name) native;
363 363
364 @DomName('IDBDatabase.onabort') 364 @DomName('IDBDatabase.onabort')
365 @DocsEditable() 365 @DocsEditable()
366 Stream<Event> get onAbort => abortEvent.forTarget(this); 366 Stream<Event> get onAbort => abortEvent.forTarget(this);
367 367
368 @DomName('IDBDatabase.onclose') 368 @DomName('IDBDatabase.onclose')
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 Future<Database> open(String name, 405 Future<Database> open(String name,
406 {int version, void onUpgradeNeeded(VersionChangeEvent), 406 {int version, void onUpgradeNeeded(VersionChangeEvent),
407 void onBlocked(Event)}) { 407 void onBlocked(Event)}) {
408 if ((version == null) != (onUpgradeNeeded == null)) { 408 if ((version == null) != (onUpgradeNeeded == null)) {
409 return new Future.error(new ArgumentError( 409 return new Future.error(new ArgumentError(
410 'version and onUpgradeNeeded must be specified together')); 410 'version and onUpgradeNeeded must be specified together'));
411 } 411 }
412 try { 412 try {
413 var request; 413 var request;
414 if (version != null) { 414 if (version != null) {
415 request = $dom_open(name, version); 415 request = _open(name, version);
416 } else { 416 } else {
417 request = $dom_open(name); 417 request = _open(name);
418 } 418 }
419 419
420 if (onUpgradeNeeded != null) { 420 if (onUpgradeNeeded != null) {
421 request.onUpgradeNeeded.listen(onUpgradeNeeded); 421 request.onUpgradeNeeded.listen(onUpgradeNeeded);
422 } 422 }
423 if (onBlocked != null) { 423 if (onBlocked != null) {
424 request.onBlocked.listen(onBlocked); 424 request.onBlocked.listen(onBlocked);
425 } 425 }
426 return _completeRequest(request); 426 return _completeRequest(request);
427 } catch (e, stacktrace) { 427 } catch (e, stacktrace) {
428 return new Future.error(e, stacktrace); 428 return new Future.error(e, stacktrace);
429 } 429 }
430 } 430 }
431 431
432 @DomName('IDBFactory.deleteDatabase') 432 @DomName('IDBFactory.deleteDatabase')
433 Future<IdbFactory> deleteDatabase(String name, 433 Future<IdbFactory> deleteDatabase(String name,
434 {void onBlocked(Event)}) { 434 {void onBlocked(Event)}) {
435 try { 435 try {
436 var request = $dom_deleteDatabase(name); 436 var request = _deleteDatabase(name);
437 437
438 if (onBlocked != null) { 438 if (onBlocked != null) {
439 request.onBlocked.listen(onBlocked); 439 request.onBlocked.listen(onBlocked);
440 } 440 }
441 var completer = new Completer.sync(); 441 var completer = new Completer.sync();
442 request.onSuccess.listen((e) { 442 request.onSuccess.listen((e) {
443 completer.complete(this); 443 completer.complete(this);
444 }); 444 });
445 request.onError.listen((e) { 445 request.onError.listen((e) {
446 completer.completeError(e); 446 completer.completeError(e);
447 }); 447 });
448 return completer.future; 448 return completer.future;
449 } catch (e, stacktrace) { 449 } catch (e, stacktrace) {
450 return new Future.error(e, stacktrace); 450 return new Future.error(e, stacktrace);
451 } 451 }
452 } 452 }
453 453
454 @DomName('IDBFactory.getDatabaseNames') 454 @DomName('IDBFactory.getDatabaseNames')
455 @SupportedBrowser(SupportedBrowser.CHROME) 455 @SupportedBrowser(SupportedBrowser.CHROME)
456 @Experimental() 456 @Experimental()
457 Future<List<String>> getDatabaseNames() { 457 Future<List<String>> getDatabaseNames() {
458 try { 458 try {
459 var request = $dom_webkitGetDatabaseNames(); 459 var request = _webkitGetDatabaseNames();
460 460
461 return _completeRequest(request); 461 return _completeRequest(request);
462 } catch (e, stacktrace) { 462 } catch (e, stacktrace) {
463 return new Future.error(e, stacktrace); 463 return new Future.error(e, stacktrace);
464 } 464 }
465 } 465 }
466 466
467 /** 467 /**
468 * Checks to see if getDatabaseNames is supported by the current platform. 468 * Checks to see if getDatabaseNames is supported by the current platform.
469 */ 469 */
470 bool get supportsDatabaseNames { 470 bool get supportsDatabaseNames {
471 return supported && JS('bool', 471 return supported && JS('bool',
472 '!!(#.getDatabaseNames || #.webkitGetDatabaseNames)', this, this); 472 '!!(#.getDatabaseNames || #.webkitGetDatabaseNames)', this, this);
473 } 473 }
474 474
475 475
476 @DomName('IDBFactory.cmp') 476 @DomName('IDBFactory.cmp')
477 @DocsEditable() 477 @DocsEditable()
478 int cmp(Object first, Object second) native; 478 int cmp(Object first, Object second) native;
479 479
480 @JSName('deleteDatabase') 480 @JSName('deleteDatabase')
481 @DomName('IDBFactory.deleteDatabase') 481 @DomName('IDBFactory.deleteDatabase')
482 @DocsEditable() 482 @DocsEditable()
483 OpenDBRequest $dom_deleteDatabase(String name) native; 483 OpenDBRequest _deleteDatabase(String name) native;
484 484
485 @JSName('open') 485 @JSName('open')
486 @DomName('IDBFactory.open') 486 @DomName('IDBFactory.open')
487 @DocsEditable() 487 @DocsEditable()
488 @Returns('Request') 488 @Returns('Request')
489 @Creates('Request') 489 @Creates('Request')
490 @Creates('Database') 490 @Creates('Database')
491 OpenDBRequest $dom_open(String name, [int version]) native; 491 OpenDBRequest _open(String name, [int version]) native;
492 492
493 @JSName('webkitGetDatabaseNames') 493 @JSName('webkitGetDatabaseNames')
494 @DomName('IDBFactory.webkitGetDatabaseNames') 494 @DomName('IDBFactory.webkitGetDatabaseNames')
495 @DocsEditable() 495 @DocsEditable()
496 @SupportedBrowser(SupportedBrowser.CHROME) 496 @SupportedBrowser(SupportedBrowser.CHROME)
497 @SupportedBrowser(SupportedBrowser.SAFARI) 497 @SupportedBrowser(SupportedBrowser.SAFARI)
498 @Experimental() 498 @Experimental()
499 @Returns('Request') 499 @Returns('Request')
500 @Creates('Request') 500 @Creates('Request')
501 @Creates('DomStringList') 501 @Creates('DomStringList')
502 Request $dom_webkitGetDatabaseNames() native; 502 Request _webkitGetDatabaseNames() native;
503 503
504 } 504 }
505 505
506 506
507 /** 507 /**
508 * Ties a request to a completer, so the completer is completed when it succeeds 508 * Ties a request to a completer, so the completer is completed when it succeeds
509 * and errors out when the request errors. 509 * and errors out when the request errors.
510 */ 510 */
511 Future _completeRequest(Request request) { 511 Future _completeRequest(Request request) {
512 var completer = new Completer.sync(); 512 var completer = new Completer.sync();
(...skipping 13 matching lines...) Expand all
526 526
527 527
528 @DomName('IDBIndex') 528 @DomName('IDBIndex')
529 @Unstable() 529 @Unstable()
530 class Index extends Interceptor native "IDBIndex" { 530 class Index extends Interceptor native "IDBIndex" {
531 @DomName('IDBIndex.count') 531 @DomName('IDBIndex.count')
532 Future<int> count([key_OR_range]) { 532 Future<int> count([key_OR_range]) {
533 try { 533 try {
534 var request; 534 var request;
535 if (key_OR_range != null) { 535 if (key_OR_range != null) {
536 request = $dom_count(key_OR_range); 536 request = _count(key_OR_range);
537 } else { 537 } else {
538 request = $dom_count(); 538 request = _count();
539 } 539 }
540 return _completeRequest(request); 540 return _completeRequest(request);
541 } catch (e, stacktrace) { 541 } catch (e, stacktrace) {
542 return new Future.error(e, stacktrace); 542 return new Future.error(e, stacktrace);
543 } 543 }
544 } 544 }
545 545
546 @DomName('IDBIndex.get') 546 @DomName('IDBIndex.get')
547 Future get(key) { 547 Future get(key) {
548 try { 548 try {
549 var request = $dom_get(key); 549 var request = _get(key);
550 550
551 return _completeRequest(request); 551 return _completeRequest(request);
552 } catch (e, stacktrace) { 552 } catch (e, stacktrace) {
553 return new Future.error(e, stacktrace); 553 return new Future.error(e, stacktrace);
554 } 554 }
555 } 555 }
556 556
557 @DomName('IDBIndex.getKey') 557 @DomName('IDBIndex.getKey')
558 Future getKey(key) { 558 Future getKey(key) {
559 try { 559 try {
560 var request = $dom_getKey(key); 560 var request = _getKey(key);
561 561
562 return _completeRequest(request); 562 return _completeRequest(request);
563 } catch (e, stacktrace) { 563 } catch (e, stacktrace) {
564 return new Future.error(e, stacktrace); 564 return new Future.error(e, stacktrace);
565 } 565 }
566 } 566 }
567 567
568 /** 568 /**
569 * Creates a stream of cursors over the records in this object store. 569 * Creates a stream of cursors over the records in this object store.
570 * 570 *
571 * See also: 571 * See also:
572 * 572 *
573 * * [ObjectStore.openCursor] 573 * * [ObjectStore.openCursor]
574 */ 574 */
575 Stream<CursorWithValue> openCursor({key, KeyRange range, String direction, 575 Stream<CursorWithValue> openCursor({key, KeyRange range, String direction,
576 bool autoAdvance}) { 576 bool autoAdvance}) {
577 var key_OR_range = null; 577 var key_OR_range = null;
578 if (key != null) { 578 if (key != null) {
579 if (range != null) { 579 if (range != null) {
580 throw new ArgumentError('Cannot specify both key and range.'); 580 throw new ArgumentError('Cannot specify both key and range.');
581 } 581 }
582 key_OR_range = key; 582 key_OR_range = key;
583 } else { 583 } else {
584 key_OR_range = range; 584 key_OR_range = range;
585 } 585 }
586 var request; 586 var request;
587 if (direction == null) { 587 if (direction == null) {
588 request = $dom_openCursor(key_OR_range); 588 request = _openCursor(key_OR_range);
589 } else { 589 } else {
590 request = $dom_openCursor(key_OR_range, direction); 590 request = _openCursor(key_OR_range, direction);
591 } 591 }
592 return ObjectStore._cursorStreamFromResult(request, autoAdvance); 592 return ObjectStore._cursorStreamFromResult(request, autoAdvance);
593 } 593 }
594 594
595 /** 595 /**
596 * Creates a stream of cursors over the records in this object store. 596 * Creates a stream of cursors over the records in this object store.
597 * 597 *
598 * See also: 598 * See also:
599 * 599 *
600 * * [ObjectStore.openCursor] 600 * * [ObjectStore.openCursor]
601 */ 601 */
602 Stream<Cursor> openKeyCursor({key, KeyRange range, String direction, 602 Stream<Cursor> openKeyCursor({key, KeyRange range, String direction,
603 bool autoAdvance}) { 603 bool autoAdvance}) {
604 var key_OR_range = null; 604 var key_OR_range = null;
605 if (key != null) { 605 if (key != null) {
606 if (range != null) { 606 if (range != null) {
607 throw new ArgumentError('Cannot specify both key and range.'); 607 throw new ArgumentError('Cannot specify both key and range.');
608 } 608 }
609 key_OR_range = key; 609 key_OR_range = key;
610 } else { 610 } else {
611 key_OR_range = range; 611 key_OR_range = range;
612 } 612 }
613 var request; 613 var request;
614 if (direction == null) { 614 if (direction == null) {
615 request = $dom_openKeyCursor(key_OR_range); 615 request = _openKeyCursor(key_OR_range);
616 } else { 616 } else {
617 request = $dom_openKeyCursor(key_OR_range, direction); 617 request = _openKeyCursor(key_OR_range, direction);
618 } 618 }
619 return ObjectStore._cursorStreamFromResult(request, autoAdvance); 619 return ObjectStore._cursorStreamFromResult(request, autoAdvance);
620 } 620 }
621 621
622 622
623 @DomName('IDBIndex.keyPath') 623 @DomName('IDBIndex.keyPath')
624 @DocsEditable() 624 @DocsEditable()
625 @annotation_Creates_SerializedScriptValue 625 @annotation_Creates_SerializedScriptValue
626 final dynamic keyPath; 626 final dynamic keyPath;
627 627
628 @DomName('IDBIndex.multiEntry') 628 @DomName('IDBIndex.multiEntry')
629 @DocsEditable() 629 @DocsEditable()
630 final bool multiEntry; 630 final bool multiEntry;
631 631
632 @DomName('IDBIndex.name') 632 @DomName('IDBIndex.name')
633 @DocsEditable() 633 @DocsEditable()
634 final String name; 634 final String name;
635 635
636 @DomName('IDBIndex.objectStore') 636 @DomName('IDBIndex.objectStore')
637 @DocsEditable() 637 @DocsEditable()
638 final ObjectStore objectStore; 638 final ObjectStore objectStore;
639 639
640 @DomName('IDBIndex.unique') 640 @DomName('IDBIndex.unique')
641 @DocsEditable() 641 @DocsEditable()
642 final bool unique; 642 final bool unique;
643 643
644 @JSName('count') 644 @JSName('count')
645 @DomName('IDBIndex.count') 645 @DomName('IDBIndex.count')
646 @DocsEditable() 646 @DocsEditable()
647 Request $dom_count([key_OR_range]) native; 647 Request _count([key_OR_range]) native;
648 648
649 @JSName('get') 649 @JSName('get')
650 @DomName('IDBIndex.get') 650 @DomName('IDBIndex.get')
651 @DocsEditable() 651 @DocsEditable()
652 @Returns('Request') 652 @Returns('Request')
653 @Creates('Request') 653 @Creates('Request')
654 @annotation_Creates_SerializedScriptValue 654 @annotation_Creates_SerializedScriptValue
655 Request $dom_get(key) native; 655 Request _get(key) native;
656 656
657 @JSName('getKey') 657 @JSName('getKey')
658 @DomName('IDBIndex.getKey') 658 @DomName('IDBIndex.getKey')
659 @DocsEditable() 659 @DocsEditable()
660 @Returns('Request') 660 @Returns('Request')
661 @Creates('Request') 661 @Creates('Request')
662 @annotation_Creates_SerializedScriptValue 662 @annotation_Creates_SerializedScriptValue
663 @Creates('ObjectStore') 663 @Creates('ObjectStore')
664 Request $dom_getKey(key) native; 664 Request _getKey(key) native;
665 665
666 @JSName('openCursor') 666 @JSName('openCursor')
667 @DomName('IDBIndex.openCursor') 667 @DomName('IDBIndex.openCursor')
668 @DocsEditable() 668 @DocsEditable()
669 @Returns('Request') 669 @Returns('Request')
670 @Creates('Request') 670 @Creates('Request')
671 @Creates('Cursor') 671 @Creates('Cursor')
672 Request $dom_openCursor([key_OR_range, String direction]) native; 672 Request _openCursor([key_OR_range, String direction]) native;
673 673
674 @JSName('openKeyCursor') 674 @JSName('openKeyCursor')
675 @DomName('IDBIndex.openKeyCursor') 675 @DomName('IDBIndex.openKeyCursor')
676 @DocsEditable() 676 @DocsEditable()
677 @Returns('Request') 677 @Returns('Request')
678 @Creates('Request') 678 @Creates('Request')
679 @Creates('Cursor') 679 @Creates('Cursor')
680 Request $dom_openKeyCursor([key_OR_range, String direction]) native; 680 Request _openKeyCursor([key_OR_range, String direction]) native;
681 681
682 } 682 }
683 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 683 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
684 // for details. All rights reserved. Use of this source code is governed by a 684 // for details. All rights reserved. Use of this source code is governed by a
685 // BSD-style license that can be found in the LICENSE file. 685 // BSD-style license that can be found in the LICENSE file.
686 686
687 687
688 @DomName('IDBKeyRange') 688 @DomName('IDBKeyRange')
689 @Unstable() 689 @Unstable()
690 class KeyRange extends Interceptor native "IDBKeyRange" { 690 class KeyRange extends Interceptor native "IDBKeyRange" {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 753
754 @DomName('IDBObjectStore') 754 @DomName('IDBObjectStore')
755 @Unstable() 755 @Unstable()
756 class ObjectStore extends Interceptor native "IDBObjectStore" { 756 class ObjectStore extends Interceptor native "IDBObjectStore" {
757 757
758 @DomName('IDBObjectStore.add') 758 @DomName('IDBObjectStore.add')
759 Future add(value, [key]) { 759 Future add(value, [key]) {
760 try { 760 try {
761 var request; 761 var request;
762 if (key != null) { 762 if (key != null) {
763 request = $dom_add(value, key); 763 request = _add(value, key);
764 } else { 764 } else {
765 request = $dom_add(value); 765 request = _add(value);
766 } 766 }
767 return _completeRequest(request); 767 return _completeRequest(request);
768 } catch (e, stacktrace) { 768 } catch (e, stacktrace) {
769 return new Future.error(e, stacktrace); 769 return new Future.error(e, stacktrace);
770 } 770 }
771 } 771 }
772 772
773 @DomName('IDBObjectStore.clear') 773 @DomName('IDBObjectStore.clear')
774 Future clear() { 774 Future clear() {
775 try { 775 try {
776 return _completeRequest($dom_clear()); 776 return _completeRequest(_clear());
777 } catch (e, stacktrace) { 777 } catch (e, stacktrace) {
778 return new Future.error(e, stacktrace); 778 return new Future.error(e, stacktrace);
779 } 779 }
780 } 780 }
781 781
782 @DomName('IDBObjectStore.delete') 782 @DomName('IDBObjectStore.delete')
783 Future delete(key_OR_keyRange){ 783 Future delete(key_OR_keyRange){
784 try { 784 try {
785 return _completeRequest($dom_delete(key_OR_keyRange)); 785 return _completeRequest(_delete(key_OR_keyRange));
786 } catch (e, stacktrace) { 786 } catch (e, stacktrace) {
787 return new Future.error(e, stacktrace); 787 return new Future.error(e, stacktrace);
788 } 788 }
789 } 789 }
790 790
791 @DomName('IDBObjectStore.count') 791 @DomName('IDBObjectStore.count')
792 Future<int> count([key_OR_range]) { 792 Future<int> count([key_OR_range]) {
793 try { 793 try {
794 var request; 794 var request;
795 if (key_OR_range != null) { 795 if (key_OR_range != null) {
796 request = $dom_count(key_OR_range); 796 request = _count(key_OR_range);
797 } else { 797 } else {
798 request = $dom_count(); 798 request = _count();
799 } 799 }
800 return _completeRequest(request); 800 return _completeRequest(request);
801 } catch (e, stacktrace) { 801 } catch (e, stacktrace) {
802 return new Future.error(e, stacktrace); 802 return new Future.error(e, stacktrace);
803 } 803 }
804 } 804 }
805 805
806 @DomName('IDBObjectStore.put') 806 @DomName('IDBObjectStore.put')
807 Future put(value, [key]) { 807 Future put(value, [key]) {
808 try { 808 try {
809 var request; 809 var request;
810 if (key != null) { 810 if (key != null) {
811 request = $dom_put(value, key); 811 request = _put(value, key);
812 } else { 812 } else {
813 request = $dom_put(value); 813 request = _put(value);
814 } 814 }
815 return _completeRequest(request); 815 return _completeRequest(request);
816 } catch (e, stacktrace) { 816 } catch (e, stacktrace) {
817 return new Future.error(e, stacktrace); 817 return new Future.error(e, stacktrace);
818 } 818 }
819 } 819 }
820 820
821 @DomName('IDBObjectStore.get') 821 @DomName('IDBObjectStore.get')
822 Future getObject(key) { 822 Future getObject(key) {
823 try { 823 try {
824 var request = $dom_get(key); 824 var request = _get(key);
825 825
826 return _completeRequest(request); 826 return _completeRequest(request);
827 } catch (e, stacktrace) { 827 } catch (e, stacktrace) {
828 return new Future.error(e, stacktrace); 828 return new Future.error(e, stacktrace);
829 } 829 }
830 } 830 }
831 831
832 /** 832 /**
833 * Creates a stream of cursors over the records in this object store. 833 * Creates a stream of cursors over the records in this object store.
834 * 834 *
(...skipping 24 matching lines...) Expand all
859 throw new ArgumentError('Cannot specify both key and range.'); 859 throw new ArgumentError('Cannot specify both key and range.');
860 } 860 }
861 key_OR_range = key; 861 key_OR_range = key;
862 } else { 862 } else {
863 key_OR_range = range; 863 key_OR_range = range;
864 } 864 }
865 865
866 // TODO: try/catch this and return a stream with an immediate error. 866 // TODO: try/catch this and return a stream with an immediate error.
867 var request; 867 var request;
868 if (direction == null) { 868 if (direction == null) {
869 request = $dom_openCursor(key_OR_range); 869 request = _openCursor(key_OR_range);
870 } else { 870 } else {
871 request = $dom_openCursor(key_OR_range, direction); 871 request = _openCursor(key_OR_range, direction);
872 } 872 }
873 return _cursorStreamFromResult(request, autoAdvance); 873 return _cursorStreamFromResult(request, autoAdvance);
874 } 874 }
875 875
876 @DomName('IDBObjectStore.createIndex') 876 @DomName('IDBObjectStore.createIndex')
877 Index createIndex(String name, keyPath, {bool unique, bool multiEntry}) { 877 Index createIndex(String name, keyPath, {bool unique, bool multiEntry}) {
878 var options = {}; 878 var options = {};
879 if (unique != null) { 879 if (unique != null) {
880 options['unique'] = unique; 880 options['unique'] = unique;
881 } 881 }
882 if (multiEntry != null) { 882 if (multiEntry != null) {
883 options['multiEntry'] = multiEntry; 883 options['multiEntry'] = multiEntry;
884 } 884 }
885 885
886 return $dom_createIndex(name, keyPath, options); 886 return _createIndex(name, keyPath, options);
887 } 887 }
888 888
889 889
890 @DomName('IDBObjectStore.autoIncrement') 890 @DomName('IDBObjectStore.autoIncrement')
891 @DocsEditable() 891 @DocsEditable()
892 final bool autoIncrement; 892 final bool autoIncrement;
893 893
894 @DomName('IDBObjectStore.indexNames') 894 @DomName('IDBObjectStore.indexNames')
895 @DocsEditable() 895 @DocsEditable()
896 @Returns('DomStringList') 896 @Returns('DomStringList')
(...skipping 11 matching lines...) Expand all
908 908
909 @DomName('IDBObjectStore.transaction') 909 @DomName('IDBObjectStore.transaction')
910 @DocsEditable() 910 @DocsEditable()
911 final Transaction transaction; 911 final Transaction transaction;
912 912
913 @DomName('IDBObjectStore.add') 913 @DomName('IDBObjectStore.add')
914 @DocsEditable() 914 @DocsEditable()
915 @Returns('Request') 915 @Returns('Request')
916 @Creates('Request') 916 @Creates('Request')
917 @_annotation_Creates_IDBKey 917 @_annotation_Creates_IDBKey
918 Request $dom_add(/*any*/ value, [/*any*/ key]) { 918 Request _add(/*any*/ value, [/*any*/ key]) {
919 if (key != null) { 919 if (key != null) {
920 var value_1 = convertDartToNative_SerializedScriptValue(value); 920 var value_1 = convertDartToNative_SerializedScriptValue(value);
921 var key_2 = convertDartToNative_SerializedScriptValue(key); 921 var key_2 = convertDartToNative_SerializedScriptValue(key);
922 return _$dom_add_1(value_1, key_2); 922 return _add_1(value_1, key_2);
923 } 923 }
924 var value_3 = convertDartToNative_SerializedScriptValue(value); 924 var value_3 = convertDartToNative_SerializedScriptValue(value);
925 return _$dom_add_2(value_3); 925 return _add_2(value_3);
926 } 926 }
927 @JSName('add') 927 @JSName('add')
928 @DomName('IDBObjectStore.add') 928 @DomName('IDBObjectStore.add')
929 @DocsEditable() 929 @DocsEditable()
930 @Returns('Request') 930 @Returns('Request')
931 @Creates('Request') 931 @Creates('Request')
932 @_annotation_Creates_IDBKey 932 @_annotation_Creates_IDBKey
933 Request _$dom_add_1(value, key) native; 933 Request _add_1(value, key) native;
934 @JSName('add') 934 @JSName('add')
935 @DomName('IDBObjectStore.add') 935 @DomName('IDBObjectStore.add')
936 @DocsEditable() 936 @DocsEditable()
937 @Returns('Request') 937 @Returns('Request')
938 @Creates('Request') 938 @Creates('Request')
939 @_annotation_Creates_IDBKey 939 @_annotation_Creates_IDBKey
940 Request _$dom_add_2(value) native; 940 Request _add_2(value) native;
941 941
942 @JSName('clear') 942 @JSName('clear')
943 @DomName('IDBObjectStore.clear') 943 @DomName('IDBObjectStore.clear')
944 @DocsEditable() 944 @DocsEditable()
945 Request $dom_clear() native; 945 Request _clear() native;
946 946
947 @JSName('count') 947 @JSName('count')
948 @DomName('IDBObjectStore.count') 948 @DomName('IDBObjectStore.count')
949 @DocsEditable() 949 @DocsEditable()
950 Request $dom_count([key_OR_range]) native; 950 Request _count([key_OR_range]) native;
951 951
952 @DomName('IDBObjectStore.createIndex') 952 @DomName('IDBObjectStore.createIndex')
953 @DocsEditable() 953 @DocsEditable()
954 Index $dom_createIndex(String name, keyPath, [Map options]) { 954 Index _createIndex(String name, keyPath, [Map options]) {
955 if ((keyPath is List<String> || keyPath == null) && options == null) { 955 if ((keyPath is List<String> || keyPath == null) && options == null) {
956 List keyPath_1 = convertDartToNative_StringArray(keyPath); 956 List keyPath_1 = convertDartToNative_StringArray(keyPath);
957 return _$dom_createIndex_1(name, keyPath_1); 957 return _createIndex_1(name, keyPath_1);
958 } 958 }
959 if (options != null && (keyPath is List<String> || keyPath == null)) { 959 if (options != null && (keyPath is List<String> || keyPath == null)) {
960 List keyPath_2 = convertDartToNative_StringArray(keyPath); 960 List keyPath_2 = convertDartToNative_StringArray(keyPath);
961 var options_3 = convertDartToNative_Dictionary(options); 961 var options_3 = convertDartToNative_Dictionary(options);
962 return _$dom_createIndex_2(name, keyPath_2, options_3); 962 return _createIndex_2(name, keyPath_2, options_3);
963 } 963 }
964 if ((keyPath is String || keyPath == null) && options == null) { 964 if ((keyPath is String || keyPath == null) && options == null) {
965 return _$dom_createIndex_3(name, keyPath); 965 return _createIndex_3(name, keyPath);
966 } 966 }
967 if (options != null && (keyPath is String || keyPath == null)) { 967 if (options != null && (keyPath is String || keyPath == null)) {
968 var options_4 = convertDartToNative_Dictionary(options); 968 var options_4 = convertDartToNative_Dictionary(options);
969 return _$dom_createIndex_4(name, keyPath, options_4); 969 return _createIndex_4(name, keyPath, options_4);
970 } 970 }
971 throw new ArgumentError("Incorrect number or type of arguments"); 971 throw new ArgumentError("Incorrect number or type of arguments");
972 } 972 }
973 @JSName('createIndex') 973 @JSName('createIndex')
974 @DomName('IDBObjectStore.createIndex') 974 @DomName('IDBObjectStore.createIndex')
975 @DocsEditable() 975 @DocsEditable()
976 Index _$dom_createIndex_1(name, List keyPath) native; 976 Index _createIndex_1(name, List keyPath) native;
977 @JSName('createIndex') 977 @JSName('createIndex')
978 @DomName('IDBObjectStore.createIndex') 978 @DomName('IDBObjectStore.createIndex')
979 @DocsEditable() 979 @DocsEditable()
980 Index _$dom_createIndex_2(name, List keyPath, options) native; 980 Index _createIndex_2(name, List keyPath, options) native;
981 @JSName('createIndex') 981 @JSName('createIndex')
982 @DomName('IDBObjectStore.createIndex') 982 @DomName('IDBObjectStore.createIndex')
983 @DocsEditable() 983 @DocsEditable()
984 Index _$dom_createIndex_3(name, String keyPath) native; 984 Index _createIndex_3(name, String keyPath) native;
985 @JSName('createIndex') 985 @JSName('createIndex')
986 @DomName('IDBObjectStore.createIndex') 986 @DomName('IDBObjectStore.createIndex')
987 @DocsEditable() 987 @DocsEditable()
988 Index _$dom_createIndex_4(name, String keyPath, options) native; 988 Index _createIndex_4(name, String keyPath, options) native;
989 989
990 @JSName('delete') 990 @JSName('delete')
991 @DomName('IDBObjectStore.delete') 991 @DomName('IDBObjectStore.delete')
992 @DocsEditable() 992 @DocsEditable()
993 Request $dom_delete(key_OR_keyRange) native; 993 Request _delete(key_OR_keyRange) native;
994 994
995 @DomName('IDBObjectStore.deleteIndex') 995 @DomName('IDBObjectStore.deleteIndex')
996 @DocsEditable() 996 @DocsEditable()
997 void deleteIndex(String name) native; 997 void deleteIndex(String name) native;
998 998
999 @JSName('get') 999 @JSName('get')
1000 @DomName('IDBObjectStore.get') 1000 @DomName('IDBObjectStore.get')
1001 @DocsEditable() 1001 @DocsEditable()
1002 @Returns('Request') 1002 @Returns('Request')
1003 @Creates('Request') 1003 @Creates('Request')
1004 @annotation_Creates_SerializedScriptValue 1004 @annotation_Creates_SerializedScriptValue
1005 Request $dom_get(key) native; 1005 Request _get(key) native;
1006 1006
1007 @DomName('IDBObjectStore.index') 1007 @DomName('IDBObjectStore.index')
1008 @DocsEditable() 1008 @DocsEditable()
1009 Index index(String name) native; 1009 Index index(String name) native;
1010 1010
1011 @JSName('openCursor') 1011 @JSName('openCursor')
1012 @DomName('IDBObjectStore.openCursor') 1012 @DomName('IDBObjectStore.openCursor')
1013 @DocsEditable() 1013 @DocsEditable()
1014 @Returns('Request') 1014 @Returns('Request')
1015 @Creates('Request') 1015 @Creates('Request')
1016 @Creates('Cursor') 1016 @Creates('Cursor')
1017 Request $dom_openCursor([key_OR_range, String direction]) native; 1017 Request _openCursor([key_OR_range, String direction]) native;
1018 1018
1019 @DomName('IDBObjectStore.put') 1019 @DomName('IDBObjectStore.put')
1020 @DocsEditable() 1020 @DocsEditable()
1021 @Returns('Request') 1021 @Returns('Request')
1022 @Creates('Request') 1022 @Creates('Request')
1023 @_annotation_Creates_IDBKey 1023 @_annotation_Creates_IDBKey
1024 Request $dom_put(/*any*/ value, [/*any*/ key]) { 1024 Request _put(/*any*/ value, [/*any*/ key]) {
1025 if (key != null) { 1025 if (key != null) {
1026 var value_1 = convertDartToNative_SerializedScriptValue(value); 1026 var value_1 = convertDartToNative_SerializedScriptValue(value);
1027 var key_2 = convertDartToNative_SerializedScriptValue(key); 1027 var key_2 = convertDartToNative_SerializedScriptValue(key);
1028 return _$dom_put_1(value_1, key_2); 1028 return _put_1(value_1, key_2);
1029 } 1029 }
1030 var value_3 = convertDartToNative_SerializedScriptValue(value); 1030 var value_3 = convertDartToNative_SerializedScriptValue(value);
1031 return _$dom_put_2(value_3); 1031 return _put_2(value_3);
1032 } 1032 }
1033 @JSName('put') 1033 @JSName('put')
1034 @DomName('IDBObjectStore.put') 1034 @DomName('IDBObjectStore.put')
1035 @DocsEditable() 1035 @DocsEditable()
1036 @Returns('Request') 1036 @Returns('Request')
1037 @Creates('Request') 1037 @Creates('Request')
1038 @_annotation_Creates_IDBKey 1038 @_annotation_Creates_IDBKey
1039 Request _$dom_put_1(value, key) native; 1039 Request _put_1(value, key) native;
1040 @JSName('put') 1040 @JSName('put')
1041 @DomName('IDBObjectStore.put') 1041 @DomName('IDBObjectStore.put')
1042 @DocsEditable() 1042 @DocsEditable()
1043 @Returns('Request') 1043 @Returns('Request')
1044 @Creates('Request') 1044 @Creates('Request')
1045 @_annotation_Creates_IDBKey 1045 @_annotation_Creates_IDBKey
1046 Request _$dom_put_2(value) native; 1046 Request _put_2(value) native;
1047 1047
1048 1048
1049 /** 1049 /**
1050 * Helper for iterating over cursors in a request. 1050 * Helper for iterating over cursors in a request.
1051 */ 1051 */
1052 static Stream<Cursor> _cursorStreamFromResult(Request request, 1052 static Stream<Cursor> _cursorStreamFromResult(Request request,
1053 bool autoAdvance) { 1053 bool autoAdvance) {
1054 // TODO: need to guarantee that the controller provides the values 1054 // TODO: need to guarantee that the controller provides the values
1055 // immediately as waiting until the next tick will cause the transaction to 1055 // immediately as waiting until the next tick will cause the transaction to
1056 // close. 1056 // close.
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1269 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
1270 // for details. All rights reserved. Use of this source code is governed by a 1270 // for details. All rights reserved. Use of this source code is governed by a
1271 // BSD-style license that can be found in the LICENSE file. 1271 // BSD-style license that can be found in the LICENSE file.
1272 1272
1273 1273
1274 @DocsEditable() 1274 @DocsEditable()
1275 @DomName('IDBAny') 1275 @DomName('IDBAny')
1276 @deprecated // nonstandard 1276 @deprecated // nonstandard
1277 abstract class _IDBAny extends Interceptor native "IDBAny" { 1277 abstract class _IDBAny extends Interceptor native "IDBAny" {
1278 } 1278 }
OLDNEW
« no previous file with comments | « sdk/lib/html/html_common/device.dart ('k') | sdk/lib/indexed_db/dartium/indexed_db_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698