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

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

Issue 23055008: Making almost all dom_ methods private. Exceptions will be addressed in a later CL. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
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_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 7 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
8 8
9 @DomName('IDBObjectStore.add') 9 @DomName('IDBObjectStore.add')
10 Future add(value, [key]) { 10 Future add(value, [key]) {
11 try { 11 try {
12 var request; 12 var request;
13 if (key != null) { 13 if (key != null) {
14 request = $dom_add(value, key); 14 request = _add(value, key);
15 } else { 15 } else {
16 request = $dom_add(value); 16 request = _add(value);
17 } 17 }
18 return _completeRequest(request); 18 return _completeRequest(request);
19 } catch (e, stacktrace) { 19 } catch (e, stacktrace) {
20 return new Future.error(e, stacktrace); 20 return new Future.error(e, stacktrace);
21 } 21 }
22 } 22 }
23 23
24 @DomName('IDBObjectStore.clear') 24 @DomName('IDBObjectStore.clear')
25 Future clear() { 25 Future clear() {
26 try { 26 try {
27 return _completeRequest($dom_clear()); 27 return _completeRequest(_clear());
28 } catch (e, stacktrace) { 28 } catch (e, stacktrace) {
29 return new Future.error(e, stacktrace); 29 return new Future.error(e, stacktrace);
30 } 30 }
31 } 31 }
32 32
33 @DomName('IDBObjectStore.delete') 33 @DomName('IDBObjectStore.delete')
34 Future delete(key_OR_keyRange){ 34 Future delete(key_OR_keyRange){
35 try { 35 try {
36 return _completeRequest($dom_delete(key_OR_keyRange)); 36 return _completeRequest(_delete(key_OR_keyRange));
37 } catch (e, stacktrace) { 37 } catch (e, stacktrace) {
38 return new Future.error(e, stacktrace); 38 return new Future.error(e, stacktrace);
39 } 39 }
40 } 40 }
41 41
42 @DomName('IDBObjectStore.count') 42 @DomName('IDBObjectStore.count')
43 Future<int> count([key_OR_range]) { 43 Future<int> count([key_OR_range]) {
44 try { 44 try {
45 var request; 45 var request;
46 if (key_OR_range != null) { 46 if (key_OR_range != null) {
47 request = $dom_count(key_OR_range); 47 request = _count(key_OR_range);
48 } else { 48 } else {
49 request = $dom_count(); 49 request = _count();
50 } 50 }
51 return _completeRequest(request); 51 return _completeRequest(request);
52 } catch (e, stacktrace) { 52 } catch (e, stacktrace) {
53 return new Future.error(e, stacktrace); 53 return new Future.error(e, stacktrace);
54 } 54 }
55 } 55 }
56 56
57 @DomName('IDBObjectStore.put') 57 @DomName('IDBObjectStore.put')
58 Future put(value, [key]) { 58 Future put(value, [key]) {
59 try { 59 try {
60 var request; 60 var request;
61 if (key != null) { 61 if (key != null) {
62 request = $dom_put(value, key); 62 request = _put(value, key);
63 } else { 63 } else {
64 request = $dom_put(value); 64 request = _put(value);
65 } 65 }
66 return _completeRequest(request); 66 return _completeRequest(request);
67 } catch (e, stacktrace) { 67 } catch (e, stacktrace) {
68 return new Future.error(e, stacktrace); 68 return new Future.error(e, stacktrace);
69 } 69 }
70 } 70 }
71 71
72 @DomName('IDBObjectStore.get') 72 @DomName('IDBObjectStore.get')
73 Future getObject(key) { 73 Future getObject(key) {
74 try { 74 try {
75 var request = $dom_get(key); 75 var request = _get(key);
76 76
77 return _completeRequest(request); 77 return _completeRequest(request);
78 } catch (e, stacktrace) { 78 } catch (e, stacktrace) {
79 return new Future.error(e, stacktrace); 79 return new Future.error(e, stacktrace);
80 } 80 }
81 } 81 }
82 82
83 /** 83 /**
84 * Creates a stream of cursors over the records in this object store. 84 * Creates a stream of cursors over the records in this object store.
85 * 85 *
(...skipping 24 matching lines...) Expand all
110 throw new ArgumentError('Cannot specify both key and range.'); 110 throw new ArgumentError('Cannot specify both key and range.');
111 } 111 }
112 key_OR_range = key; 112 key_OR_range = key;
113 } else { 113 } else {
114 key_OR_range = range; 114 key_OR_range = range;
115 } 115 }
116 116
117 // 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.
118 var request; 118 var request;
119 if (direction == null) { 119 if (direction == null) {
120 request = $dom_openCursor(key_OR_range); 120 request = _openCursor(key_OR_range);
121 } else { 121 } else {
122 request = $dom_openCursor(key_OR_range, direction); 122 request = _openCursor(key_OR_range, direction);
123 } 123 }
124 return _cursorStreamFromResult(request, autoAdvance); 124 return _cursorStreamFromResult(request, autoAdvance);
125 } 125 }
126 126
127 @DomName('IDBObjectStore.createIndex') 127 @DomName('IDBObjectStore.createIndex')
128 Index createIndex(String name, keyPath, {bool unique, bool multiEntry}) { 128 Index createIndex(String name, keyPath, {bool unique, bool multiEntry}) {
129 var options = {}; 129 var options = {};
130 if (unique != null) { 130 if (unique != null) {
131 options['unique'] = unique; 131 options['unique'] = unique;
132 } 132 }
133 if (multiEntry != null) { 133 if (multiEntry != null) {
134 options['multiEntry'] = multiEntry; 134 options['multiEntry'] = multiEntry;
135 } 135 }
136 136
137 return $dom_createIndex(name, keyPath, options); 137 return _createIndex(name, keyPath, options);
138 } 138 }
139 139
140 $!MEMBERS 140 $!MEMBERS
141 141
142 /** 142 /**
143 * Helper for iterating over cursors in a request. 143 * Helper for iterating over cursors in a request.
144 */ 144 */
145 static Stream<Cursor> _cursorStreamFromResult(Request request, 145 static Stream<Cursor> _cursorStreamFromResult(Request request,
146 bool autoAdvance) { 146 bool autoAdvance) {
147 // TODO: need to guarantee that the controller provides the values 147 // TODO: need to guarantee that the controller provides the values
(...skipping 13 matching lines...) Expand all
161 } else { 161 } else {
162 controller.add(cursor); 162 controller.add(cursor);
163 if (autoAdvance == true && controller.hasListener) { 163 if (autoAdvance == true && controller.hasListener) {
164 cursor.next(); 164 cursor.next();
165 } 165 }
166 } 166 }
167 }); 167 });
168 return controller.stream; 168 return controller.stream;
169 } 169 }
170 } 170 }
OLDNEW
« no previous file with comments | « tools/dom/templates/html/impl/impl_IDBIndex.darttemplate ('k') | tools/dom/templates/html/impl/impl_MessageEvent.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698