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

Side by Side Diff: include/v8.h

Issue 196943014: Split Promise API into Promise/Resolver (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 | « no previous file | src/api.cc » ('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 2679 matching lines...) Expand 10 before | Expand all | Expand 10 after
2690 static void CheckCast(Value* obj); 2690 static void CheckCast(Value* obj);
2691 }; 2691 };
2692 2692
2693 2693
2694 /** 2694 /**
2695 * An instance of the built-in Promise constructor (ES6 draft). 2695 * An instance of the built-in Promise constructor (ES6 draft).
2696 * This API is experimental. Only works with --harmony flag. 2696 * This API is experimental. Only works with --harmony flag.
2697 */ 2697 */
2698 class V8_EXPORT Promise : public Object { 2698 class V8_EXPORT Promise : public Object {
2699 public: 2699 public:
2700 /** 2700 class V8_EXPORT Resolver : public Object {
2701 * Create a new Promise in pending state. 2701 public:
2702 */ 2702 /**
2703 static Local<Promise> New(Isolate* isolate); 2703 * Create a new resolver, along with an associated promise in pending state.
2704 */
2705 static Local<Resolver> New(Isolate* isolate);
2704 2706
2705 /** 2707 /**
2706 * Resolve/reject a promise with a given value. 2708 * Extract the associated promise.
2707 * Ignored if the promise is not unresolved. 2709 */
2708 */ 2710 Local<Promise> GetPromise();
2709 void Resolve(Handle<Value> value); 2711
2710 void Reject(Handle<Value> value); 2712 /**
2713 * Resolve/reject the associated promise with a given value.
2714 * Ignored if the promise is no longer pending.
2715 */
2716 void Resolve(Handle<Value> value);
2717 void Reject(Handle<Value> value);
2718
2719 V8_INLINE static Resolver* Cast(Value* obj);
2720
2721 private:
2722 Resolver();
2723 static void CheckCast(Value* obj);
2724 };
2711 2725
2712 /** 2726 /**
2713 * Register a resolution/rejection handler with a promise. 2727 * Register a resolution/rejection handler with a promise.
2714 * The handler is given the respective resolution/rejection value as 2728 * The handler is given the respective resolution/rejection value as
2715 * an argument. If the promise is already resolved/rejected, the handler is 2729 * an argument. If the promise is already resolved/rejected, the handler is
2716 * invoked at the end of turn. 2730 * invoked at the end of turn.
2717 */ 2731 */
2718 Local<Promise> Chain(Handle<Function> handler); 2732 Local<Promise> Chain(Handle<Function> handler);
2719 Local<Promise> Catch(Handle<Function> handler); 2733 Local<Promise> Catch(Handle<Function> handler);
2720 2734
(...skipping 3701 matching lines...) Expand 10 before | Expand all | Expand 10 after
6422 6436
6423 6437
6424 Promise* Promise::Cast(v8::Value* value) { 6438 Promise* Promise::Cast(v8::Value* value) {
6425 #ifdef V8_ENABLE_CHECKS 6439 #ifdef V8_ENABLE_CHECKS
6426 CheckCast(value); 6440 CheckCast(value);
6427 #endif 6441 #endif
6428 return static_cast<Promise*>(value); 6442 return static_cast<Promise*>(value);
6429 } 6443 }
6430 6444
6431 6445
6446 Promise::Resolver* Promise::Resolver::Cast(v8::Value* value) {
6447 #ifdef V8_ENABLE_CHECKS
6448 CheckCast(value);
6449 #endif
6450 return static_cast<Promise::Resolver*>(value);
6451 }
6452
6453
6432 ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) { 6454 ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) {
6433 #ifdef V8_ENABLE_CHECKS 6455 #ifdef V8_ENABLE_CHECKS
6434 CheckCast(value); 6456 CheckCast(value);
6435 #endif 6457 #endif
6436 return static_cast<ArrayBuffer*>(value); 6458 return static_cast<ArrayBuffer*>(value);
6437 } 6459 }
6438 6460
6439 6461
6440 ArrayBufferView* ArrayBufferView::Cast(v8::Value* value) { 6462 ArrayBufferView* ArrayBufferView::Cast(v8::Value* value) {
6441 #ifdef V8_ENABLE_CHECKS 6463 #ifdef V8_ENABLE_CHECKS
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
6697 */ 6719 */
6698 6720
6699 6721
6700 } // namespace v8 6722 } // namespace v8
6701 6723
6702 6724
6703 #undef TYPE_CHECK 6725 #undef TYPE_CHECK
6704 6726
6705 6727
6706 #endif // V8_H_ 6728 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698