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

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

Issue 1700153002: Wrapperless dart:html and friends (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: A couple more tweaks Created 4 years, 10 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
(Empty)
1 /**
2 * A client-side key-value store with support for indexes.
3 *
4 * Many browsers support IndexedDB—a web standard for
5 * an indexed database.
6 * By storing data on the client in an IndexedDB,
7 * a web app gets some advantages, such as faster performance and persistence.
8 * To find out which browsers support IndexedDB,
9 * refer to [Can I Use?](http://caniuse.com/#feat=indexeddb)
10 *
11 * In IndexedDB, each record is identified by a unique index or key,
12 * making data retrieval speedy.
13 * You can store structured data,
14 * such as images, arrays, and maps using IndexedDB.
15 * The standard does not specify size limits for individual data items
16 * or for the database itself, but browsers may impose storage limits.
17 *
18 * ## Using indexed_db
19 *
20 * The classes in this library provide an interface
21 * to the browser's IndexedDB, if it has one.
22 * To use this library in your code:
23 *
24 * import 'dart:indexed_db';
25 *
26 * A web app can determine if the browser supports
27 * IndexedDB with [IdbFactory.supported]:
28 *
29 * if (IdbFactory.supported)
30 * // Use indexeddb.
31 * else
32 * // Find an alternative.
33 *
34 * Access to the browser's IndexedDB is provided by the app's top-level
35 * [Window] object, which your code can refer to with `window.indexedDB`.
36 * So, for example,
37 * here's how to use window.indexedDB to open a database:
38 *
39 * Future open() {
40 * return window.indexedDB.open('myIndexedDB',
41 * version: 1,
42 * onUpgradeNeeded: _initializeDatabase)
43 * .then(_loadFromDB);
44 * }
45 * void _initializeDatabase(VersionChangeEvent e) {
46 * ...
47 * }
48 * Future _loadFromDB(Database db) {
49 * ...
50 * }
51 *
52 *
53 * All data in an IndexedDB is stored within an [ObjectStore].
54 * To manipulate the database use [Transaction]s.
55 *
56 * ## Other resources
57 *
58 * Other options for client-side data storage include:
59 *
60 * * [Window.localStorage]—a
61 * basic mechanism that stores data as a [Map],
62 * and where both the keys and the values are strings.
63 *
64 * * [dart:web_sql]—a database that can be queried with SQL.
65 *
66 * For a tutorial about using the indexed_db library with Dart,
67 * check out
68 * [Use IndexedDB](http://www.dartlang.org/docs/tutorials/indexeddb/).
69 *
70 * [IndexedDB reference](http://docs.webplatform.org/wiki/apis/indexeddb)
71 * provides wiki-style docs about indexedDB
72 */
73 library dart.dom.indexed_db;
74
75 import 'dart:async';
76 import 'dart:html';
77 import 'dart:html_common';
78 import 'dart:_native_typed_data';
79 import 'dart:typed_data';
80 import 'dart:_js_helper' show Creates, Returns, JSName, Native;
81 import 'dart:_foreign_helper' show JS;
82 import 'dart:_interceptors' show Interceptor, JSExtendableArray;
83 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
84 // for details. All rights reserved. Use of this source code is governed by a
85 // BSD-style license that can be found in the LICENSE file.
86
87 // DO NOT EDIT - unless you are editing documentation as per:
88 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
89 // Auto-generated dart:svg library.
90
91
92
93
94
95 class _KeyRangeFactoryProvider {
96
97 static KeyRange createKeyRange_only(/*Key*/ value) =>
98 _only(_class(), _translateKey(value));
99
100 static KeyRange createKeyRange_lowerBound(
101 /*Key*/ bound, [bool open = false]) =>
102 _lowerBound(_class(), _translateKey(bound), open);
103
104 static KeyRange createKeyRange_upperBound(
105 /*Key*/ bound, [bool open = false]) =>
106 _upperBound(_class(), _translateKey(bound), open);
107
108 static KeyRange createKeyRange_bound(/*Key*/ lower, /*Key*/ upper,
109 [bool lowerOpen = false, bool upperOpen = false]) =>
110 _bound(_class(), _translateKey(lower), _translateKey(upper),
111 lowerOpen, upperOpen);
112
113 static var _cachedClass;
114
115 static _class() {
116 if (_cachedClass != null) return _cachedClass;
117 return _cachedClass = _uncachedClass();
118 }
119
120 static _uncachedClass() =>
121 JS('var',
122 '''window.webkitIDBKeyRange || window.mozIDBKeyRange ||
123 window.msIDBKeyRange || window.IDBKeyRange''');
124
125 static _translateKey(idbkey) => idbkey; // TODO: fixme.
126
127 static KeyRange _only(cls, value) =>
128 JS('KeyRange', '#.only(#)', cls, value);
129
130 static KeyRange _lowerBound(cls, bound, open) =>
131 JS('KeyRange', '#.lowerBound(#, #)', cls, bound, open);
132
133 static KeyRange _upperBound(cls, bound, open) =>
134 JS('KeyRange', '#.upperBound(#, #)', cls, bound, open);
135
136 static KeyRange _bound(cls, lower, upper, lowerOpen, upperOpen) =>
137 JS('KeyRange', '#.bound(#, #, #, #)',
138 cls, lower, upper, lowerOpen, upperOpen);
139 }
140
141 // Conversions for IDBKey.
142 //
143 // Per http://www.w3.org/TR/IndexedDB/#key-construct
144 //
145 // "A value is said to be a valid key if it is one of the following types: Array
146 // JavaScript objects [ECMA-262], DOMString [WEBIDL], Date [ECMA-262] or float
147 // [WEBIDL]. However Arrays are only valid keys if every item in the array is
148 // defined and is a valid key (i.e. sparse arrays can not be valid keys) and if
149 // the Array doesn't directly or indirectly contain itself. Any non-numeric
150 // properties are ignored, and thus does not affect whether the Array is a valid
151 // key. Additionally, if the value is of type float, it is only a valid key if
152 // it is not NaN, and if the value is of type Date it is only a valid key if its
153 // [[PrimitiveValue]] internal property, as defined by [ECMA-262], is not NaN."
154
155 // What is required is to ensure that an Lists in the key are actually
156 // JavaScript arrays, and any Dates are JavaScript Dates.
157
158
159 /**
160 * Converts a native IDBKey into a Dart object.
161 *
162 * May return the original input. May mutate the original input (but will be
163 * idempotent if mutation occurs). It is assumed that this conversion happens
164 * on native IDBKeys on all paths that return IDBKeys from native DOM calls.
165 *
166 * If necessary, JavaScript Dates are converted into Dart Dates.
167 */
168 _convertNativeToDart_IDBKey(nativeKey) {
169 containsDate(object) {
170 if (isJavaScriptDate(object)) return true;
171 if (object is List) {
172 for (int i = 0; i < object.length; i++) {
173 if (containsDate(object[i])) return true;
174 }
175 }
176 return false; // number, string.
177 }
178 if (containsDate(nativeKey)) {
179 throw new UnimplementedError('Key containing DateTime');
180 }
181 // TODO: Cache conversion somewhere?
182 return nativeKey;
183 }
184
185 /**
186 * Converts a Dart object into a valid IDBKey.
187 *
188 * May return the original input. Does not mutate input.
189 *
190 * If necessary, [dartKey] may be copied to ensure all lists are converted into
191 * JavaScript Arrays and Dart Dates into JavaScript Dates.
192 */
193 _convertDartToNative_IDBKey(dartKey) {
194 // TODO: Implement.
195 return dartKey;
196 }
197
198
199
200 /// May modify original. If so, action is idempotent.
201 _convertNativeToDart_IDBAny(object) {
202 return convertNativeToDart_AcceptStructuredClone(object, mustCopy: false);
203 }
204
205 // TODO(sra): Add DateTime.
206 const String _idbKey = 'JSExtendableArray|=Object|num|String';
207 const _annotation_Creates_IDBKey = const Creates(_idbKey);
208 const _annotation_Returns_IDBKey = const Returns(_idbKey);
209 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
210 // for details. All rights reserved. Use of this source code is governed by a
211 // BSD-style license that can be found in the LICENSE file.
212
213
214 @DomName('IDBCursor')
215 @Unstable()
216 @Native("IDBCursor")
217 class Cursor extends Interceptor {
218 @DomName('IDBCursor.delete')
219 Future delete() {
220 try {
221 return _completeRequest(_delete());
222 } catch (e, stacktrace) {
223 return new Future.error(e, stacktrace);
224 }
225 }
226
227 @DomName('IDBCursor.value')
228 Future update(value) {
229 try {
230 return _completeRequest(_update(value));
231 } catch (e, stacktrace) {
232 return new Future.error(e, stacktrace);
233 }
234 }
235
236 @JSName('continue')
237 @DomName('IDBCursor.continue')
238 void next([Object key]) {
239 if (key == null) {
240 JS('void', '#.continue()', this);
241 } else {
242 JS('void', '#.continue(#)', this, key);
243 }
244 }
245 // To suppress missing implicit constructor warnings.
246 factory Cursor._() { throw new UnsupportedError("Not supported"); }
247
248 @DomName('IDBCursor.direction')
249 @DocsEditable()
250 final String direction;
251
252 @DomName('IDBCursor.key')
253 @DocsEditable()
254 @_annotation_Creates_IDBKey
255 @_annotation_Returns_IDBKey
256 final Object key;
257
258 @DomName('IDBCursor.primaryKey')
259 @DocsEditable()
260 @_annotation_Creates_IDBKey
261 @_annotation_Returns_IDBKey
262 final Object primaryKey;
263
264 @DomName('IDBCursor.source')
265 @DocsEditable()
266 @Creates('Null')
267 @Returns('ObjectStore|Index|Null')
268 final Object source;
269
270 @DomName('IDBCursor.advance')
271 @DocsEditable()
272 void advance(int count) native;
273
274 @DomName('IDBCursor.continuePrimaryKey')
275 @DocsEditable()
276 @Experimental() // untriaged
277 void continuePrimaryKey(Object key, Object primaryKey) native;
278
279 @JSName('delete')
280 @DomName('IDBCursor.delete')
281 @DocsEditable()
282 Request _delete() native;
283
284 @DomName('IDBCursor.update')
285 @DocsEditable()
286 Request _update(/*any*/ value) {
287 var value_1 = convertDartToNative_SerializedScriptValue(value);
288 return _update_1(value_1);
289 }
290 @JSName('update')
291 @DomName('IDBCursor.update')
292 @DocsEditable()
293 Request _update_1(value) native;
294
295 }
296 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
297 // for details. All rights reserved. Use of this source code is governed by a
298 // BSD-style license that can be found in the LICENSE file.
299
300
301 @DocsEditable()
302 @DomName('IDBCursorWithValue')
303 @Unstable()
304 @Native("IDBCursorWithValue")
305 class CursorWithValue extends Cursor {
306 // To suppress missing implicit constructor warnings.
307 factory CursorWithValue._() { throw new UnsupportedError("Not supported"); }
308
309 @DomName('IDBCursorWithValue.value')
310 @DocsEditable()
311 dynamic get value => _convertNativeToDart_IDBAny(this._get_value);
312 @JSName('value')
313 @DomName('IDBCursorWithValue.value')
314 @DocsEditable()
315 @annotation_Creates_SerializedScriptValue
316 @annotation_Returns_SerializedScriptValue
317 final dynamic _get_value;
318 }
319 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
320 // for details. All rights reserved. Use of this source code is governed by a
321 // BSD-style license that can be found in the LICENSE file.
322
323
324 @DocsEditable()
325 /**
326 * An indexed database object for storing client-side data
327 * in web apps.
328 */
329 @DomName('IDBDatabase')
330 @SupportedBrowser(SupportedBrowser.CHROME)
331 @SupportedBrowser(SupportedBrowser.FIREFOX, '15')
332 @SupportedBrowser(SupportedBrowser.IE, '10')
333 @Experimental()
334 @Unstable()
335 @Native("IDBDatabase")
336 class Database extends EventTarget {
337 @DomName('IDBDatabase.createObjectStore')
338 @DocsEditable()
339 ObjectStore createObjectStore(String name,
340 {String keyPath, bool autoIncrement}) {
341 var options = {};
342 if (keyPath != null) {
343 options['keyPath'] = keyPath;
344 }
345 if (autoIncrement != null) {
346 options['autoIncrement'] = autoIncrement;
347 }
348
349 return _createObjectStore(name, options);
350 }
351
352 Transaction transaction(storeName_OR_storeNames, String mode) {
353 if (mode != 'readonly' && mode != 'readwrite') {
354 throw new ArgumentError(mode);
355 }
356
357 // TODO(sra): Ensure storeName_OR_storeNames is a string or List<String>,
358 // and copy to JavaScript array if necessary.
359
360 // Try and create a transaction with a string mode. Browsers that expect a
361 // numeric mode tend to convert the string into a number. This fails
362 // silently, resulting in zero ('readonly').
363 return _transaction(storeName_OR_storeNames, mode);
364 }
365
366 Transaction transactionStore(String storeName, String mode) {
367 if (mode != 'readonly' && mode != 'readwrite') {
368 throw new ArgumentError(mode);
369 }
370 // Try and create a transaction with a string mode. Browsers that expect a
371 // numeric mode tend to convert the string into a number. This fails
372 // silently, resulting in zero ('readonly').
373 return _transaction(storeName, mode);
374 }
375
376 Transaction transactionList(List<String> storeNames, String mode) {
377 if (mode != 'readonly' && mode != 'readwrite') {
378 throw new ArgumentError(mode);
379 }
380 List storeNames_1 = convertDartToNative_StringArray(storeNames);
381 return _transaction(storeNames_1, mode);
382 }
383
384 Transaction transactionStores(DomStringList storeNames, String mode) {
385 if (mode != 'readonly' && mode != 'readwrite') {
386 throw new ArgumentError(mode);
387 }
388 return _transaction(storeNames, mode);
389 }
390
391 @JSName('transaction')
392 Transaction _transaction(stores, mode) native;
393
394 // To suppress missing implicit constructor warnings.
395 factory Database._() { throw new UnsupportedError("Not supported"); }
396
397 /**
398 * Static factory designed to expose `abort` events to event
399 * handlers that are not necessarily instances of [Database].
400 *
401 * See [EventStreamProvider] for usage information.
402 */
403 @DomName('IDBDatabase.abortEvent')
404 @DocsEditable()
405 static const EventStreamProvider<Event> abortEvent = const EventStreamProvider <Event>('abort');
406
407 /**
408 * Static factory designed to expose `close` events to event
409 * handlers that are not necessarily instances of [Database].
410 *
411 * See [EventStreamProvider] for usage information.
412 */
413 @DomName('IDBDatabase.closeEvent')
414 @DocsEditable()
415 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=22540
416 @Experimental()
417 static const EventStreamProvider<Event> closeEvent = const EventStreamProvider <Event>('close');
418
419 /**
420 * Static factory designed to expose `error` events to event
421 * handlers that are not necessarily instances of [Database].
422 *
423 * See [EventStreamProvider] for usage information.
424 */
425 @DomName('IDBDatabase.errorEvent')
426 @DocsEditable()
427 static const EventStreamProvider<Event> errorEvent = const EventStreamProvider <Event>('error');
428
429 /**
430 * Static factory designed to expose `versionchange` events to event
431 * handlers that are not necessarily instances of [Database].
432 *
433 * See [EventStreamProvider] for usage information.
434 */
435 @DomName('IDBDatabase.versionchangeEvent')
436 @DocsEditable()
437 static const EventStreamProvider<VersionChangeEvent> versionChangeEvent = cons t EventStreamProvider<VersionChangeEvent>('versionchange');
438
439 @DomName('IDBDatabase.name')
440 @DocsEditable()
441 final String name;
442
443 @DomName('IDBDatabase.objectStoreNames')
444 @DocsEditable()
445 @Returns('DomStringList')
446 @Creates('DomStringList')
447 final List<String> objectStoreNames;
448
449 @DomName('IDBDatabase.version')
450 @DocsEditable()
451 @Creates('int|String|Null')
452 @Returns('int|String|Null')
453 final Object version;
454
455 @DomName('IDBDatabase.close')
456 @DocsEditable()
457 void close() native;
458
459 @DomName('IDBDatabase.createObjectStore')
460 @DocsEditable()
461 ObjectStore _createObjectStore(String name, [Map options]) {
462 if (options != null) {
463 var options_1 = convertDartToNative_Dictionary(options);
464 return _createObjectStore_1(name, options_1);
465 }
466 return _createObjectStore_2(name);
467 }
468 @JSName('createObjectStore')
469 @DomName('IDBDatabase.createObjectStore')
470 @DocsEditable()
471 ObjectStore _createObjectStore_1(name, options) native;
472 @JSName('createObjectStore')
473 @DomName('IDBDatabase.createObjectStore')
474 @DocsEditable()
475 ObjectStore _createObjectStore_2(name) native;
476
477 @DomName('IDBDatabase.deleteObjectStore')
478 @DocsEditable()
479 void deleteObjectStore(String name) native;
480
481 /// Stream of `abort` events handled by this [Database].
482 @DomName('IDBDatabase.onabort')
483 @DocsEditable()
484 Stream<Event> get onAbort => abortEvent.forTarget(this);
485
486 /// Stream of `close` events handled by this [Database].
487 @DomName('IDBDatabase.onclose')
488 @DocsEditable()
489 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=22540
490 @Experimental()
491 Stream<Event> get onClose => closeEvent.forTarget(this);
492
493 /// Stream of `error` events handled by this [Database].
494 @DomName('IDBDatabase.onerror')
495 @DocsEditable()
496 Stream<Event> get onError => errorEvent.forTarget(this);
497
498 /// Stream of `versionchange` events handled by this [Database].
499 @DomName('IDBDatabase.onversionchange')
500 @DocsEditable()
501 Stream<VersionChangeEvent> get onVersionChange => versionChangeEvent.forTarget (this);
502 }
503 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
504 // for details. All rights reserved. Use of this source code is governed by a
505 // BSD-style license that can be found in the LICENSE file.
506
507
508 @DomName('IDBFactory')
509 @SupportedBrowser(SupportedBrowser.CHROME)
510 @SupportedBrowser(SupportedBrowser.FIREFOX, '15')
511 @SupportedBrowser(SupportedBrowser.IE, '10')
512 @Experimental()
513 @Unstable()
514 @Native("IDBFactory")
515 class IdbFactory extends Interceptor {
516 /**
517 * Checks to see if Indexed DB is supported on the current platform.
518 */
519 static bool get supported {
520 return JS('bool',
521 '!!(window.indexedDB || '
522 'window.webkitIndexedDB || '
523 'window.mozIndexedDB)');
524 }
525
526 @DomName('IDBFactory.open')
527 Future<Database> open(String name,
528 {int version, void onUpgradeNeeded(VersionChangeEvent),
529 void onBlocked(Event)}) {
530 if ((version == null) != (onUpgradeNeeded == null)) {
531 return new Future.error(new ArgumentError(
532 'version and onUpgradeNeeded must be specified together'));
533 }
534 try {
535 var request;
536 if (version != null) {
537 request = _open(name, version);
538 } else {
539 request = _open(name);
540 }
541
542 if (onUpgradeNeeded != null) {
543 request.onUpgradeNeeded.listen(onUpgradeNeeded);
544 }
545 if (onBlocked != null) {
546 request.onBlocked.listen(onBlocked);
547 }
548 return _completeRequest(request);
549 } catch (e, stacktrace) {
550 return new Future.error(e, stacktrace);
551 }
552 }
553
554 @DomName('IDBFactory.deleteDatabase')
555 Future<IdbFactory> deleteDatabase(String name,
556 {void onBlocked(Event)}) {
557 try {
558 var request = _deleteDatabase(name);
559
560 if (onBlocked != null) {
561 request.onBlocked.listen(onBlocked);
562 }
563 var completer = new Completer.sync();
564 request.onSuccess.listen((e) {
565 completer.complete(this);
566 });
567 request.onError.listen(completer.completeError);
568 return completer.future;
569 } catch (e, stacktrace) {
570 return new Future.error(e, stacktrace);
571 }
572 }
573
574 @DomName('IDBFactory.getDatabaseNames')
575 @SupportedBrowser(SupportedBrowser.CHROME)
576 @Experimental()
577 Future<List<String>> getDatabaseNames() {
578 try {
579 var request = _webkitGetDatabaseNames();
580
581 return _completeRequest(request);
582 } catch (e, stacktrace) {
583 return new Future.error(e, stacktrace);
584 }
585 }
586
587 /**
588 * Checks to see if getDatabaseNames is supported by the current platform.
589 */
590 bool get supportsDatabaseNames {
591 return supported && JS('bool',
592 '!!(#.getDatabaseNames || #.webkitGetDatabaseNames)', this, this);
593 }
594
595 // To suppress missing implicit constructor warnings.
596 factory IdbFactory._() { throw new UnsupportedError("Not supported"); }
597
598 @DomName('IDBFactory.cmp')
599 @DocsEditable()
600 int cmp(Object first, Object second) native;
601
602 @JSName('deleteDatabase')
603 @DomName('IDBFactory.deleteDatabase')
604 @DocsEditable()
605 OpenDBRequest _deleteDatabase(String name) native;
606
607 @JSName('open')
608 @DomName('IDBFactory.open')
609 @DocsEditable()
610 @Returns('Request')
611 @Creates('Request')
612 @Creates('Database')
613 OpenDBRequest _open(String name, [int version]) native;
614
615 @JSName('webkitGetDatabaseNames')
616 @DomName('IDBFactory.webkitGetDatabaseNames')
617 @DocsEditable()
618 @SupportedBrowser(SupportedBrowser.CHROME)
619 @SupportedBrowser(SupportedBrowser.SAFARI)
620 @Experimental()
621 @Returns('Request')
622 @Creates('Request')
623 @Creates('DomStringList')
624 Request _webkitGetDatabaseNames() native;
625
626 }
627
628
629 /**
630 * Ties a request to a completer, so the completer is completed when it succeeds
631 * and errors out when the request errors.
632 */
633 Future _completeRequest(Request request) {
634 var completer = new Completer.sync();
635 // TODO: make sure that completer.complete is synchronous as transactions
636 // may be committed if the result is not processed immediately.
637 request.onSuccess.listen((e) {
638 completer.complete(request.result);
639 });
640 request.onError.listen(completer.completeError);
641 return completer.future;
642 }
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
645 // BSD-style license that can be found in the LICENSE file.
646
647
648 @DomName('IDBIndex')
649 @Unstable()
650 @Native("IDBIndex")
651 class Index extends Interceptor {
652 @DomName('IDBIndex.count')
653 Future<int> count([key_OR_range]) {
654 try {
655 var request = _count(key_OR_range);
656 return _completeRequest(request);
657 } catch (e, stacktrace) {
658 return new Future.error(e, stacktrace);
659 }
660 }
661
662 @DomName('IDBIndex.get')
663 Future get(key) {
664 try {
665 var request = _get(key);
666
667 return _completeRequest(request);
668 } catch (e, stacktrace) {
669 return new Future.error(e, stacktrace);
670 }
671 }
672
673 @DomName('IDBIndex.getKey')
674 Future getKey(key) {
675 try {
676 var request = _getKey(key);
677
678 return _completeRequest(request);
679 } catch (e, stacktrace) {
680 return new Future.error(e, stacktrace);
681 }
682 }
683
684 /**
685 * Creates a stream of cursors over the records in this object store.
686 *
687 * See also:
688 *
689 * * [ObjectStore.openCursor]
690 */
691 Stream<CursorWithValue> openCursor({key, KeyRange range, String direction,
692 bool autoAdvance}) {
693 var key_OR_range = null;
694 if (key != null) {
695 if (range != null) {
696 throw new ArgumentError('Cannot specify both key and range.');
697 }
698 key_OR_range = key;
699 } else {
700 key_OR_range = range;
701 }
702 var request;
703 if (direction == null) {
704 // FIXME: Passing in "next" should be unnecessary.
705 request = _openCursor(key_OR_range, "next");
706 } else {
707 request = _openCursor(key_OR_range, direction);
708 }
709 return ObjectStore._cursorStreamFromResult(request, autoAdvance);
710 }
711
712 /**
713 * Creates a stream of cursors over the records in this object store.
714 *
715 * See also:
716 *
717 * * [ObjectStore.openCursor]
718 */
719 Stream<Cursor> openKeyCursor({key, KeyRange range, String direction,
720 bool autoAdvance}) {
721 var key_OR_range = null;
722 if (key != null) {
723 if (range != null) {
724 throw new ArgumentError('Cannot specify both key and range.');
725 }
726 key_OR_range = key;
727 } else {
728 key_OR_range = range;
729 }
730 var request;
731 if (direction == null) {
732 // FIXME: Passing in "next" should be unnecessary.
733 request = _openKeyCursor(key_OR_range, "next");
734 } else {
735 request = _openKeyCursor(key_OR_range, direction);
736 }
737 return ObjectStore._cursorStreamFromResult(request, autoAdvance);
738 }
739
740 // To suppress missing implicit constructor warnings.
741 factory Index._() { throw new UnsupportedError("Not supported"); }
742
743 @DomName('IDBIndex.keyPath')
744 @DocsEditable()
745 @annotation_Creates_SerializedScriptValue
746 final Object keyPath;
747
748 @DomName('IDBIndex.multiEntry')
749 @DocsEditable()
750 final bool multiEntry;
751
752 @DomName('IDBIndex.name')
753 @DocsEditable()
754 final String name;
755
756 @DomName('IDBIndex.objectStore')
757 @DocsEditable()
758 final ObjectStore objectStore;
759
760 @DomName('IDBIndex.unique')
761 @DocsEditable()
762 final bool unique;
763
764 @JSName('count')
765 @DomName('IDBIndex.count')
766 @DocsEditable()
767 Request _count(Object key) native;
768
769 @JSName('get')
770 @DomName('IDBIndex.get')
771 @DocsEditable()
772 @Returns('Request')
773 @Creates('Request')
774 @annotation_Creates_SerializedScriptValue
775 Request _get(Object key) native;
776
777 @JSName('getKey')
778 @DomName('IDBIndex.getKey')
779 @DocsEditable()
780 @Returns('Request')
781 @Creates('Request')
782 @annotation_Creates_SerializedScriptValue
783 @Creates('ObjectStore')
784 Request _getKey(Object key) native;
785
786 @JSName('openCursor')
787 @DomName('IDBIndex.openCursor')
788 @DocsEditable()
789 @Returns('Request')
790 @Creates('Request')
791 @Creates('Cursor')
792 Request _openCursor(Object range, [String direction]) native;
793
794 @JSName('openKeyCursor')
795 @DomName('IDBIndex.openKeyCursor')
796 @DocsEditable()
797 @Returns('Request')
798 @Creates('Request')
799 @Creates('Cursor')
800 Request _openKeyCursor(Object range, [String direction]) native;
801
802 }
803 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
804 // for details. All rights reserved. Use of this source code is governed by a
805 // BSD-style license that can be found in the LICENSE file.
806
807
808 @DomName('IDBKeyRange')
809 @Unstable()
810 @Native("IDBKeyRange")
811 class KeyRange extends Interceptor {
812 @DomName('IDBKeyRange.only')
813 factory KeyRange.only(/*Key*/ value) =>
814 _KeyRangeFactoryProvider.createKeyRange_only(value);
815
816 @DomName('IDBKeyRange.lowerBound')
817 factory KeyRange.lowerBound(/*Key*/ bound, [bool open = false]) =>
818 _KeyRangeFactoryProvider.createKeyRange_lowerBound(bound, open);
819
820 @DomName('IDBKeyRange.upperBound')
821 factory KeyRange.upperBound(/*Key*/ bound, [bool open = false]) =>
822 _KeyRangeFactoryProvider.createKeyRange_upperBound(bound, open);
823
824 @DomName('KeyRange.bound')
825 factory KeyRange.bound(/*Key*/ lower, /*Key*/ upper,
826 [bool lowerOpen = false, bool upperOpen = false]) =>
827 _KeyRangeFactoryProvider.createKeyRange_bound(
828 lower, upper, lowerOpen, upperOpen);
829
830 // To suppress missing implicit constructor warnings.
831 factory KeyRange._() { throw new UnsupportedError("Not supported"); }
832
833 @DomName('IDBKeyRange.lower')
834 @DocsEditable()
835 @annotation_Creates_SerializedScriptValue
836 final Object lower;
837
838 @DomName('IDBKeyRange.lowerOpen')
839 @DocsEditable()
840 final bool lowerOpen;
841
842 @DomName('IDBKeyRange.upper')
843 @DocsEditable()
844 @annotation_Creates_SerializedScriptValue
845 final Object upper;
846
847 @DomName('IDBKeyRange.upperOpen')
848 @DocsEditable()
849 final bool upperOpen;
850
851 @JSName('bound')
852 @DomName('IDBKeyRange.bound')
853 @DocsEditable()
854 static KeyRange bound_(Object lower, Object upper, [bool lowerOpen, bool upper Open]) native;
855
856 @JSName('lowerBound')
857 @DomName('IDBKeyRange.lowerBound')
858 @DocsEditable()
859 static KeyRange lowerBound_(Object bound, [bool open]) native;
860
861 @JSName('only')
862 @DomName('IDBKeyRange.only')
863 @DocsEditable()
864 static KeyRange only_(Object value) native;
865
866 @JSName('upperBound')
867 @DomName('IDBKeyRange.upperBound')
868 @DocsEditable()
869 static KeyRange upperBound_(Object bound, [bool open]) native;
870
871 }
872 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
873 // for details. All rights reserved. Use of this source code is governed by a
874 // BSD-style license that can be found in the LICENSE file.
875
876
877 @DomName('IDBObjectStore')
878 @Unstable()
879 @Native("IDBObjectStore")
880 class ObjectStore extends Interceptor {
881
882 @DomName('IDBObjectStore.add')
883 Future add(value, [key]) {
884 try {
885 var request;
886 if (key != null) {
887 request = _add(value, key);
888 } else {
889 request = _add(value);
890 }
891 return _completeRequest(request);
892 } catch (e, stacktrace) {
893 return new Future.error(e, stacktrace);
894 }
895 }
896
897 @DomName('IDBObjectStore.clear')
898 Future clear() {
899 try {
900 return _completeRequest(_clear());
901 } catch (e, stacktrace) {
902 return new Future.error(e, stacktrace);
903 }
904 }
905
906 @DomName('IDBObjectStore.delete')
907 Future delete(key_OR_keyRange){
908 try {
909 return _completeRequest(_delete(key_OR_keyRange));
910 } catch (e, stacktrace) {
911 return new Future.error(e, stacktrace);
912 }
913 }
914
915 @DomName('IDBObjectStore.count')
916 Future<int> count([key_OR_range]) {
917 try {
918 var request = _count(key_OR_range);
919 return _completeRequest(request);
920 } catch (e, stacktrace) {
921 return new Future.error(e, stacktrace);
922 }
923 }
924
925 @DomName('IDBObjectStore.put')
926 Future put(value, [key]) {
927 try {
928 var request;
929 if (key != null) {
930 request = _put(value, key);
931 } else {
932 request = _put(value);
933 }
934 return _completeRequest(request);
935 } catch (e, stacktrace) {
936 return new Future.error(e, stacktrace);
937 }
938 }
939
940 @DomName('IDBObjectStore.get')
941 Future getObject(key) {
942 try {
943 var request = _get(key);
944
945 return _completeRequest(request);
946 } catch (e, stacktrace) {
947 return new Future.error(e, stacktrace);
948 }
949 }
950
951 /**
952 * Creates a stream of cursors over the records in this object store.
953 *
954 * **The stream must be manually advanced by calling [Cursor.next] after
955 * each item or by specifying autoAdvance to be true.**
956 *
957 * var cursors = objectStore.openCursor().listen(
958 * (cursor) {
959 * // ...some processing with the cursor
960 * cursor.next(); // advance onto the next cursor.
961 * },
962 * onDone: () {
963 * // called when there are no more cursors.
964 * print('all done!');
965 * });
966 *
967 * Asynchronous operations which are not related to the current transaction
968 * will cause the transaction to automatically be committed-- all processing
969 * must be done synchronously unless they are additional async requests to
970 * the current transaction.
971 */
972 @DomName('IDBObjectStore.openCursor')
973 Stream<CursorWithValue> openCursor({key, KeyRange range, String direction,
974 bool autoAdvance}) {
975 var key_OR_range = null;
976 if (key != null) {
977 if (range != null) {
978 throw new ArgumentError('Cannot specify both key and range.');
979 }
980 key_OR_range = key;
981 } else {
982 key_OR_range = range;
983 }
984
985 // TODO: try/catch this and return a stream with an immediate error.
986 var request;
987 if (direction == null) {
988 request = _openCursor(key_OR_range);
989 } else {
990 request = _openCursor(key_OR_range, direction);
991 }
992 return _cursorStreamFromResult(request, autoAdvance);
993 }
994
995 @DomName('IDBObjectStore.createIndex')
996 Index createIndex(String name, keyPath, {bool unique, bool multiEntry}) {
997 var options = {};
998 if (unique != null) {
999 options['unique'] = unique;
1000 }
1001 if (multiEntry != null) {
1002 options['multiEntry'] = multiEntry;
1003 }
1004
1005 return _createIndex(name, keyPath, options);
1006 }
1007
1008 // To suppress missing implicit constructor warnings.
1009 factory ObjectStore._() { throw new UnsupportedError("Not supported"); }
1010
1011 @DomName('IDBObjectStore.autoIncrement')
1012 @DocsEditable()
1013 final bool autoIncrement;
1014
1015 @DomName('IDBObjectStore.indexNames')
1016 @DocsEditable()
1017 @Returns('DomStringList')
1018 @Creates('DomStringList')
1019 final List<String> indexNames;
1020
1021 @DomName('IDBObjectStore.keyPath')
1022 @DocsEditable()
1023 @annotation_Creates_SerializedScriptValue
1024 final Object keyPath;
1025
1026 @DomName('IDBObjectStore.name')
1027 @DocsEditable()
1028 final String name;
1029
1030 @DomName('IDBObjectStore.transaction')
1031 @DocsEditable()
1032 final Transaction transaction;
1033
1034 @DomName('IDBObjectStore.add')
1035 @DocsEditable()
1036 @Returns('Request')
1037 @Creates('Request')
1038 @_annotation_Creates_IDBKey
1039 Request _add(/*any*/ value, [/*any*/ key]) {
1040 if (key != null) {
1041 var value_1 = convertDartToNative_SerializedScriptValue(value);
1042 var key_2 = convertDartToNative_SerializedScriptValue(key);
1043 return _add_1(value_1, key_2);
1044 }
1045 var value_1 = convertDartToNative_SerializedScriptValue(value);
1046 return _add_2(value_1);
1047 }
1048 @JSName('add')
1049 @DomName('IDBObjectStore.add')
1050 @DocsEditable()
1051 @Returns('Request')
1052 @Creates('Request')
1053 @_annotation_Creates_IDBKey
1054 Request _add_1(value, key) native;
1055 @JSName('add')
1056 @DomName('IDBObjectStore.add')
1057 @DocsEditable()
1058 @Returns('Request')
1059 @Creates('Request')
1060 @_annotation_Creates_IDBKey
1061 Request _add_2(value) native;
1062
1063 @JSName('clear')
1064 @DomName('IDBObjectStore.clear')
1065 @DocsEditable()
1066 Request _clear() native;
1067
1068 @JSName('count')
1069 @DomName('IDBObjectStore.count')
1070 @DocsEditable()
1071 Request _count(Object key) native;
1072
1073 @DomName('IDBObjectStore.createIndex')
1074 @DocsEditable()
1075 Index _createIndex(String name, keyPath, [Map options]) {
1076 if ((keyPath is String || keyPath == null) && options == null) {
1077 return _createIndex_1(name, keyPath);
1078 }
1079 if (options != null && (keyPath is String || keyPath == null)) {
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 }
1094 @JSName('createIndex')
1095 @DomName('IDBObjectStore.createIndex')
1096 @DocsEditable()
1097 Index _createIndex_1(name, String keyPath) native;
1098 @JSName('createIndex')
1099 @DomName('IDBObjectStore.createIndex')
1100 @DocsEditable()
1101 Index _createIndex_2(name, String keyPath, options) 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
1111 @JSName('delete')
1112 @DomName('IDBObjectStore.delete')
1113 @DocsEditable()
1114 Request _delete(Object key) native;
1115
1116 @DomName('IDBObjectStore.deleteIndex')
1117 @DocsEditable()
1118 void deleteIndex(String name) native;
1119
1120 @JSName('get')
1121 @DomName('IDBObjectStore.get')
1122 @DocsEditable()
1123 @Returns('Request')
1124 @Creates('Request')
1125 @annotation_Creates_SerializedScriptValue
1126 Request _get(Object key) native;
1127
1128 @DomName('IDBObjectStore.index')
1129 @DocsEditable()
1130 Index index(String name) native;
1131
1132 @JSName('openCursor')
1133 @DomName('IDBObjectStore.openCursor')
1134 @DocsEditable()
1135 @Returns('Request')
1136 @Creates('Request')
1137 @Creates('Cursor')
1138 Request _openCursor(Object range, [String direction]) native;
1139
1140 @DomName('IDBObjectStore.openKeyCursor')
1141 @DocsEditable()
1142 @Experimental() // untriaged
1143 Request openKeyCursor(Object range, [String direction]) native;
1144
1145 @DomName('IDBObjectStore.put')
1146 @DocsEditable()
1147 @Returns('Request')
1148 @Creates('Request')
1149 @_annotation_Creates_IDBKey
1150 Request _put(/*any*/ value, [/*any*/ key]) {
1151 if (key != null) {
1152 var value_1 = convertDartToNative_SerializedScriptValue(value);
1153 var key_2 = convertDartToNative_SerializedScriptValue(key);
1154 return _put_1(value_1, key_2);
1155 }
1156 var value_1 = convertDartToNative_SerializedScriptValue(value);
1157 return _put_2(value_1);
1158 }
1159 @JSName('put')
1160 @DomName('IDBObjectStore.put')
1161 @DocsEditable()
1162 @Returns('Request')
1163 @Creates('Request')
1164 @_annotation_Creates_IDBKey
1165 Request _put_1(value, key) native;
1166 @JSName('put')
1167 @DomName('IDBObjectStore.put')
1168 @DocsEditable()
1169 @Returns('Request')
1170 @Creates('Request')
1171 @_annotation_Creates_IDBKey
1172 Request _put_2(value) native;
1173
1174
1175 /**
1176 * Helper for iterating over cursors in a request.
1177 */
1178 static Stream<Cursor> _cursorStreamFromResult(Request request,
1179 bool autoAdvance) {
1180 // TODO: need to guarantee that the controller provides the values
1181 // immediately as waiting until the next tick will cause the transaction to
1182 // close.
1183 var controller = new StreamController(sync: true);
1184
1185 //TODO: Report stacktrace once issue 4061 is resolved.
1186 request.onError.listen(controller.addError);
1187
1188 request.onSuccess.listen((e) {
1189 Cursor cursor = request.result;
1190 if (cursor == null) {
1191 controller.close();
1192 } else {
1193 controller.add(cursor);
1194 if (autoAdvance == true && controller.hasListener) {
1195 cursor.next();
1196 }
1197 }
1198 });
1199 return controller.stream;
1200 }
1201 }
1202 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
1203 // for details. All rights reserved. Use of this source code is governed by a
1204 // BSD-style license that can be found in the LICENSE file.
1205
1206
1207 @DocsEditable()
1208 @DomName('IDBOpenDBRequest')
1209 @Unstable()
1210 @Native("IDBOpenDBRequest,IDBVersionChangeRequest")
1211 class OpenDBRequest extends Request {
1212 // To suppress missing implicit constructor warnings.
1213 factory OpenDBRequest._() { throw new UnsupportedError("Not supported"); }
1214
1215 /**
1216 * Static factory designed to expose `blocked` events to event
1217 * handlers that are not necessarily instances of [OpenDBRequest].
1218 *
1219 * See [EventStreamProvider] for usage information.
1220 */
1221 @DomName('IDBOpenDBRequest.blockedEvent')
1222 @DocsEditable()
1223 static const EventStreamProvider<Event> blockedEvent = const EventStreamProvid er<Event>('blocked');
1224
1225 /**
1226 * Static factory designed to expose `upgradeneeded` events to event
1227 * handlers that are not necessarily instances of [OpenDBRequest].
1228 *
1229 * See [EventStreamProvider] for usage information.
1230 */
1231 @DomName('IDBOpenDBRequest.upgradeneededEvent')
1232 @DocsEditable()
1233 static const EventStreamProvider<VersionChangeEvent> upgradeNeededEvent = cons t EventStreamProvider<VersionChangeEvent>('upgradeneeded');
1234
1235 /// Stream of `blocked` events handled by this [OpenDBRequest].
1236 @DomName('IDBOpenDBRequest.onblocked')
1237 @DocsEditable()
1238 Stream<Event> get onBlocked => blockedEvent.forTarget(this);
1239
1240 /// Stream of `upgradeneeded` events handled by this [OpenDBRequest].
1241 @DomName('IDBOpenDBRequest.onupgradeneeded')
1242 @DocsEditable()
1243 Stream<VersionChangeEvent> get onUpgradeNeeded => upgradeNeededEvent.forTarget (this);
1244 }
1245 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
1246 // for details. All rights reserved. Use of this source code is governed by a
1247 // BSD-style license that can be found in the LICENSE file.
1248
1249
1250 @DocsEditable()
1251 @DomName('IDBRequest')
1252 @Unstable()
1253 @Native("IDBRequest")
1254 class Request extends EventTarget {
1255 // To suppress missing implicit constructor warnings.
1256 factory Request._() { throw new UnsupportedError("Not supported"); }
1257
1258 /**
1259 * Static factory designed to expose `error` events to event
1260 * handlers that are not necessarily instances of [Request].
1261 *
1262 * See [EventStreamProvider] for usage information.
1263 */
1264 @DomName('IDBRequest.errorEvent')
1265 @DocsEditable()
1266 static const EventStreamProvider<Event> errorEvent = const EventStreamProvider <Event>('error');
1267
1268 /**
1269 * Static factory designed to expose `success` events to event
1270 * handlers that are not necessarily instances of [Request].
1271 *
1272 * See [EventStreamProvider] for usage information.
1273 */
1274 @DomName('IDBRequest.successEvent')
1275 @DocsEditable()
1276 static const EventStreamProvider<Event> successEvent = const EventStreamProvid er<Event>('success');
1277
1278 @DomName('IDBRequest.error')
1279 @DocsEditable()
1280 final DomError error;
1281
1282 @DomName('IDBRequest.readyState')
1283 @DocsEditable()
1284 final String readyState;
1285
1286 @DomName('IDBRequest.result')
1287 @DocsEditable()
1288 dynamic get result => _convertNativeToDart_IDBAny(this._get_result);
1289 @JSName('result')
1290 @DomName('IDBRequest.result')
1291 @DocsEditable()
1292 @Creates('Null')
1293 final dynamic _get_result;
1294
1295 @DomName('IDBRequest.source')
1296 @DocsEditable()
1297 @Creates('Null')
1298 final Object source;
1299
1300 @DomName('IDBRequest.transaction')
1301 @DocsEditable()
1302 final Transaction transaction;
1303
1304 /// Stream of `error` events handled by this [Request].
1305 @DomName('IDBRequest.onerror')
1306 @DocsEditable()
1307 Stream<Event> get onError => errorEvent.forTarget(this);
1308
1309 /// Stream of `success` events handled by this [Request].
1310 @DomName('IDBRequest.onsuccess')
1311 @DocsEditable()
1312 Stream<Event> get onSuccess => successEvent.forTarget(this);
1313 }
1314 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
1315 // for details. All rights reserved. Use of this source code is governed by a
1316 // BSD-style license that can be found in the LICENSE file.
1317
1318
1319 @DomName('IDBTransaction')
1320 @Unstable()
1321 @Native("IDBTransaction")
1322 class Transaction extends EventTarget {
1323
1324 /**
1325 * Provides a Future which will be completed once the transaction has
1326 * completed.
1327 *
1328 * The future will error if an error occurrs on the transaction or if the
1329 * transaction is aborted.
1330 */
1331 Future<Database> get completed {
1332 var completer = new Completer<Database>();
1333
1334 this.onComplete.first.then((_) {
1335 completer.complete(db);
1336 });
1337
1338 this.onError.first.then((e) {
1339 completer.completeError(e);
1340 });
1341
1342 this.onAbort.first.then((e) {
1343 // Avoid completing twice if an error occurs.
1344 if (!completer.isCompleted) {
1345 completer.completeError(e);
1346 }
1347 });
1348
1349 return completer.future;
1350 }
1351
1352 // To suppress missing implicit constructor warnings.
1353 factory Transaction._() { throw new UnsupportedError("Not supported"); }
1354
1355 /**
1356 * Static factory designed to expose `abort` events to event
1357 * handlers that are not necessarily instances of [Transaction].
1358 *
1359 * See [EventStreamProvider] for usage information.
1360 */
1361 @DomName('IDBTransaction.abortEvent')
1362 @DocsEditable()
1363 static const EventStreamProvider<Event> abortEvent = const EventStreamProvider <Event>('abort');
1364
1365 /**
1366 * Static factory designed to expose `complete` events to event
1367 * handlers that are not necessarily instances of [Transaction].
1368 *
1369 * See [EventStreamProvider] for usage information.
1370 */
1371 @DomName('IDBTransaction.completeEvent')
1372 @DocsEditable()
1373 static const EventStreamProvider<Event> completeEvent = const EventStreamProvi der<Event>('complete');
1374
1375 /**
1376 * Static factory designed to expose `error` events to event
1377 * handlers that are not necessarily instances of [Transaction].
1378 *
1379 * See [EventStreamProvider] for usage information.
1380 */
1381 @DomName('IDBTransaction.errorEvent')
1382 @DocsEditable()
1383 static const EventStreamProvider<Event> errorEvent = const EventStreamProvider <Event>('error');
1384
1385 @DomName('IDBTransaction.db')
1386 @DocsEditable()
1387 final Database db;
1388
1389 @DomName('IDBTransaction.error')
1390 @DocsEditable()
1391 final DomError error;
1392
1393 @DomName('IDBTransaction.mode')
1394 @DocsEditable()
1395 final String mode;
1396
1397 @DomName('IDBTransaction.abort')
1398 @DocsEditable()
1399 void abort() native;
1400
1401 @DomName('IDBTransaction.objectStore')
1402 @DocsEditable()
1403 ObjectStore objectStore(String name) native;
1404
1405 /// Stream of `abort` events handled by this [Transaction].
1406 @DomName('IDBTransaction.onabort')
1407 @DocsEditable()
1408 Stream<Event> get onAbort => abortEvent.forTarget(this);
1409
1410 /// Stream of `complete` events handled by this [Transaction].
1411 @DomName('IDBTransaction.oncomplete')
1412 @DocsEditable()
1413 Stream<Event> get onComplete => completeEvent.forTarget(this);
1414
1415 /// Stream of `error` events handled by this [Transaction].
1416 @DomName('IDBTransaction.onerror')
1417 @DocsEditable()
1418 Stream<Event> get onError => errorEvent.forTarget(this);
1419
1420 }
1421 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
1422 // for details. All rights reserved. Use of this source code is governed by a
1423 // BSD-style license that can be found in the LICENSE file.
1424
1425
1426 @DocsEditable()
1427 @DomName('IDBVersionChangeEvent')
1428 @Unstable()
1429 @Native("IDBVersionChangeEvent")
1430 class VersionChangeEvent extends Event {
1431 // To suppress missing implicit constructor warnings.
1432 factory VersionChangeEvent._() { throw new UnsupportedError("Not supported"); }
1433
1434 @DomName('IDBVersionChangeEvent.dataLoss')
1435 @DocsEditable()
1436 @Experimental() // untriaged
1437 final String dataLoss;
1438
1439 @DomName('IDBVersionChangeEvent.dataLossMessage')
1440 @DocsEditable()
1441 @Experimental() // untriaged
1442 final String dataLossMessage;
1443
1444 @DomName('IDBVersionChangeEvent.newVersion')
1445 @DocsEditable()
1446 @Creates('int|String|Null')
1447 @Returns('int|String|Null')
1448 final int newVersion;
1449
1450 @DomName('IDBVersionChangeEvent.oldVersion')
1451 @DocsEditable()
1452 @Creates('int|String|Null')
1453 @Returns('int|String|Null')
1454 final int oldVersion;
1455 }
OLDNEW
« no previous file with comments | « tool/input_sdk/lib/html/html_common/html_common_ddc.dart ('k') | tool/input_sdk/lib/indexed_db/ddc/indexed_db_ddc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698