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

Side by Side Diff: lib/dom/templates/html/frog/impl_IDBDatabase.darttemplate

Issue 10540016: indexedDB work (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
6
7 _IDBTransactionImpl transaction(storeName_OR_storeNames, String mode) {
8 if (mode != 'readonly' && mode != 'readwrite') {
vsm 2012/06/06 20:08:47 Consider pushing to into _transaction_*_mode to el
9 throw new IllegalArgumentException(mode);
10 }
11
12 // TODO(sra): Ensure storeName_OR_storeNames is a string, List<String> or
13 // DOMStringList, and copy to JavaScript array if necessary.
14
15 if (_transaction_fn != null) {
16 return _transaction_fn(this, storeName_OR_storeNames, mode);
17 }
18
19 // Try and create a transaction with a string mode. Browsers that expect a
20 // numeric mode tend to convert the string into a number. This fails
21 // silently, resulting in zero ('readonly').
22 var txn = _transaction(storeName_OR_storeNames, mode);
23 if (_hasNumericMode(txn)) {
24 _transaction_fn = _transaction_numeric_mode;
25 txn = _transaction_fn(this, storeName_OR_storeNames, mode);
26 } else {
27 _transaction_fn = _transaction_string_mode;
28 }
29 return txn;
30 }
31
32 static var _transaction_fn; // Assigned one of the following:
33
34 static _IDBTransactionImpl _transaction_string_mode($CLASSNAME db, stores, mod e) {
35 return db._transaction(stores, mode);
36 }
37
38 static _IDBTransactionImpl _transaction_numeric_mode($CLASSNAME db, stores, mo de) {
39 int intMode;
40 if (mode == 'readonly') intMode = IDBTransaction.READ_ONLY;
41 if (mode == 'readwrite') intMode = IDBTransaction.READ_WRITE;
42 return db._transaction(stores, intMode);
43 }
44
45 _IDBTransactionImpl _transaction(stores, mode) native 'transaction';
46
47 static bool _hasNumericMode(txn) native 'return typeof(txn.mode) === "number"' ;
48
49 $!MEMBERS}
OLDNEW
« no previous file with comments | « lib/dom/templates/html/frog/html_frog.darttemplate ('k') | lib/dom/templates/html/frog/impl_Window.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698