@@ -519,7 +519,7 @@ promise.Promise.prototype.scheduleNotifications_ = function() {
519
519
}
520
520
521
521
if ( this . callbacks_ && this . callbacks_ . length ) {
522
- activeFrame = this . flow_ . getActiveFrame_ ( ) ;
522
+ activeFrame = this . flow_ . getSchedulingFrame_ ( ) ;
523
523
var self = this ;
524
524
goog . array . forEach ( this . callbacks_ , function ( callback ) {
525
525
if ( ! callback . frame_ . getParent ( ) ) {
@@ -653,7 +653,7 @@ promise.Promise.prototype.addCallback_ = function(callback, errback, name, fn) {
653
653
if ( this . state_ !== promise . Promise . State_ . PENDING &&
654
654
this . state_ !== promise . Promise . State_ . BLOCKED ) {
655
655
cb . frame_ . pendingCallback = true ;
656
- this . flow_ . getActiveFrame_ ( ) . addChild ( cb . frame_ ) ;
656
+ this . flow_ . getSchedulingFrame_ ( ) . addChild ( cb . frame_ ) ;
657
657
this . scheduleNotifications_ ( ) ;
658
658
}
659
659
return cb . promise ;
@@ -1463,6 +1463,15 @@ promise.ControlFlow.prototype.getActiveFrame_ = function() {
1463
1463
} ;
1464
1464
1465
1465
1466
+ /**
1467
+ * @return {!promise.Frame_ } The frame that new items should be added to.
1468
+ * @private
1469
+ */
1470
+ promise . ControlFlow . prototype . getSchedulingFrame_ = function ( ) {
1471
+ return this . schedulingFrame_ || this . getActiveFrame_ ( ) ;
1472
+ } ;
1473
+
1474
+
1466
1475
/**
1467
1476
* Schedules a task for execution. If there is nothing currently in the
1468
1477
* queue, the task will be executed in the next turn of the event loop. If
@@ -1493,9 +1502,7 @@ promise.ControlFlow.prototype.execute = function(fn, opt_description) {
1493
1502
task . promise . stack_ = promise . captureStackTrace ( 'Task' , description ,
1494
1503
promise . ControlFlow . prototype . execute ) ;
1495
1504
1496
- var scheduleIn = this . schedulingFrame_ || this . getActiveFrame_ ( ) ;
1497
- scheduleIn . addChild ( task ) ;
1498
-
1505
+ this . getSchedulingFrame_ ( ) . addChild ( task ) ;
1499
1506
this . emit ( promise . ControlFlow . EventType . SCHEDULE_TASK , opt_description ) ;
1500
1507
this . scheduleEventLoopStart_ ( ) ;
1501
1508
return task . promise ;
@@ -2246,14 +2253,6 @@ promise.Frame_.prototype.addChild = function(node) {
2246
2253
return ; // Child will never run, no point keeping a reference.
2247
2254
}
2248
2255
2249
- if ( this . lastInsertedChild_ &&
2250
- this . lastInsertedChild_ instanceof promise . Frame_ &&
2251
- ! this . lastInsertedChild_ . pendingCallback &&
2252
- ! this . lastInsertedChild_ . isLocked_ ) {
2253
- this . lastInsertedChild_ . addChild ( node ) ;
2254
- return ;
2255
- }
2256
-
2257
2256
node . setParent ( this ) ;
2258
2257
if ( this . isLocked_ && node instanceof promise . Frame_ ) {
2259
2258
var index = 0 ;
0 commit comments