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

Side by Side Diff: sky/engine/bindings-dart/common/AbstractScriptPromiseResolver.h

Issue 918273002: Remove bindings-dart (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef AbstractScriptPromiseResolver_h
6 #define AbstractScriptPromiseResolver_h
7
8 #include "bindings/common/ScriptPromise.h"
9 #include "bindings/common/ScriptState.h"
10 #include "bindings/core/v8/ScopedPersistent.h"
11 #include "bindings/core/v8/V8Binding.h"
12 #include "core/dom/ActiveDOMObject.h"
13 #include "core/dom/ExecutionContext.h"
14 #include "platform/Timer.h"
15 #include "wtf/RefCounted.h"
16 #include "wtf/Vector.h"
17 #include <v8.h>
18
19 namespace blink {
20
21 class BatteryManager;
22 class Blob;
23 class Cache;
24 class Credential;
25 class CryptoKey;
26 class DOMError;
27 class DOMException;
28 class ExecutionContext;
29 class FontFace;
30 class FontFaceSet;
31 class ImageBitmap;
32 class MIDIAccess;
33 class MediaKeySession;
34 class MediaKeys;
35 class PushRegistration;
36 class Response;
37 class ServiceWorker;
38 class ServiceWorkerClient;
39 class ServiceWorkerRegistration;
40 class StorageInfo;
41
42 // Do not add bool to this list, as it becomes the implicit conversion for types
43 // that are missing from this list. Use ScriptState::createBoolean instead.
44 #define PROMISE_RESOLUTION_TYPES_LIST(V) \
45 V(AtomicString) \
46 V(BatteryManager*) \
47 V(Credential*) \
48 V(CryptoKey*) \
49 V(MediaKeys*) \
50 V(MIDIAccess*) \
51 V(PassRefPtr<ArrayBuffer>) \
52 V(PassRefPtr<BatteryManager>) \
53 V(PassRefPtr<Cache>) \
54 V(PassRefPtr<MediaKeySession>) \
55 V(PassRefPtr<Response>) \
56 V(PassRefPtrWillBeRawPtr<Blob>) \
57 V(PassRefPtrWillBeRawPtr<DOMError>) \
58 V(PassRefPtrWillBeRawPtr<DOMException>) \
59 V(PassRefPtrWillBeRawPtr<FontFace>) \
60 V(PassRefPtrWillBeRawPtr<FontFaceSet>) \
61 V(PassRefPtrWillBeRawPtr<ImageBitmap>) \
62 V(PassRefPtrWillBeRawPtr<MIDIAccess>) \
63 V(PassRefPtrWillBeRawPtr<ServiceWorker>) \
64 V(PassRefPtrWillBeRawPtr<ServiceWorkerRegistration>) \
65 V(PushRegistration*) \
66 V(ScriptValue) \
67 V(ServiceWorker*) \
68 V(StorageInfo*) \
69 V(String) \
70 V(WillBeHeapVector<RefPtrWillBeMember<ServiceWorkerClient> >) \
71 V(Vector<String>) \
72 V(V8UndefinedType) \
73 V(WillBeHeapVector<RefPtrWillBeMember<FontFace> >) \
74 V(const char*) \
75 V(v8::Handle<v8::Value>) \
76
77
78 // This class wraps v8::Promise::Resolver and provides the following
79 // functionalities.
80 // - A ScriptPromiseResolver retains a ScriptState. A caller
81 // can call resolve or reject from outside of a V8 context.
82 // - This class is an ActiveDOMObject and keeps track of the associated
83 // ExecutionContext state. When the ExecutionContext is suspended,
84 // resolve or reject will be delayed. When it is stopped, resolve or reject
85 // will be ignored.
86 class AbstractScriptPromiseResolver {
87 WTF_MAKE_NONCOPYABLE(AbstractScriptPromiseResolver);
88 public:
89 virtual ~AbstractScriptPromiseResolver() { }
90
91 // Note that an empty ScriptPromise will be returned after resolve or
92 // reject is called.
93 virtual PassRefPtr<AbstractScriptPromise> promise() = 0;
94
95 virtual void resolve() = 0;
96 virtual void reject() = 0;
97
98 #define DECLARE_RESOLUTION_METHODS(type) \
99 virtual void resolve(type) = 0; \
100 virtual void reject(type) = 0;
101 PROMISE_RESOLUTION_TYPES_LIST(DECLARE_RESOLUTION_METHODS);
102 #undef DECLARE_RESOLUTION_METHODS
103
104 // Once this function is called this resolver stays alive while the
105 // promise is pending and the associated ExecutionContext isn't stopped.
106 virtual void keepAliveWhilePending() = 0;
107
108 virtual ScriptState* scriptState() = 0;
109 virtual ScriptState* scriptState() const = 0;
110
111 // Forwarded ActiveDOMObject implementation.
112 virtual void suspend() = 0;
113 virtual void resume() = 0;
114 virtual void stop() = 0;
115
116 protected:
117 // You need to call suspendIfNeeded after the construction because
118 // this is an ActiveDOMObject.
119 AbstractScriptPromiseResolver() { }
120 };
121
122 } // namespace blink
123
124 #endif // #ifndef AbstractScriptPromiseResolver_h
OLDNEW
« no previous file with comments | « sky/engine/bindings-dart/common/AbstractScriptPromise.h ('k') | sky/engine/bindings-dart/common/AbstractScriptValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698