Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 ScriptPromisePropertyBase_h | |
| 6 #define ScriptPromisePropertyBase_h | |
| 7 | |
| 8 #include "bindings/core/v8/ScopedPersistent.h" | |
| 9 #include "bindings/core/v8/ScriptPromise.h" | |
| 10 #include "core/dom/ContextLifecycleObserver.h" | |
| 11 #include "wtf/OwnPtr.h" | |
|
haraken
2014/07/02 09:04:32
This is not needed.
| |
| 12 #include "wtf/RefCounted.h" | |
| 13 #include "wtf/Vector.h" | |
|
haraken
2014/07/02 09:04:32
This is not needed.
| |
| 14 #include "wtf/text/WTFString.h" | |
| 15 #include <v8.h> | |
| 16 | |
| 17 namespace WebCore { | |
| 18 | |
| 19 class ExecutionContext; | |
| 20 | |
| 21 class ScriptPromisePropertyBase : public ContextLifecycleObserver, public RefCou nted<ScriptPromisePropertyBase> { | |
| 22 public: | |
| 23 virtual ~ScriptPromisePropertyBase(); | |
| 24 | |
| 25 enum State { | |
| 26 Pending, | |
| 27 Resolved, | |
| 28 Rejected, | |
| 29 }; | |
| 30 State state() const { return m_state; } | |
| 31 | |
| 32 ScriptPromise promise(DOMWrapperWorld&); | |
| 33 | |
| 34 protected: | |
| 35 ScriptPromisePropertyBase(ExecutionContext*, const char* name); | |
| 36 | |
| 37 void settle(State targetState); | |
| 38 | |
| 39 virtual v8::Handle<v8::Object> holder(v8::Handle<v8::Object> creationContext , v8::Isolate*) = 0; | |
| 40 virtual v8::Handle<v8::Value> resolvedValue(v8::Handle<v8::Object> creationC ontext, v8::Isolate*) = 0; | |
| 41 virtual v8::Handle<v8::Value> rejectedValue(v8::Handle<v8::Object> creationC ontext, v8::Isolate*) = 0; | |
| 42 | |
| 43 private: | |
| 44 void resolveOrReject(v8::Handle<v8::Promise::Resolver>); | |
| 45 | |
| 46 v8::Isolate* m_isolate; | |
| 47 State m_state; | |
| 48 String m_resolverName; | |
| 49 String m_promiseName; | |
| 50 | |
| 51 // FIXME: When isolated worlds are supported replace this with a | |
| 52 // set of wrappers. | |
| 53 ScopedPersistent<v8::Object> m_mainWorldWrapper; | |
| 54 }; | |
| 55 | |
| 56 } // namespace WebCore | |
| 57 | |
| 58 #endif // ScriptPromisePropertyBase_h | |
| OLD | NEW |