Index: Source/bindings/v8/ScriptPromise.h |
diff --git a/Source/core/testing/GCObservation.h b/Source/bindings/v8/ScriptPromise.h |
similarity index 63% |
copy from Source/core/testing/GCObservation.h |
copy to Source/bindings/v8/ScriptPromise.h |
index 469656acc669dba1a3a051e6460eab4243ddff47..34f801975eca5622dd12fe5952c681fa872462b7 100644 |
--- a/Source/core/testing/GCObservation.h |
+++ b/Source/bindings/v8/ScriptPromise.h |
@@ -28,35 +28,65 @@ |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef GCObservation_h |
-#define GCObservation_h |
+#ifndef ScriptPromise_h |
+#define ScriptPromise_h |
#include "bindings/v8/ScopedPersistent.h" |
-#include "wtf/PassRefPtr.h" |
-#include "wtf/RefCounted.h" |
+#include "bindings/v8/ScriptValue.h" |
+#include "bindings/v8/V8ScriptRunner.h" |
#include <v8.h> |
namespace WebCore { |
-class GCObservation : public RefCounted<GCObservation> { |
+class ScriptPromise { |
yhirano
2013/09/02 11:58:17
Can ScriptPromise be a subclass of ScriptValue?
yusukesuzuki
2013/09/03 08:33:11
Done.
yusukesuzuki
2013/09/04 06:37:00
ScriptPromise may have different semantics from Sc
|
public: |
- static PassRefPtr<GCObservation> create(v8::Handle<v8::Value> observedValue) { return adoptRef(new GCObservation(observedValue)); } |
- ~GCObservation() { } |
+ ScriptPromise() |
+ : m_promise() |
+ { |
+ } |
- // Caution: It is only feasible to determine whether an object was |
- // "near death"; it may have been kept alive through a weak |
- // handle. After reaching near-death, having been collected is the |
- // common case. |
- bool wasCollected() const { return m_collected; } |
- void setWasCollected(); |
+ explicit ScriptPromise(ScriptValue promise) |
+ : m_promise(promise) |
+ { |
+ ASSERT(!m_promise.hasNoValue()); |
+ } |
-private: |
- explicit GCObservation(v8::Handle<v8::Value>); |
+ explicit ScriptPromise(v8::Handle<v8::Value> promise) |
+ : m_promise(promise) |
+ { |
+ ASSERT(!m_promise.hasNoValue()); |
+ } |
+ |
+ bool isObject() const |
+ { |
+ return m_promise.isObject(); |
+ } |
+ |
+ bool isNull() const |
+ { |
+ return m_promise.isNull(); |
+ } |
+ |
+ bool isUndefinedOrNull() const |
+ { |
+ return m_promise.isUndefined() || m_promise.isNull(); |
+ } |
- ScopedPersistent<v8::Value> m_observed; |
- bool m_collected; |
+ v8::Handle<v8::Value> v8Value() const |
+ { |
+ return m_promise.v8Value(); |
+ } |
+ |
+ void clear() |
+ { |
+ m_promise.clear(); |
+ } |
+ |
+private: |
+ ScriptValue m_promise; |
haraken
2013/09/02 21:44:21
Why can't you use ScopedPersistent?
|
}; |
-} |
+} // namespace WebCore |
+ |
-#endif // GCObservation_h |
+#endif // ScriptPromise_h |