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

Unified Diff: sky/engine/bindings-dart/core/dart/DartScriptPromise.h

Issue 875013003: Import Dart bindings as of Blink r188698. This merely copies the files over and does not attach any… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: sky/engine/bindings-dart/core/dart/DartScriptPromise.h
diff --git a/sky/engine/bindings-dart/core/dart/DartScriptPromise.h b/sky/engine/bindings-dart/core/dart/DartScriptPromise.h
new file mode 100644
index 0000000000000000000000000000000000000000..ef00feedbfad9c1fec39f387487ebe3c6dcb7bf8
--- /dev/null
+++ b/sky/engine/bindings-dart/core/dart/DartScriptPromise.h
@@ -0,0 +1,117 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef DartScriptPromise_h
+#define DartScriptPromise_h
+
+#include "bindings/common/AbstractScriptPromise.h"
+#include "bindings/common/ScriptValue.h"
+#include "bindings/core/v8/ScriptFunction.h"
+#include "core/dom/ExceptionCode.h"
+#include "platform/heap/Handle.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/text/WTFString.h"
+#include <dart_api.h>
+
+namespace blink {
+
+class DOMException;
+class ExceptionState;
+
+class DartScriptPromise FINAL : public AbstractScriptPromise {
+ WTF_MAKE_NONCOPYABLE(DartScriptPromise);
+public:
+ static PassRefPtr<DartScriptPromise> create()
+ {
+ return adoptRef(new DartScriptPromise());
+ }
+
+ static PassRefPtr<DartScriptPromise> create(DartScriptState* scriptState, Dart_Handle promise)
+ {
+ return adoptRef(new DartScriptPromise(scriptState, promise));
+ }
+
+ static void returnToDart(Dart_NativeArguments args, ScriptPromise promise, bool autoScope);
+
+private:
+ // Constructs an empty promise.
+ DartScriptPromise() : m_scriptState() , m_value(0) { }
+
+ // Constructs a ScriptPromise from |promise|.
+ // If |promise| is not a Promise object, throws a v8 TypeError.
+ DartScriptPromise(DartScriptState*, Dart_Handle promise);
+
+public:
+ PassRefPtr<AbstractScriptPromise> then(PassOwnPtr<ScriptFunction> onFulfilled, PassOwnPtr<ScriptFunction> onRejected = PassOwnPtr<ScriptFunction>());
+
+ bool isDartScriptPromise() const { return true; }
+
+ bool equals(PassRefPtr<AbstractScriptPromise> other) const
+ {
+ if (!other->isDartScriptPromise())
+ return false;
+ return *this == *static_cast<DartScriptPromise*>(other.get());
+ }
+
+ bool isObject() const
+ {
+ ASSERT(!isEmpty());
+ return true;
+ }
+
+ bool isNull() const
+ {
+ ASSERT(!isEmpty());
+ return Dart_IsNull(dartValue());
+ }
+
+ bool isUndefinedOrNull() const
+ {
+ ASSERT(!isEmpty());
+ return Dart_IsNull(dartValue());
+ }
+
+ bool isEmpty() const
+ {
+ return !dartValue();
+ }
+
+ void clear()
+ {
+ m_value.clear();
+ }
+
+ bool operator==(const DartScriptPromise& value) const
+ {
+ return Dart_IdentityEquals(dartValue(), value.dartValue());
+ }
+
+ bool operator!=(const DartScriptPromise& value) const
+ {
+ return !operator==(value);
+ }
+
+ Dart_Handle dartValue() const { return m_value.value(); }
+
+ v8::Handle<v8::Value> v8Value() const
+ {
+ RELEASE_ASSERT_NOT_REACHED();
+ return v8::Handle<v8::Value>();
+ }
+
+ v8::Isolate* isolate() const
+ {
+ RELEASE_ASSERT_NOT_REACHED();
+ return m_scriptState->v8ScriptState()->isolate();
+ }
+
+private:
+ RefPtr<DartScriptState> m_scriptState;
+ DartPersistentValue m_value;
+};
+
+} // namespace blink
+
+#endif // DartScriptPromise_h
« no previous file with comments | « sky/engine/bindings-dart/core/dart/DartScriptDebugServer.cpp ('k') | sky/engine/bindings-dart/core/dart/DartScriptPromise.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698