Chromium Code Reviews| 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 support IndexedDB—a web standard for | |
| 13 * an indexed database. | |
| 14 * By storing data on the client in an IndexedDB, | |
| 15 * a web app gets some advantages, such as faster performance and persistence. | |
| 16 * To find out which browsers support IndexedDB, | |
| 17 * refer to [Can I Use?](http://caniuse.com/#feat=indexeddb) | |
| 18 * | |
| 19 * In IndexedDB, each record is identified by a unique index or key, | |
| 20 * making data retrieval speedy. | |
| 21 * You can store structured data, | |
| 22 * such as images, arrays, and maps using IndexedDB. | |
| 23 * The standard does not specify size limits for individual data items | |
| 24 * or for the database itself, but browsers may impose storage limits. | |
| 25 * | |
| 26 * ## Using indexed_db | |
| 27 * | |
| 28 * The classes in this library provide an interface | |
| 29 * to the browser's IndexedDB, if it has one. | |
| 30 * To use this library in your code: | |
| 31 * | |
| 32 * import 'dart:indexed_db'; | |
| 33 * | |
| 34 * A web app can determine if the browser supports | |
| 35 * IndexedDB with [IdbFactory.supported]: | |
| 36 * | |
| 37 * if (IdbFactory.supported) | |
| 38 * // Use indexeddb. | |
| 39 * else | |
| 40 * // Find an alternative. | |
| 41 * | |
| 42 * Access to the browser's IndexedDB is provided by the app's top-level | |
| 43 * [Window] object, which your code can refer to with `window.indexedDB`. | |
| 44 * So, for example, | |
| 45 * to open an indexed database, you would write something like this: | |
|
sethladd
2013/08/29 11:26:34
"write something like this" is wishy-washy. How ab
mem
2013/09/03 17:41:06
Done.
| |
| 46 * | |
| 47 * Future open() { | |
| 48 * return window.indexedDB.open('myIndexedDB', | |
| 49 * version: 1, | |
| 50 * onUpgradeNeeded: /* Initalize the database. */ ) | |
|
sethladd
2013/08/29 11:26:34
this isn't valid Dart code. Can you fix so that so
mem
2013/09/03 17:41:06
Done.
| |
| 51 * .then( /* Load data from the database. */ ); | |
| 52 * } | |
| 53 * | |
| 54 * All data in an IndexedDB is stored within an [ObjectStore]. | |
| 55 * To manipulate the database use [Transaction]s. | |
| 56 * | |
| 57 * ## Other resources | |
| 58 * | |
| 59 * Other options for client-side data storage include: | |
| 60 * | |
| 61 * * [Window.localStorage]—a | |
| 62 * basic mechanism in which data is stored as a [Map]. | |
| 63 * | |
| 64 * * [dart:web_sql]—a database that can be queried with SQL. | |
| 65 * | |
| 66 * * The [Lawndart](http://pub.dartlang.org/packages/lawndart) package, | |
| 67 * which helps you deal with the wide array of client-side storage options. | |
| 68 * | |
| 69 * For a tutorial about using the indexed_db library with Dart, | |
| 70 * check out | |
| 71 * [Use IndexedDB](http://www.dartlang.org/docs/tutorials/indexeddb/). | |
| 72 * | |
| 73 * [IndexedDB reference](http://docs.webplatform.org/wiki/apis/indexeddb) | |
| 74 * provides wiki-style docs about indexedDB | |
| 75 */ | |
| 9 library dart.dom.indexed_db; | 76 library dart.dom.indexed_db; |
| 10 | 77 |
| 11 import 'dart:async'; | 78 import 'dart:async'; |
| 12 import 'dart:html'; | 79 import 'dart:html'; |
| 13 import 'dart:html_common'; | 80 import 'dart:html_common'; |
| 14 import 'dart:typed_data'; | 81 import 'dart:typed_data'; |
| 15 import 'dart:_js_helper' show Creates, Returns, JSName, Null; | 82 import 'dart:_js_helper' show Creates, Returns, JSName, Null; |
| 16 import 'dart:_foreign_helper' show JS; | 83 import 'dart:_foreign_helper' show JS; |
| 17 import 'dart:_interceptors' show Interceptor, JSExtendableArray; | 84 import 'dart:_interceptors' show Interceptor, JSExtendableArray; |
| 18 | 85 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 | 192 |
| 126 /// May modify original. If so, action is idempotent. | 193 /// May modify original. If so, action is idempotent. |
| 127 _convertNativeToDart_IDBAny(object) { | 194 _convertNativeToDart_IDBAny(object) { |
| 128 return convertNativeToDart_AcceptStructuredClone(object, mustCopy: false); | 195 return convertNativeToDart_AcceptStructuredClone(object, mustCopy: false); |
| 129 } | 196 } |
| 130 | 197 |
| 131 // TODO(sra): Add DateTime. | 198 // TODO(sra): Add DateTime. |
| 132 const String _idbKey = 'JSExtendableArray|=Object|num|String'; | 199 const String _idbKey = 'JSExtendableArray|=Object|num|String'; |
| 133 const _annotation_Creates_IDBKey = const Creates(_idbKey); | 200 const _annotation_Creates_IDBKey = const Creates(_idbKey); |
| 134 const _annotation_Returns_IDBKey = const Returns(_idbKey); | 201 const _annotation_Returns_IDBKey = const Returns(_idbKey); |
| OLD | NEW |