Chromium Code Reviews| Index: Source/core/dom/Promise.js |
| diff --git a/Source/core/platform/Task.h b/Source/core/dom/Promise.js |
| similarity index 80% |
| copy from Source/core/platform/Task.h |
| copy to Source/core/dom/Promise.js |
| index b9d2e46802aebf6391df4ec3dabb580d43b2483c..26562d4298b2f85b6650de9dc4d2490f2665e798 100644 |
| --- a/Source/core/platform/Task.h |
| +++ b/Source/core/dom/Promise.js |
| @@ -28,30 +28,27 @@ |
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| -#ifndef Task_h |
| -#define Task_h |
| - |
| -#include "wtf/Functional.h" |
| -#include "public/platform/WebThread.h" |
| - |
| -namespace WebCore { |
| - |
| -class Task : public WebKit::WebThread::Task { |
| -public: |
| - explicit Task(const Closure& closure) |
| - : m_closure(closure) |
| +(function() { |
| + function get(value) |
| { |
| + var old = this.value; |
| + this.value = value; |
| + return old; |
| } |
| - virtual void run() OVERRIDE |
| + function getStatic(value) |
| { |
| - m_closure(); |
| + return new Promise(value); |
|
abarth-chromium
2013/06/18 09:17:22
This calls whatever the web page has mutated windo
yhirano
2013/06/19 12:55:56
Done. Please see Promise-overwrite-constructor.htm
|
| } |
| -private: |
| - Closure m_closure; |
| -}; |
| - |
| -} // namespace WebCore |
| + function $Promise(value) |
| + { |
| + this.value = value; |
|
abarth-chromium
2013/06/18 09:13:16
I'm worried that this will call setters on Object.
yhirano
2013/06/19 12:55:56
Done. Please see Promise-define-setter.html.
|
| + } |
| -#endif // Task_h |
| + $Promise.prototype = { |
|
jsbell
2013/06/18 18:23:13
Possibly use $Promise.prototype = Object.create(nu
abarth-chromium
2013/06/18 18:41:35
Both Object and create would be external dependenc
jsbell
2013/06/18 19:00:08
If this is run *after* user scripts can touch the
yhirano
2013/06/19 12:55:56
There is no external dependencies now.
No property
|
| + get: get |
| + }; |
| + $Promise.getStatic = getStatic; |
| + return $Promise; |
|
abarth-chromium
2013/06/18 09:17:22
What does this print:
console.log((new Promise(42
yhirano
2013/06/19 12:55:56
[object Promise]
|
| +}); |