Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 (function(global, utils, extrasUtils) { | 5 (function(global, utils, extrasUtils) { |
| 6 | 6 |
| 7 "use strict"; | 7 "use strict"; |
| 8 | 8 |
| 9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
| 10 | 10 |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 | 580 |
| 581 // Return whether the promise will be handled by a user-defined reject | 581 // Return whether the promise will be handled by a user-defined reject |
| 582 // handler somewhere down the promise chain. For this, we do a depth-first | 582 // handler somewhere down the promise chain. For this, we do a depth-first |
| 583 // search for a reject handler that's not the default PromiseIdRejectHandler. | 583 // search for a reject handler that's not the default PromiseIdRejectHandler. |
| 584 // This function also traverses dependencies of one Promise on another, | 584 // This function also traverses dependencies of one Promise on another, |
| 585 // set up through async/await and Promises resolved with Promises. | 585 // set up through async/await and Promises resolved with Promises. |
| 586 function PromiseHasUserDefinedRejectHandler() { | 586 function PromiseHasUserDefinedRejectHandler() { |
| 587 return PromiseHasUserDefinedRejectHandlerRecursive(this); | 587 return PromiseHasUserDefinedRejectHandlerRecursive(this); |
| 588 }; | 588 }; |
| 589 | 589 |
| 590 function MarkPromiseAsHandled(promise) { | |
| 591 SET_PRIVATE(promise, promiseHasHandlerSymbol, true); | |
| 592 } | |
|
Dan Ehrenberg
2016/11/15 10:34:39
I like factoring this out into a separate function
| |
| 593 | |
| 590 | 594 |
| 591 function PromiseSpecies() { | 595 function PromiseSpecies() { |
| 592 return this; | 596 return this; |
| 593 } | 597 } |
| 594 | 598 |
| 595 // ------------------------------------------------------------------- | 599 // ------------------------------------------------------------------- |
| 596 // Install exported functions. | 600 // Install exported functions. |
| 597 | 601 |
| 598 %AddNamedProperty(global, 'Promise', GlobalPromise, DONT_ENUM); | 602 %AddNamedProperty(global, 'Promise', GlobalPromise, DONT_ENUM); |
| 599 %AddNamedProperty(GlobalPromise.prototype, toStringTagSymbol, "Promise", | 603 %AddNamedProperty(GlobalPromise.prototype, toStringTagSymbol, "Promise", |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 625 "promise_handle", PromiseHandle, | 629 "promise_handle", PromiseHandle, |
| 626 "promise_debug_get_info", PromiseDebugGetInfo | 630 "promise_debug_get_info", PromiseDebugGetInfo |
| 627 ]); | 631 ]); |
| 628 | 632 |
| 629 // This allows extras to create promises quickly without building extra | 633 // This allows extras to create promises quickly without building extra |
| 630 // resolve/reject closures, and allows them to later resolve and reject any | 634 // resolve/reject closures, and allows them to later resolve and reject any |
| 631 // promise without having to hold on to those closures forever. | 635 // promise without having to hold on to those closures forever. |
| 632 utils.InstallFunctions(extrasUtils, 0, [ | 636 utils.InstallFunctions(extrasUtils, 0, [ |
| 633 "createPromise", PromiseCreate, | 637 "createPromise", PromiseCreate, |
| 634 "resolvePromise", ResolvePromise, | 638 "resolvePromise", ResolvePromise, |
| 635 "rejectPromise", DoRejectPromise | 639 "rejectPromise", DoRejectPromise, |
| 640 "markPromiseAsHandled", MarkPromiseAsHandled | |
|
Dan Ehrenberg
2016/11/15 10:35:14
Maybe add a trailing comma here so that future pat
| |
| 636 ]); | 641 ]); |
| 637 | 642 |
| 638 utils.Export(function(to) { | 643 utils.Export(function(to) { |
| 639 to.IsPromise = IsPromise; | 644 to.IsPromise = IsPromise; |
| 640 to.PromiseCreate = PromiseCreate; | 645 to.PromiseCreate = PromiseCreate; |
| 641 to.PromiseThen = PromiseThen; | 646 to.PromiseThen = PromiseThen; |
| 642 | 647 |
| 643 to.GlobalPromise = GlobalPromise; | 648 to.GlobalPromise = GlobalPromise; |
| 644 to.NewPromiseCapability = NewPromiseCapability; | 649 to.NewPromiseCapability = NewPromiseCapability; |
| 645 to.PerformPromiseThen = PerformPromiseThen; | 650 to.PerformPromiseThen = PerformPromiseThen; |
| 646 to.ResolvePromise = ResolvePromise; | 651 to.ResolvePromise = ResolvePromise; |
| 647 to.RejectPromise = RejectPromise; | 652 to.RejectPromise = RejectPromise; |
| 648 }); | 653 }); |
| 649 | 654 |
| 650 }) | 655 }) |
| OLD | NEW |