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

Side by Side Diff: src/promise.js

Issue 194663003: API support for promises (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Sven's comments Created 6 years, 9 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 | « src/contexts.h ('k') | src/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 function PromiseResolve(promise, x) { 96 function PromiseResolve(promise, x) {
97 PromiseDone(promise, +1, x, promiseOnResolve) 97 PromiseDone(promise, +1, x, promiseOnResolve)
98 } 98 }
99 99
100 function PromiseReject(promise, r) { 100 function PromiseReject(promise, r) {
101 PromiseDone(promise, -1, r, promiseOnReject) 101 PromiseDone(promise, -1, r, promiseOnReject)
102 } 102 }
103 103
104 104
105 // For API.
106
107 function PromiseNopResolver() {}
108
109 function PromiseCreate() {
110 return new Promise(PromiseNopResolver)
111 }
112
113
105 // Convenience. 114 // Convenience.
106 115
107 function PromiseDeferred() { 116 function PromiseDeferred() {
108 if (this === $Promise) { 117 if (this === $Promise) {
109 // Optimized case, avoid extra closure. 118 // Optimized case, avoid extra closure.
110 var promise = PromiseInit(new Promise(promiseRaw)); 119 var promise = PromiseInit(new Promise(promiseRaw));
111 return { 120 return {
112 promise: promise, 121 promise: promise,
113 resolve: function(x) { PromiseResolve(promise, x) }, 122 resolve: function(x) { PromiseResolve(promise, x) },
114 reject: function(r) { PromiseReject(promise, r) } 123 reject: function(r) { PromiseReject(promise, r) }
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 "cast", PromiseCast 316 "cast", PromiseCast
308 ]); 317 ]);
309 InstallFunctions($Promise.prototype, DONT_ENUM, [ 318 InstallFunctions($Promise.prototype, DONT_ENUM, [
310 "chain", PromiseChain, 319 "chain", PromiseChain,
311 "then", PromiseThen, 320 "then", PromiseThen,
312 "catch", PromiseCatch 321 "catch", PromiseCatch
313 ]); 322 ]);
314 } 323 }
315 324
316 SetUpPromise(); 325 SetUpPromise();
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698