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

Side by Side Diff: sky/engine/bindings-dart/common/ScriptState.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 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef ScriptState_h
32 #define ScriptState_h
33
34 #include "bindings/common/AbstractScriptValue.h"
35 #include "platform/heap/Handle.h"
36 #include "wtf/Assertions.h"
37 #include "wtf/Noncopyable.h"
38 #include "wtf/RefCounted.h"
39
40 namespace blink {
41
42 class AbstractScriptPromiseResolver;
43 class AbstractScriptStateProtectingContext;
44 class DOMException;
45 class DOMWrapperWorld;
46 class ExecutionContext;
47 class IDBAny;
48 class IDBKey;
49 class LocalDOMWindow;
50 class LocalFrame;
51 class SharedBuffer;
52 class ScriptPromiseResolver;
53 class V8ScriptState;
54 class WebBlobInfo;
55
56 class ScriptState : public RefCounted<ScriptState> {
57 WTF_MAKE_NONCOPYABLE(ScriptState);
58 public:
59 virtual ~ScriptState() { }
60
61 virtual bool isV8ScriptState() const { return false; }
62 virtual bool isDartScriptState() const { return false; }
63 virtual V8ScriptState* v8ScriptState() = 0;
64
65 virtual ExecutionContext* executionContext() const = 0;
66 virtual LocalDOMWindow* domWindow() const = 0;
67 virtual LocalDOMWindow* callingDOMWindow() const = 0;
68
69 virtual PassRefPtr<AbstractScriptValue> createNull() = 0;
70 virtual PassRefPtr<AbstractScriptValue> createUndefined() = 0;
71 virtual PassRefPtr<AbstractScriptValue> createBoolean(bool value) = 0;
72 virtual PassRefPtr<AbstractScriptPromise> createEmptyPromise() = 0;
73 virtual PassRefPtr<AbstractScriptPromise> createRejectedPromise(PassRefPtrWi llBeRawPtr<DOMException>) = 0;
74 virtual PassRefPtr<AbstractScriptPromise> createPromiseRejectedWithTypeError (const String& message) = 0;
75
76 virtual PassOwnPtr<AbstractScriptPromiseResolver> createPromiseResolver(Scri ptPromiseResolver*) = 0;
77 virtual AbstractScriptStateProtectingContext* createProtectingContext() = 0;
78 virtual PassRefPtr<AbstractScriptValue> idbAnyToScriptValue(IDBAny*) = 0;
79 virtual PassRefPtr<AbstractScriptValue> idbKeyToScriptValue(IDBKey*) = 0;
80
81 virtual const String* name() = 0;
82 virtual intptr_t libraryId() = 0;
83 virtual bool isJavaScript() = 0;
84
85 #ifndef NDEBUG
86 virtual void assertPrimaryKeyValidOrInjectable(PassRefPtr<SharedBuffer>, con st Vector<blink::WebBlobInfo>*, IDBKey*, const IDBKeyPath&) = 0;
87 #endif
88
89 protected:
90 ScriptState() { }
91 };
92
93 class AbstractScriptStateProtectingContext {
94 public:
95 virtual ~AbstractScriptStateProtectingContext() { }
96 virtual ScriptState* get() const = 0;
97 virtual void clear() = 0;
98 protected:
99 AbstractScriptStateProtectingContext() { }
100 };
101
102 // ScriptStateProtectingContext keeps the context (V8) or isolate (Dart) associa ted with the ScriptState alive.
103 // You need to call clear() once you no longer need the context. Otherwise, the context will leak.
104 class ScriptStateProtectingContext {
105 WTF_MAKE_NONCOPYABLE(ScriptStateProtectingContext);
106 public:
107 ScriptStateProtectingContext(ScriptState* scriptState)
108 : m_implProtectingContext(scriptState ? scriptState->createProtectingCon text() : 0) { }
109
110 ~ScriptStateProtectingContext()
111 {
112 clear();
113 }
114
115 ScriptState* operator->() const
116 {
117 return m_implProtectingContext ? m_implProtectingContext->get() : 0;
118 }
119 ScriptState* get() const
120 {
121 return m_implProtectingContext ? m_implProtectingContext->get() : 0;
122 }
123 void clear()
124 {
125 if (m_implProtectingContext) {
126 m_implProtectingContext->clear();
127 delete m_implProtectingContext;
128 m_implProtectingContext = 0;
129 }
130 }
131 private:
132 AbstractScriptStateProtectingContext* m_implProtectingContext;
133 };
134
135 } // namespace blink
136
137 #endif // ScriptState_h
OLDNEW
« no previous file with comments | « sky/engine/bindings-dart/common/ScriptPromiseResolverIncludes.h ('k') | sky/engine/bindings-dart/common/ScriptValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698