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

Side by Side Diff: tools/dom/templates/html/impl/impl_IDBFactory.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
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 * Checks to see if Indexed DB is supported on the current platform. 9 * Checks to see if Indexed DB is supported on the current platform.
10 */ 10 */
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 if (onBlocked != null) { 56 if (onBlocked != null) {
57 request.onBlocked.listen(onBlocked); 57 request.onBlocked.listen(onBlocked);
58 } 58 }
59 return _completeRequest(request); 59 return _completeRequest(request);
60 } catch (e, stacktrace) { 60 } catch (e, stacktrace) {
61 return new Future.immediateError(e, stacktrace); 61 return new Future.immediateError(e, stacktrace);
62 } 62 }
63 } 63 }
64 64
65 @DomName('IDBFactory.getDatabaseNames')
66 @SupportedBrowser(SupportedBrowser.CHROME)
67 @Experimental
68 Future<List<String>> getDatabaseNames() {
69 try {
70 var request = $dom_webkitGetDatabaseNames();
71
72 return _completeRequest(request);
73 } catch (e, stacktrace) {
74 return new Future.immediateError(e, stacktrace);
75 }
76 }
77
78 /**
79 * Checks to see if getDatabaseNames is supported by the current platform.
80 */
81 bool get supportsDatabaseNames {
82 $if DART2JS
83 return JS('bool', '!!(#.getDatabaseNames || #.webkitGetDatabaseNames)',
84 this, this);
85 $else
86 return true;
87 $endif
88 }
89
65 $!MEMBERS 90 $!MEMBERS
66 } 91 }
67 92
68 93
69 /** 94 /**
70 * Ties a request to a completer, so the completer is completed when it succeeds 95 * Ties a request to a completer, so the completer is completed when it succeeds
71 * and errors out when the request errors. 96 * and errors out when the request errors.
72 */ 97 */
73 Future _completeRequest(Request request) { 98 Future _completeRequest(Request request) {
74 var completer = new Completer(); 99 var completer = new Completer();
75 // TODO: make sure that completer.complete is synchronous as transactions 100 // TODO: make sure that completer.complete is synchronous as transactions
76 // may be committed if the result is not processed immediately. 101 // may be committed if the result is not processed immediately.
77 request.onSuccess.listen((e) { 102 request.onSuccess.listen((e) {
78 completer.complete(request.result); 103 completer.complete(request.result);
79 }); 104 });
80 request.onError.listen((e) { 105 request.onError.listen((e) {
81 completer.completeError(e); 106 completer.completeError(e);
82 }); 107 });
83 return completer.future; 108 return completer.future;
84 } 109 }
OLDNEW
« no previous file with comments | « tools/dom/templates/html/impl/impl_IDBDatabase.darttemplate ('k') | tools/dom/templates/html/impl/impl_IDBIndex.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698