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

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

Issue 26789008: Fixing double-completing indexed DB transactions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | « no previous file | sdk/lib/indexed_db/dartium/indexed_db_dartium.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 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 /** 1245 /**
1246 * Provides a Future which will be completed once the transaction has 1246 * Provides a Future which will be completed once the transaction has
1247 * completed. 1247 * completed.
1248 * 1248 *
1249 * The future will error if an error occurrs on the transaction or if the 1249 * The future will error if an error occurrs on the transaction or if the
1250 * transaction is aborted. 1250 * transaction is aborted.
1251 */ 1251 */
1252 Future<Database> get completed { 1252 Future<Database> get completed {
1253 var completer = new Completer<Database>(); 1253 var completer = new Completer<Database>();
1254 1254
1255 var errored = false;
1256
1255 this.onComplete.first.then((_) { 1257 this.onComplete.first.then((_) {
1256 completer.complete(db); 1258 completer.complete(db);
1257 }); 1259 });
1258 1260
1259 this.onError.first.then((e) { 1261 this.onError.first.then((e) {
1262 errored = true;
1260 completer.completeError(e); 1263 completer.completeError(e);
1261 }); 1264 });
1262 1265
1263 this.onAbort.first.then((e) { 1266 this.onAbort.first.then((e) {
1264 completer.completeError(e); 1267 // Avoid completing twice if an error occurs.
1268 if (!errored) {
Emily Fortuna 2013/10/16 00:20:59 would completer.isCompleted work instead?
blois 2013/10/17 01:05:07 Ah, much nicer!
1269 completer.completeError(e);
1270 }
1265 }); 1271 });
1266 1272
1267 return completer.future; 1273 return completer.future;
1268 } 1274 }
1269 1275
1270 // To suppress missing implicit constructor warnings. 1276 // To suppress missing implicit constructor warnings.
1271 factory Transaction._() { throw new UnsupportedError("Not supported"); } 1277 factory Transaction._() { throw new UnsupportedError("Not supported"); }
1272 1278
1273 @DomName('IDBTransaction.abortEvent') 1279 @DomName('IDBTransaction.abortEvent')
1274 @DocsEditable() 1280 @DocsEditable()
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 // BSD-style license that can be found in the LICENSE file. 1355 // BSD-style license that can be found in the LICENSE file.
1350 1356
1351 1357
1352 @DocsEditable() 1358 @DocsEditable()
1353 @DomName('IDBAny') 1359 @DomName('IDBAny')
1354 @deprecated // nonstandard 1360 @deprecated // nonstandard
1355 abstract class _IDBAny extends Interceptor native "IDBAny" { 1361 abstract class _IDBAny extends Interceptor native "IDBAny" {
1356 // To suppress missing implicit constructor warnings. 1362 // To suppress missing implicit constructor warnings.
1357 factory _IDBAny._() { throw new UnsupportedError("Not supported"); } 1363 factory _IDBAny._() { throw new UnsupportedError("Not supported"); }
1358 } 1364 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/indexed_db/dartium/indexed_db_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698