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

Side by Side Diff: tools/dom/templates/html/impl/impl_IDBObjectStore.darttemplate

Issue 12313015: Dartifying remainder of Index DB APIs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « tools/dom/templates/html/impl/impl_IDBIndex.darttemplate ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 part of $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
8 8
9 @DomName('IDBObjectStore.add')
10 Future add(value, [key]) {
11 try {
12 var request;
13 if (key != null) {
14 request = $dom_add(value, key);
15 } else {
16 request = $dom_add(value);
17 }
18 return _completeRequest(request);
19 } catch (e, stacktrace) {
20 return new Future.immediateError(e, stacktrace);
21 }
22 }
23
24 @DomName('IDBObjectStore.clear')
25 Future clear() {
26 try {
27 return _completeRequest($dom_clear());
28 } catch (e, stacktrace) {
29 return new Future.immediateError(e, stacktrace);
30 }
31 }
32
33 @DomName('IDBObjectStore.delete')
34 Future delete(key_OR_keyRange){
35 try {
36 return _completeRequest($dom_delete(key_OR_keyRange));
37 } catch (e, stacktrace) {
38 return new Future.immediateError(e, stacktrace);
39 }
40 }
41
42 @DomName('IDBObjectStore.count')
43 Future<int> count([key_OR_range]) {
44 try {
45 var request;
46 if (key_OR_range != null) {
47 request = $dom_count(key_OR_range);
48 } else {
49 request = $dom_count();
50 }
51 return _completeRequest(request);
52 } catch (e, stacktrace) {
53 return new Future.immediateError(e, stacktrace);
54 }
55 }
56
9 @DomName('IDBObjectStore.put') 57 @DomName('IDBObjectStore.put')
10 Future put(value, [key]) { 58 Future put(value, [key]) {
11 try { 59 try {
12 var request; 60 var request;
13 if (key != null) { 61 if (key != null) {
14 request = $dom_put(value, key); 62 request = $dom_put(value, key);
15 } else { 63 } else {
16 request = $dom_put(value); 64 request = $dom_put(value);
17 } 65 }
18 return _completeRequest(request); 66 return _completeRequest(request);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // TODO: try/catch this and return a stream with an immediate error. 117 // TODO: try/catch this and return a stream with an immediate error.
70 var request; 118 var request;
71 if (direction == null) { 119 if (direction == null) {
72 request = $dom_openCursor(key_OR_range); 120 request = $dom_openCursor(key_OR_range);
73 } else { 121 } else {
74 request = $dom_openCursor(key_OR_range, direction); 122 request = $dom_openCursor(key_OR_range, direction);
75 } 123 }
76 return _cursorStreamFromResult(request, autoAdvance); 124 return _cursorStreamFromResult(request, autoAdvance);
77 } 125 }
78 126
127 @DomName('IDBObjectStore.createIndex')
128 Index createIndex(String name, keyPath, {bool unique, bool multiEntry}) {
129 var options = {};
130 if (unique != null) {
131 options['unique'] = unique;
132 }
133 if (multiEntry != null) {
134 options['multiEntry'] = multiEntry;
135 }
136
137 return $dom_createIndex(name, keyPath, options);
138 }
139
79 $!MEMBERS 140 $!MEMBERS
80 141
81 /** 142 /**
82 * Helper for iterating over cursors in a request. 143 * Helper for iterating over cursors in a request.
83 */ 144 */
84 static Stream<Cursor> _cursorStreamFromResult(Request request, 145 static Stream<Cursor> _cursorStreamFromResult(Request request,
85 bool autoAdvance) { 146 bool autoAdvance) {
86 // TODO: need to guarantee that the controller provides the values 147 // TODO: need to guarantee that the controller provides the values
87 // immediately as waiting until the next tick will cause the transaction to 148 // immediately as waiting until the next tick will cause the transaction to
88 // close. 149 // close.
(...skipping 11 matching lines...) Expand all
100 } else { 161 } else {
101 controller.add(cursor); 162 controller.add(cursor);
102 if (autoAdvance == true) { 163 if (autoAdvance == true) {
103 cursor.next(); 164 cursor.next();
104 } 165 }
105 } 166 }
106 }); 167 });
107 return controller.stream; 168 return controller.stream;
108 } 169 }
109 } 170 }
OLDNEW
« no previous file with comments | « tools/dom/templates/html/impl/impl_IDBIndex.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698