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

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

Issue 410863002: Redo "Use @Native annotation on dart2js DOM native classes" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | sdk/lib/svg/dart2js/svg_dart2js.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * A client-side key-value store with support for indexes. 2 * A client-side key-value store with support for indexes.
3 * 3 *
4 * Many browsers support IndexedDB—a web standard for 4 * Many browsers support IndexedDB—a web standard for
5 * an indexed database. 5 * an indexed database.
6 * By storing data on the client in an IndexedDB, 6 * By storing data on the client in an IndexedDB,
7 * a web app gets some advantages, such as faster performance and persistence. 7 * a web app gets some advantages, such as faster performance and persistence.
8 * To find out which browsers support IndexedDB, 8 * To find out which browsers support IndexedDB,
9 * refer to [Can I Use?](http://caniuse.com/#feat=indexeddb) 9 * refer to [Can I Use?](http://caniuse.com/#feat=indexeddb)
10 * 10 *
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 * [IndexedDB reference](http://docs.webplatform.org/wiki/apis/indexeddb) 70 * [IndexedDB reference](http://docs.webplatform.org/wiki/apis/indexeddb)
71 * provides wiki-style docs about indexedDB 71 * provides wiki-style docs about indexedDB
72 */ 72 */
73 library dart.dom.indexed_db; 73 library dart.dom.indexed_db;
74 74
75 import 'dart:async'; 75 import 'dart:async';
76 import 'dart:html'; 76 import 'dart:html';
77 import 'dart:html_common'; 77 import 'dart:html_common';
78 import 'dart:_native_typed_data'; 78 import 'dart:_native_typed_data';
79 import 'dart:typed_data'; 79 import 'dart:typed_data';
80 import 'dart:_js_helper' show Creates, Returns, JSName, Null; 80 import 'dart:_js_helper' show Creates, Returns, JSName, Native, Null;
81 import 'dart:_foreign_helper' show JS; 81 import 'dart:_foreign_helper' show JS;
82 import 'dart:_interceptors' show Interceptor, JSExtendableArray; 82 import 'dart:_interceptors' show Interceptor, JSExtendableArray;
83 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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. 85 // BSD-style license that can be found in the LICENSE file.
86 86
87 // DO NOT EDIT - unless you are editing documentation as per: 87 // DO NOT EDIT - unless you are editing documentation as per:
88 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation 88 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation
89 // Auto-generated dart:svg library. 89 // Auto-generated dart:svg library.
90 90
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 const String _idbKey = 'JSExtendableArray|=Object|num|String'; 206 const String _idbKey = 'JSExtendableArray|=Object|num|String';
207 const _annotation_Creates_IDBKey = const Creates(_idbKey); 207 const _annotation_Creates_IDBKey = const Creates(_idbKey);
208 const _annotation_Returns_IDBKey = const Returns(_idbKey); 208 const _annotation_Returns_IDBKey = const Returns(_idbKey);
209 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 211 // BSD-style license that can be found in the LICENSE file.
212 212
213 213
214 @DomName('IDBCursor') 214 @DomName('IDBCursor')
215 @Unstable() 215 @Unstable()
216 class Cursor extends Interceptor native "IDBCursor" { 216 @Native("IDBCursor")
217 class Cursor extends Interceptor {
217 @DomName('IDBCursor.delete') 218 @DomName('IDBCursor.delete')
218 Future delete() { 219 Future delete() {
219 try { 220 try {
220 return _completeRequest(_delete()); 221 return _completeRequest(_delete());
221 } catch (e, stacktrace) { 222 } catch (e, stacktrace) {
222 return new Future.error(e, stacktrace); 223 return new Future.error(e, stacktrace);
223 } 224 }
224 } 225 }
225 226
226 @DomName('IDBCursor.value') 227 @DomName('IDBCursor.value')
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 294
294 } 295 }
295 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 296 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
296 // for details. All rights reserved. Use of this source code is governed by a 297 // for details. All rights reserved. Use of this source code is governed by a
297 // BSD-style license that can be found in the LICENSE file. 298 // BSD-style license that can be found in the LICENSE file.
298 299
299 300
300 @DocsEditable() 301 @DocsEditable()
301 @DomName('IDBCursorWithValue') 302 @DomName('IDBCursorWithValue')
302 @Unstable() 303 @Unstable()
303 class CursorWithValue extends Cursor native "IDBCursorWithValue" { 304 @Native("IDBCursorWithValue")
305 class CursorWithValue extends Cursor {
304 // To suppress missing implicit constructor warnings. 306 // To suppress missing implicit constructor warnings.
305 factory CursorWithValue._() { throw new UnsupportedError("Not supported"); } 307 factory CursorWithValue._() { throw new UnsupportedError("Not supported"); }
306 308
307 @DomName('IDBCursorWithValue.value') 309 @DomName('IDBCursorWithValue.value')
308 @DocsEditable() 310 @DocsEditable()
309 dynamic get value => _convertNativeToDart_IDBAny(this._get_value); 311 dynamic get value => _convertNativeToDart_IDBAny(this._get_value);
310 @JSName('value') 312 @JSName('value')
311 @DomName('IDBCursorWithValue.value') 313 @DomName('IDBCursorWithValue.value')
312 @DocsEditable() 314 @DocsEditable()
313 @annotation_Creates_SerializedScriptValue 315 @annotation_Creates_SerializedScriptValue
314 @annotation_Returns_SerializedScriptValue 316 @annotation_Returns_SerializedScriptValue
315 final dynamic _get_value; 317 final dynamic _get_value;
316 } 318 }
317 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 319 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
318 // for details. All rights reserved. Use of this source code is governed by a 320 // for details. All rights reserved. Use of this source code is governed by a
319 // BSD-style license that can be found in the LICENSE file. 321 // BSD-style license that can be found in the LICENSE file.
320 322
321 323
322 @DocsEditable() 324 @DocsEditable()
323 /** 325 /**
324 * An indexed database object for storing client-side data 326 * An indexed database object for storing client-side data
325 * in web apps. 327 * in web apps.
326 */ 328 */
327 @DomName('IDBDatabase') 329 @DomName('IDBDatabase')
328 @SupportedBrowser(SupportedBrowser.CHROME) 330 @SupportedBrowser(SupportedBrowser.CHROME)
329 @SupportedBrowser(SupportedBrowser.FIREFOX, '15') 331 @SupportedBrowser(SupportedBrowser.FIREFOX, '15')
330 @SupportedBrowser(SupportedBrowser.IE, '10') 332 @SupportedBrowser(SupportedBrowser.IE, '10')
331 @Experimental() 333 @Experimental()
332 @Unstable() 334 @Unstable()
333 class Database extends EventTarget native "IDBDatabase" { 335 @Native("IDBDatabase")
336 class Database extends EventTarget {
334 @DomName('IDBDatabase.createObjectStore') 337 @DomName('IDBDatabase.createObjectStore')
335 @DocsEditable() 338 @DocsEditable()
336 ObjectStore createObjectStore(String name, 339 ObjectStore createObjectStore(String name,
337 {String keyPath, bool autoIncrement}) { 340 {String keyPath, bool autoIncrement}) {
338 var options = {}; 341 var options = {};
339 if (keyPath != null) { 342 if (keyPath != null) {
340 options['keyPath'] = keyPath; 343 options['keyPath'] = keyPath;
341 } 344 }
342 if (autoIncrement != null) { 345 if (autoIncrement != null) {
343 options['autoIncrement'] = autoIncrement; 346 options['autoIncrement'] = autoIncrement;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 // for details. All rights reserved. Use of this source code is governed by a 504 // for details. All rights reserved. Use of this source code is governed by a
502 // BSD-style license that can be found in the LICENSE file. 505 // BSD-style license that can be found in the LICENSE file.
503 506
504 507
505 @DomName('IDBFactory') 508 @DomName('IDBFactory')
506 @SupportedBrowser(SupportedBrowser.CHROME) 509 @SupportedBrowser(SupportedBrowser.CHROME)
507 @SupportedBrowser(SupportedBrowser.FIREFOX, '15') 510 @SupportedBrowser(SupportedBrowser.FIREFOX, '15')
508 @SupportedBrowser(SupportedBrowser.IE, '10') 511 @SupportedBrowser(SupportedBrowser.IE, '10')
509 @Experimental() 512 @Experimental()
510 @Unstable() 513 @Unstable()
511 class IdbFactory extends Interceptor native "IDBFactory" { 514 @Native("IDBFactory")
515 class IdbFactory extends Interceptor {
512 /** 516 /**
513 * Checks to see if Indexed DB is supported on the current platform. 517 * Checks to see if Indexed DB is supported on the current platform.
514 */ 518 */
515 static bool get supported { 519 static bool get supported {
516 return JS('bool', 520 return JS('bool',
517 '!!(window.indexedDB || ' 521 '!!(window.indexedDB || '
518 'window.webkitIndexedDB || ' 522 'window.webkitIndexedDB || '
519 'window.mozIndexedDB)'); 523 'window.mozIndexedDB)');
520 } 524 }
521 525
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 request.onError.listen(completer.completeError); 640 request.onError.listen(completer.completeError);
637 return completer.future; 641 return completer.future;
638 } 642 }
639 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 643 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
640 // for details. All rights reserved. Use of this source code is governed by a 644 // for details. All rights reserved. Use of this source code is governed by a
641 // BSD-style license that can be found in the LICENSE file. 645 // BSD-style license that can be found in the LICENSE file.
642 646
643 647
644 @DomName('IDBIndex') 648 @DomName('IDBIndex')
645 @Unstable() 649 @Unstable()
646 class Index extends Interceptor native "IDBIndex" { 650 @Native("IDBIndex")
651 class Index extends Interceptor {
647 @DomName('IDBIndex.count') 652 @DomName('IDBIndex.count')
648 Future<int> count([key_OR_range]) { 653 Future<int> count([key_OR_range]) {
649 try { 654 try {
650 var request = _count(key_OR_range); 655 var request = _count(key_OR_range);
651 return _completeRequest(request); 656 return _completeRequest(request);
652 } catch (e, stacktrace) { 657 } catch (e, stacktrace) {
653 return new Future.error(e, stacktrace); 658 return new Future.error(e, stacktrace);
654 } 659 }
655 } 660 }
656 661
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 Request _openKeyCursor(Object key, [String direction]) native; 798 Request _openKeyCursor(Object key, [String direction]) native;
794 799
795 } 800 }
796 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 801 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
797 // for details. All rights reserved. Use of this source code is governed by a 802 // for details. All rights reserved. Use of this source code is governed by a
798 // BSD-style license that can be found in the LICENSE file. 803 // BSD-style license that can be found in the LICENSE file.
799 804
800 805
801 @DomName('IDBKeyRange') 806 @DomName('IDBKeyRange')
802 @Unstable() 807 @Unstable()
803 class KeyRange extends Interceptor native "IDBKeyRange" { 808 @Native("IDBKeyRange")
809 class KeyRange extends Interceptor {
804 @DomName('IDBKeyRange.only') 810 @DomName('IDBKeyRange.only')
805 factory KeyRange.only(/*Key*/ value) => 811 factory KeyRange.only(/*Key*/ value) =>
806 _KeyRangeFactoryProvider.createKeyRange_only(value); 812 _KeyRangeFactoryProvider.createKeyRange_only(value);
807 813
808 @DomName('IDBKeyRange.lowerBound') 814 @DomName('IDBKeyRange.lowerBound')
809 factory KeyRange.lowerBound(/*Key*/ bound, [bool open = false]) => 815 factory KeyRange.lowerBound(/*Key*/ bound, [bool open = false]) =>
810 _KeyRangeFactoryProvider.createKeyRange_lowerBound(bound, open); 816 _KeyRangeFactoryProvider.createKeyRange_lowerBound(bound, open);
811 817
812 @DomName('IDBKeyRange.upperBound') 818 @DomName('IDBKeyRange.upperBound')
813 factory KeyRange.upperBound(/*Key*/ bound, [bool open = false]) => 819 factory KeyRange.upperBound(/*Key*/ bound, [bool open = false]) =>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 static KeyRange upperBound_(Object bound, [bool open]) native; 867 static KeyRange upperBound_(Object bound, [bool open]) native;
862 868
863 } 869 }
864 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 870 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
865 // for details. All rights reserved. Use of this source code is governed by a 871 // for details. All rights reserved. Use of this source code is governed by a
866 // BSD-style license that can be found in the LICENSE file. 872 // BSD-style license that can be found in the LICENSE file.
867 873
868 874
869 @DomName('IDBObjectStore') 875 @DomName('IDBObjectStore')
870 @Unstable() 876 @Unstable()
871 class ObjectStore extends Interceptor native "IDBObjectStore" { 877 @Native("IDBObjectStore")
878 class ObjectStore extends Interceptor {
872 879
873 @DomName('IDBObjectStore.add') 880 @DomName('IDBObjectStore.add')
874 Future add(value, [key]) { 881 Future add(value, [key]) {
875 try { 882 try {
876 var request; 883 var request;
877 if (key != null) { 884 if (key != null) {
878 request = _add(value, key); 885 request = _add(value, key);
879 } else { 886 } else {
880 request = _add(value); 887 request = _add(value);
881 } 888 }
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 } 1198 }
1192 } 1199 }
1193 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1200 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
1194 // for details. All rights reserved. Use of this source code is governed by a 1201 // for details. All rights reserved. Use of this source code is governed by a
1195 // BSD-style license that can be found in the LICENSE file. 1202 // BSD-style license that can be found in the LICENSE file.
1196 1203
1197 1204
1198 @DocsEditable() 1205 @DocsEditable()
1199 @DomName('IDBOpenDBRequest') 1206 @DomName('IDBOpenDBRequest')
1200 @Unstable() 1207 @Unstable()
1201 class OpenDBRequest extends Request native "IDBOpenDBRequest,IDBVersionChangeReq uest" { 1208 @Native("IDBOpenDBRequest,IDBVersionChangeRequest")
1209 class OpenDBRequest extends Request {
1202 // To suppress missing implicit constructor warnings. 1210 // To suppress missing implicit constructor warnings.
1203 factory OpenDBRequest._() { throw new UnsupportedError("Not supported"); } 1211 factory OpenDBRequest._() { throw new UnsupportedError("Not supported"); }
1204 1212
1205 /** 1213 /**
1206 * Static factory designed to expose `blocked` events to event 1214 * Static factory designed to expose `blocked` events to event
1207 * handlers that are not necessarily instances of [OpenDBRequest]. 1215 * handlers that are not necessarily instances of [OpenDBRequest].
1208 * 1216 *
1209 * See [EventStreamProvider] for usage information. 1217 * See [EventStreamProvider] for usage information.
1210 */ 1218 */
1211 @DomName('IDBOpenDBRequest.blockedEvent') 1219 @DomName('IDBOpenDBRequest.blockedEvent')
(...skipping 21 matching lines...) Expand all
1233 Stream<VersionChangeEvent> get onUpgradeNeeded => upgradeNeededEvent.forTarget (this); 1241 Stream<VersionChangeEvent> get onUpgradeNeeded => upgradeNeededEvent.forTarget (this);
1234 } 1242 }
1235 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1243 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
1236 // for details. All rights reserved. Use of this source code is governed by a 1244 // for details. All rights reserved. Use of this source code is governed by a
1237 // BSD-style license that can be found in the LICENSE file. 1245 // BSD-style license that can be found in the LICENSE file.
1238 1246
1239 1247
1240 @DocsEditable() 1248 @DocsEditable()
1241 @DomName('IDBRequest') 1249 @DomName('IDBRequest')
1242 @Unstable() 1250 @Unstable()
1243 class Request extends EventTarget native "IDBRequest" { 1251 @Native("IDBRequest")
1252 class Request extends EventTarget {
1244 // To suppress missing implicit constructor warnings. 1253 // To suppress missing implicit constructor warnings.
1245 factory Request._() { throw new UnsupportedError("Not supported"); } 1254 factory Request._() { throw new UnsupportedError("Not supported"); }
1246 1255
1247 /** 1256 /**
1248 * Static factory designed to expose `error` events to event 1257 * Static factory designed to expose `error` events to event
1249 * handlers that are not necessarily instances of [Request]. 1258 * handlers that are not necessarily instances of [Request].
1250 * 1259 *
1251 * See [EventStreamProvider] for usage information. 1260 * See [EventStreamProvider] for usage information.
1252 */ 1261 */
1253 @DomName('IDBRequest.errorEvent') 1262 @DomName('IDBRequest.errorEvent')
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 @DocsEditable() 1309 @DocsEditable()
1301 Stream<Event> get onSuccess => successEvent.forTarget(this); 1310 Stream<Event> get onSuccess => successEvent.forTarget(this);
1302 } 1311 }
1303 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1312 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
1304 // for details. All rights reserved. Use of this source code is governed by a 1313 // for details. All rights reserved. Use of this source code is governed by a
1305 // BSD-style license that can be found in the LICENSE file. 1314 // BSD-style license that can be found in the LICENSE file.
1306 1315
1307 1316
1308 @DomName('IDBTransaction') 1317 @DomName('IDBTransaction')
1309 @Unstable() 1318 @Unstable()
1310 class Transaction extends EventTarget native "IDBTransaction" { 1319 @Native("IDBTransaction")
1320 class Transaction extends EventTarget {
1311 1321
1312 /** 1322 /**
1313 * Provides a Future which will be completed once the transaction has 1323 * Provides a Future which will be completed once the transaction has
1314 * completed. 1324 * completed.
1315 * 1325 *
1316 * The future will error if an error occurrs on the transaction or if the 1326 * The future will error if an error occurrs on the transaction or if the
1317 * transaction is aborted. 1327 * transaction is aborted.
1318 */ 1328 */
1319 Future<Database> get completed { 1329 Future<Database> get completed {
1320 var completer = new Completer<Database>(); 1330 var completer = new Completer<Database>();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 1417
1408 } 1418 }
1409 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1419 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
1410 // for details. All rights reserved. Use of this source code is governed by a 1420 // for details. All rights reserved. Use of this source code is governed by a
1411 // BSD-style license that can be found in the LICENSE file. 1421 // BSD-style license that can be found in the LICENSE file.
1412 1422
1413 1423
1414 @DocsEditable() 1424 @DocsEditable()
1415 @DomName('IDBVersionChangeEvent') 1425 @DomName('IDBVersionChangeEvent')
1416 @Unstable() 1426 @Unstable()
1417 class VersionChangeEvent extends Event native "IDBVersionChangeEvent" { 1427 @Native("IDBVersionChangeEvent")
1428 class VersionChangeEvent extends Event {
1418 // To suppress missing implicit constructor warnings. 1429 // To suppress missing implicit constructor warnings.
1419 factory VersionChangeEvent._() { throw new UnsupportedError("Not supported"); } 1430 factory VersionChangeEvent._() { throw new UnsupportedError("Not supported"); }
1420 1431
1421 @DomName('IDBVersionChangeEvent.dataLoss') 1432 @DomName('IDBVersionChangeEvent.dataLoss')
1422 @DocsEditable() 1433 @DocsEditable()
1423 @Experimental() // untriaged 1434 @Experimental() // untriaged
1424 final String dataLoss; 1435 final String dataLoss;
1425 1436
1426 @DomName('IDBVersionChangeEvent.dataLossMessage') 1437 @DomName('IDBVersionChangeEvent.dataLossMessage')
1427 @DocsEditable() 1438 @DocsEditable()
1428 @Experimental() // untriaged 1439 @Experimental() // untriaged
1429 final String dataLossMessage; 1440 final String dataLossMessage;
1430 1441
1431 @DomName('IDBVersionChangeEvent.newVersion') 1442 @DomName('IDBVersionChangeEvent.newVersion')
1432 @DocsEditable() 1443 @DocsEditable()
1433 @Creates('int|String|Null') 1444 @Creates('int|String|Null')
1434 @Returns('int|String|Null') 1445 @Returns('int|String|Null')
1435 final Object newVersion; 1446 final Object newVersion;
1436 1447
1437 @DomName('IDBVersionChangeEvent.oldVersion') 1448 @DomName('IDBVersionChangeEvent.oldVersion')
1438 @DocsEditable() 1449 @DocsEditable()
1439 @Creates('int|String|Null') 1450 @Creates('int|String|Null')
1440 @Returns('int|String|Null') 1451 @Returns('int|String|Null')
1441 final Object oldVersion; 1452 final Object oldVersion;
1442 } 1453 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | sdk/lib/svg/dart2js/svg_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698