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

Side by Side Diff: Source/bindings/v8/custom/V8PromiseCustom.h

Issue 293933002: Remove the Promises old implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « Source/bindings/v8/V8Initializer.cpp ('k') | Source/bindings/v8/custom/V8PromiseCustom.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013, Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25 #ifndef V8PromiseCustom_h
26 #define V8PromiseCustom_h
27
28 #include "bindings/v8/WrapperTypeInfo.h"
29
30 #include <v8.h>
31
32 namespace WebCore {
33
34 class V8PromiseCustom {
35 public:
36 enum InternalFieldIndex {
37 InternalStateIndex,
38 InternalResultIndex,
39 InternalFulfillCallbackIndex,
40 InternalRejectCallbackIndex,
41 InternalDerivedPromiseIndex,
42 InternalFieldCount, // This entry must always be at the bottom.
43 };
44
45 enum PromiseAllEnvironmentFieldIndex {
46 PromiseAllEnvironmentPromiseIndex,
47 PromiseAllEnvironmentCountdownIndex,
48 PromiseAllEnvironmentIndexIndex,
49 PromiseAllEnvironmentResultsIndex,
50 PromiseAllEnvironmentFieldCount, // This entry must always be at the bot tom.
51 };
52
53 enum PrimitiveWrapperFieldIndex {
54 PrimitiveWrapperPrimitiveIndex,
55 PrimitiveWrapperFieldCount, // This entry must always be at the bottom.
56 };
57
58 enum PromiseState {
59 Pending,
60 Fulfilled,
61 Rejected,
62 Following,
63 };
64
65 static v8::Local<v8::Object> createPromise(v8::Handle<v8::Object> creationCo ntext, v8::Isolate*);
66
67 // |promise| must be a Promise instance.
68 static v8::Local<v8::Object> getInternal(v8::Handle<v8::Object> promise);
69
70 // |internal| must be a Promise internal object.
71 static PromiseState getState(v8::Handle<v8::Object> internal);
72
73 // Return true if |maybePromise| is a Promise instance.
74 static bool isPromise(v8::Handle<v8::Value> maybePromise, v8::Isolate*);
75
76 // Coerces |maybePromise| to a Promise instance.
77 static v8::Local<v8::Object> toPromise(v8::Handle<v8::Value> maybePromise, v 8::Isolate*);
78
79 // |promise| must be a Promise instance.
80 static void resolve(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> re sult, v8::Isolate*);
81
82 // |promise| must be a Promise instance.
83 static void reject(v8::Handle<v8::Object> promise, v8::Handle<v8::Value> res ult, v8::Isolate*);
84
85 // |promise| must be a Promise instance.
86 // |onFulfilled| and |onRejected| can be an empty value respectively.
87 // Appends |onFulfilled| and/or |onRejected| handlers to |promise|.
88 static v8::Local<v8::Object> then(v8::Handle<v8::Object> promise, v8::Handle <v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Isolate*);
89
90 // |promise| must be a Promise instance.
91 // Set a |promise|'s value and propagate it to derived promises.
92 static void setValue(v8::Handle<v8::Object> promise, v8::Handle<v8::Value>, v8::Isolate*);
93
94 // |promise| must be a Promise instance.
95 // Set a |promise|'s failure reason and propagate it to derived promises.
96 static void setReason(v8::Handle<v8::Object> promise, v8::Handle<v8::Value>, v8::Isolate*);
97
98 // |promise| must be a Promise instance.
99 // Propagate a |promise|'s value or reason to all of its derived promies.
100 static void propagateToDerived(v8::Handle<v8::Object> promise, v8::Isolate*) ;
101
102 // |derivedPromise| and |originator| must be a Promise instance.
103 // |onFulfilled| and |onRejected| can be an empty value respectively.
104 // Propagate |originator|'s state to |derivedPromise|.
105 static void updateDerived(v8::Handle<v8::Object> derivedPromise, v8::Handle< v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::Handle<v8::O bject> originator, v8::Isolate*);
106
107 // |derivedPromise| must be a Promise instance.
108 // Propagate a value to |derivedPromise|.
109 static void updateDerivedFromValue(v8::Handle<v8::Object> derivedPromise, v8 ::Handle<v8::Function> onFulfilled, v8::Handle<v8::Value>, v8::Isolate*);
110
111 // |derivedPromise| must be a Promise instance.
112 // Propagate a failure reason to |derivedPromise|.
113 static void updateDerivedFromReason(v8::Handle<v8::Object> derivedPromise, v 8::Handle<v8::Function> onRejected, v8::Handle<v8::Value>, v8::Isolate*);
114
115 // |derivedPromise| and |promise| must be a Promise instance.
116 // |onFulfilled| and |onRejected| can be an empty value respectively.
117 // Propagate |promise|'s state to |derivedPromise|.
118 static void updateDerivedFromPromise(v8::Handle<v8::Object> derivedPromise, v8::Handle<v8::Function> onFulfilled, v8::Handle<v8::Function> onRejected, v8::H andle<v8::Object> promise, v8::Isolate*);
119
120 // Returns a Promise instance that will be fulfilled or rejected by
121 // |thenable|'s result.
122 static v8::Local<v8::Object> coerceThenable(v8::Handle<v8::Object> thenable, v8::Handle<v8::Function> then, v8::Isolate*);
123
124 // |promise| must be a Promise instance.
125 // Applies a transformation to an argument and use it to update derived
126 // promies.
127 static void callHandler(v8::Handle<v8::Object> promise, v8::Handle<v8::Funct ion> handler, v8::Handle<v8::Value> argument, PromiseState originatorState, v8:: Isolate*);
128 };
129
130 } // namespace WebCore
131
132 #endif // V8PromiseCustom_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8Initializer.cpp ('k') | Source/bindings/v8/custom/V8PromiseCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698