| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // DO NOT EDIT - unless you are editing documentation as per: | 5 // DO NOT EDIT - unless you are editing documentation as per: |
| 6 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation | 6 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation |
| 7 // Auto-generated dart:svg library. | 7 // Auto-generated dart:svg library. |
| 8 | 8 |
| 9 /** |
| 10 * A client-side key-value store with support for indexes. |
| 11 * |
| 12 * Many browsers provide an indexed database, |
| 13 * which web apps can use to store data in the client. |
| 14 * Client-side storage provides apps with |
| 15 * off-line functionality, better performance, |
| 16 * and the ability to cache the app's state between invocations. |
| 17 * To find out which browsers support indexed database, |
| 18 * refer to [Can I Use?](http://caniuse.com/#feat=indexeddb) |
| 19 * |
| 20 * In an indexed database each record is identified by a unique index or key, |
| 21 * making data retrieval speedy. |
| 22 * You can store large amounts of structured data, |
| 23 * such as images, arrays, maps, and objects using IndexedDB. |
| 24 * The standard does not specify size limits for individual data items |
| 25 * or for the database itself, but browsers may impose storage limits. |
| 26 * |
| 27 * The classes in this library provide an interface |
| 28 * to the browser's indexed database, if it has one. |
| 29 * To use this library in your code: |
| 30 * |
| 31 * import 'dart:indexed_db'; |
| 32 * |
| 33 * A web app can determine if the browser has an |
| 34 * indexed database with [IdbFactory.supported]: |
| 35 * |
| 36 * if (IdbFactory.supported) |
| 37 * // Use indexeddb. |
| 38 * else |
| 39 * // Find an alternative. |
| 40 * |
| 41 * Open an indexed database using the `indexedDB` object |
| 42 * provided by the top-level [Window] object for the app. |
| 43 * For example: |
| 44 * |
| 45 * Future open() { |
| 46 * return window.indexedDB.open('myIndexedDB', |
| 47 * version: 1, |
| 48 * onUpgradeNeeded: /* Initalize the database. */ ) |
| 49 * .then( /* Load data from the database. */ ); |
| 50 * } |
| 51 * |
| 52 * ## Other resources |
| 53 * |
| 54 * Other client-side data stores include: |
| 55 * |
| 56 * * [Window.localStorage]—a |
| 57 * basic mechanism in which data is stored as a [Map]. |
| 58 * |
| 59 * * [dart:web_sql]—a database that can be queried with SQL. |
| 60 * |
| 61 * For a tutorial about using the indexed_db library, |
| 62 * check out |
| 63 * [Use IndexedDB](https://www.dartlang.org/docs/tutorials/indexeddb/). |
| 64 */ |
| 9 library dart.dom.indexed_db; | 65 library dart.dom.indexed_db; |
| 10 | 66 |
| 11 import 'dart:async'; | 67 import 'dart:async'; |
| 12 import 'dart:html'; | 68 import 'dart:html'; |
| 13 import 'dart:html_common'; | 69 import 'dart:html_common'; |
| 14 import 'dart:typed_data'; | 70 import 'dart:typed_data'; |
| 15 import 'dart:_js_helper' show Creates, Returns, JSName, Null; | 71 import 'dart:_js_helper' show Creates, Returns, JSName, Null; |
| 16 import 'dart:_foreign_helper' show JS; | 72 import 'dart:_foreign_helper' show JS; |
| 17 import 'dart:_interceptors' show Interceptor, JSExtendableArray; | 73 import 'dart:_interceptors' show Interceptor, JSExtendableArray; |
| 18 | 74 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 181 |
| 126 /// May modify original. If so, action is idempotent. | 182 /// May modify original. If so, action is idempotent. |
| 127 _convertNativeToDart_IDBAny(object) { | 183 _convertNativeToDart_IDBAny(object) { |
| 128 return convertNativeToDart_AcceptStructuredClone(object, mustCopy: false); | 184 return convertNativeToDart_AcceptStructuredClone(object, mustCopy: false); |
| 129 } | 185 } |
| 130 | 186 |
| 131 // TODO(sra): Add DateTime. | 187 // TODO(sra): Add DateTime. |
| 132 const String _idbKey = 'JSExtendableArray|=Object|num|String'; | 188 const String _idbKey = 'JSExtendableArray|=Object|num|String'; |
| 133 const _annotation_Creates_IDBKey = const Creates(_idbKey); | 189 const _annotation_Creates_IDBKey = const Creates(_idbKey); |
| 134 const _annotation_Returns_IDBKey = const Returns(_idbKey); | 190 const _annotation_Returns_IDBKey = const Returns(_idbKey); |
| OLD | NEW |