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

Side by Side Diff: sky/engine/bindings-dart/core/dart/DartScriptPromise.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 DartScriptPromise_h
6 #define DartScriptPromise_h
7
8 #include "bindings/common/AbstractScriptPromise.h"
9 #include "bindings/common/ScriptValue.h"
10 #include "bindings/core/v8/ScriptFunction.h"
11 #include "core/dom/ExceptionCode.h"
12 #include "platform/heap/Handle.h"
13 #include "wtf/PassOwnPtr.h"
14 #include "wtf/PassRefPtr.h"
15 #include "wtf/text/WTFString.h"
16 #include <dart_api.h>
17
18 namespace blink {
19
20 class DOMException;
21 class ExceptionState;
22
23 class DartScriptPromise FINAL : public AbstractScriptPromise {
24 WTF_MAKE_NONCOPYABLE(DartScriptPromise);
25 public:
26 static PassRefPtr<DartScriptPromise> create()
27 {
28 return adoptRef(new DartScriptPromise());
29 }
30
31 static PassRefPtr<DartScriptPromise> create(DartScriptState* scriptState, Da rt_Handle promise)
32 {
33 return adoptRef(new DartScriptPromise(scriptState, promise));
34 }
35
36 static void returnToDart(Dart_NativeArguments args, ScriptPromise promise, b ool autoScope);
37
38 private:
39 // Constructs an empty promise.
40 DartScriptPromise() : m_scriptState() , m_value(0) { }
41
42 // Constructs a ScriptPromise from |promise|.
43 // If |promise| is not a Promise object, throws a v8 TypeError.
44 DartScriptPromise(DartScriptState*, Dart_Handle promise);
45
46 public:
47 PassRefPtr<AbstractScriptPromise> then(PassOwnPtr<ScriptFunction> onFulfille d, PassOwnPtr<ScriptFunction> onRejected = PassOwnPtr<ScriptFunction>());
48
49 bool isDartScriptPromise() const { return true; }
50
51 bool equals(PassRefPtr<AbstractScriptPromise> other) const
52 {
53 if (!other->isDartScriptPromise())
54 return false;
55 return *this == *static_cast<DartScriptPromise*>(other.get());
56 }
57
58 bool isObject() const
59 {
60 ASSERT(!isEmpty());
61 return true;
62 }
63
64 bool isNull() const
65 {
66 ASSERT(!isEmpty());
67 return Dart_IsNull(dartValue());
68 }
69
70 bool isUndefinedOrNull() const
71 {
72 ASSERT(!isEmpty());
73 return Dart_IsNull(dartValue());
74 }
75
76 bool isEmpty() const
77 {
78 return !dartValue();
79 }
80
81 void clear()
82 {
83 m_value.clear();
84 }
85
86 bool operator==(const DartScriptPromise& value) const
87 {
88 return Dart_IdentityEquals(dartValue(), value.dartValue());
89 }
90
91 bool operator!=(const DartScriptPromise& value) const
92 {
93 return !operator==(value);
94 }
95
96 Dart_Handle dartValue() const { return m_value.value(); }
97
98 v8::Handle<v8::Value> v8Value() const
99 {
100 RELEASE_ASSERT_NOT_REACHED();
101 return v8::Handle<v8::Value>();
102 }
103
104 v8::Isolate* isolate() const
105 {
106 RELEASE_ASSERT_NOT_REACHED();
107 return m_scriptState->v8ScriptState()->isolate();
108 }
109
110 private:
111 RefPtr<DartScriptState> m_scriptState;
112 DartPersistentValue m_value;
113 };
114
115 } // namespace blink
116
117 #endif // DartScriptPromise_h
OLDNEW
« 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