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/v8/ScopedPersistent.h" | |
| 9 #include "bindings/v8/ScriptPromise.h" | |
| 10 #include "core/dom/ActiveDOMObject.h" | |
| 11 #include "wtf/OwnPtr.h" | |
| 12 #include "wtf/RefCounted.h" | |
| 13 #include "wtf/Vector.h" | |
| 14 #include <v8.h> | |
| 15 | |
| 16 namespace WebCore { | |
| 17 | |
| 18 class ExecutionContext; | |
| 19 | |
| 20 class ScriptPromisePropertyBase : public ActiveDOMObject, public RefCountedWillB eGarbageCollected<ScriptPromisePropertyBase> { | |
| 21 public: | |
| 22 virtual ~ScriptPromisePropertyBase(); | |
| 23 | |
| 24 enum State { | |
| 25 Pending, | |
| 26 Resolved, | |
| 27 Rejected, | |
| 28 }; | |
| 29 State state() { return m_state; } | |
|
yhirano
2014/07/01 04:38:14
const
| |
| 30 | |
| 31 ScriptPromise promise(DOMWrapperWorld&); | |
| 32 | |
| 33 protected: | |
| 34 ScriptPromisePropertyBase(ExecutionContext*, const char* name); | |
| 35 | |
| 36 void settle(State targetState); | |
| 37 | |
| 38 virtual v8::Handle<v8::Object> holder(v8::Handle<v8::Object> creationContext , v8::Isolate*) = 0; | |
| 39 virtual v8::Handle<v8::Value> resolvedValue(v8::Handle<v8::Object> creationC ontext, v8::Isolate*) = 0; | |
| 40 virtual v8::Handle<v8::Value> rejectedValue(v8::Handle<v8::Object> creationC ontext, v8::Isolate*) = 0; | |
| 41 | |
| 42 private: | |
| 43 void resolveOrReject(v8::Handle<v8::Promise::Resolver>); | |
| 44 void enqueuePendingAction(v8::Handle<v8::Promise::Resolver>, v8::Handle<v8:: Value>, State); | |
| 45 | |
| 46 // ActiveDOMObject overrides | |
| 47 virtual void resume() OVERRIDE; | |
| 48 virtual void stop() OVERRIDE; | |
| 49 | |
| 50 v8::Isolate* m_isolate; | |
| 51 State m_state; | |
| 52 bool m_inResume; | |
| 53 ScopedPersistent<v8::String> m_resolverName; | |
| 54 ScopedPersistent<v8::String> m_promiseName; | |
| 55 | |
| 56 class PendingAction; | |
| 57 typedef Vector<OwnPtr<PendingAction> > PendingActionList; | |
| 58 PendingActionList m_pending; | |
| 59 | |
| 60 // FIXME: When isolated worlds are supported replace this with a | |
| 61 // set of wrappers. | |
| 62 ScopedPersistent<v8::Object> m_mainWorldWrapper; | |
| 63 }; | |
| 64 | |
| 65 } // namespace WebCore | |
| 66 | |
| 67 #endif // ScriptPromisePropertyBase_h | |
| OLD | NEW |