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

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

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

Powered by Google App Engine
This is Rietveld 408576698