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

Side by Side Diff: Source/bindings/common/StackTrace.h

Issue 300393002: Merge DevTools Refactor CL to Blink36 (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/1985
Patch Set: PTAL Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 20 matching lines...) Expand all
31 #ifndef ScriptValue_h 31 #ifndef ScriptValue_h
32 #define ScriptValue_h 32 #define ScriptValue_h
33 33
34 #include "bindings/common/AbstractScriptValue.h" 34 #include "bindings/common/AbstractScriptValue.h"
35 #include "bindings/dart/DartScriptValue.h" 35 #include "bindings/dart/DartScriptValue.h"
36 #include "bindings/v8/SharedPersistent.h" 36 #include "bindings/v8/SharedPersistent.h"
37 #include "bindings/v8/V8ScriptValue.h" 37 #include "bindings/v8/V8ScriptValue.h"
38 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
39 #include "wtf/RefPtr.h" 39 #include "wtf/RefPtr.h"
40 #include "wtf/text/WTFString.h" 40 #include "wtf/text/WTFString.h"
41 #include <dart_debugger_api.h>
41 #include <v8.h> 42 #include <v8.h>
42 43
43 namespace WebCore { 44 namespace WebCore {
44 45
45 class JSONValue; 46 class JSONValue;
46 class ScriptState; 47 class ScriptState;
47 class V8ScriptState;
48 48
49 // Indirection to avoid re-writing the parts of Blink that pass ScriptValue by 49 // Indirection to avoid re-writing the parts of Blink that pass ScriptValue by
50 // value. 50 // value.
51 // FIXME: Should change pass by value uses to pass by reference and use 51 // FIXME: Should change pass by value uses to pass by reference and use
52 // AbstractScriptValue directly. 52 // AbstractScriptValue directly.
53 class ScriptValue { 53 class ScriptValue {
54 public: 54 public:
55 ScriptValue() 55 ScriptValue()
56 : m_implScriptValue(V8ScriptValue::create()) 56 : m_implScriptValue(V8ScriptValue::create())
57 { 57 {
58 } 58 }
59 59
60 virtual ~ScriptValue(); 60 virtual ~ScriptValue();
61 61
62 // FIXME: This method is deprecated and will be removed soon. 62 // FIXME: This method is deprecated and will be removed soon.
63 // We should always pass a ScriptState when creating a new ScriptValue. 63 // We should always pass a ScriptState when creating a new ScriptValue.
64 ScriptValue(v8::Handle<v8::Value> value, v8::Isolate* isolate) 64 ScriptValue(v8::Handle<v8::Value> value, v8::Isolate* isolate)
65 : m_implScriptValue(V8ScriptValue::create(value, isolate)) 65 : m_implScriptValue(V8ScriptValue::create(value, isolate))
66 { 66 {
67 } 67 }
68 68
69 ScriptValue(V8ScriptState* scriptState, v8::Handle<v8::Value> value) 69 ScriptValue(ScriptState* scriptState, v8::Handle<v8::Value> value)
70 : m_implScriptValue(V8ScriptValue::create(scriptState, value)) 70 : m_implScriptValue(V8ScriptValue::create(scriptState, value))
71 { 71 {
72 } 72 }
73 73
74 ScriptValue(const ScriptValue& value) 74 ScriptValue(const ScriptValue& value)
75 : m_implScriptValue(value.m_implScriptValue) 75 : m_implScriptValue(value.m_implScriptValue)
76 { 76 {
77 } 77 }
78 78
79 ScriptValue(PassRefPtr<AbstractScriptValue> value) 79 ScriptValue(PassRefPtr<AbstractScriptValue> value)
80 : m_implScriptValue(value) 80 : m_implScriptValue(value)
81 { 81 {
82 } 82 }
83 83
84 // FIXME: Replace with an instance member of ScriptState.
85 static ScriptValue createNull()
86 {
87 return ScriptValue(V8ScriptValue::createNull());
88 }
89
90 // FIXME: Replace with an instance member of ScriptState.
91 static ScriptValue createBoolean(bool b)
92 {
93 return ScriptValue(V8ScriptValue::createBoolean(b));
94 }
95
84 ScriptState* scriptState() const 96 ScriptState* scriptState() const
85 { 97 {
86 return m_implScriptValue->scriptState(); 98 return m_implScriptValue->scriptState();
87 } 99 }
88 100
89 v8::Isolate* isolate() const 101 v8::Isolate* isolate() const
90 { 102 {
91 ASSERT(m_implScriptValue->isV8()); 103 ASSERT(m_implScriptValue->isV8());
92 return static_cast<V8ScriptValue*>(m_implScriptValue.get())->isolate(); 104 return static_cast<V8ScriptValue*>(m_implScriptValue.get())->isolate();
93 } 105 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 178
167 AbstractScriptValue* scriptValue() const 179 AbstractScriptValue* scriptValue() const
168 { 180 {
169 return m_implScriptValue.get(); 181 return m_implScriptValue.get();
170 } 182 }
171 183
172 private: 184 private:
173 RefPtr<AbstractScriptValue> m_implScriptValue; 185 RefPtr<AbstractScriptValue> m_implScriptValue;
174 }; 186 };
175 187
188 // FIXMEDART: where should we define this class that holds either a V8 or Dart
189 // stack trace?
190 class StackTrace {
191 public:
192 explicit StackTrace()
193 {
194 m_isJavaScript = true;
195 m_dartStackTrace = 0;
196 }
197
198 explicit StackTrace(const ScriptValue& stackTrace)
199 {
200 m_isJavaScript = true;
201 m_scriptValue = stackTrace;
202 m_dartStackTrace = 0;
203 }
204
205 explicit StackTrace(Dart_StackTrace stackTrace)
206 {
207 m_isJavaScript = false;
208 m_dartStackTrace = stackTrace;
209 }
210
211 bool isJavaScript() const
212 {
213 return m_isJavaScript;
214 }
215
216 ScriptValue asJavaScript() const
217 {
218 return m_scriptValue;
219 }
220
221 Dart_StackTrace asDart() const
222 {
223 return m_dartStackTrace;
224 }
225
226 bool isNull() const
227 {
228 return m_isJavaScript ? m_scriptValue.isNull() : !m_dartStackTrace;
229 }
230
231 private:
232 bool m_isJavaScript;
233 ScriptValue m_scriptValue;
234 Dart_StackTrace m_dartStackTrace;
235 };
236
237 // FIXMEDART: where should we define this class that holds either a V8 or Dart
238 // activation frame?
239 class ActivationFrame {
240 public:
241 explicit ActivationFrame()
242 {
243 m_isJavaScript = true;
244 m_dartActivationFrame = 0;
245 }
246
247 explicit ActivationFrame(const ScriptValue& activationFrame)
248 {
249 m_isJavaScript = true;
250 m_scriptValue = activationFrame;
251 m_dartActivationFrame = 0;
252 }
253
254 explicit ActivationFrame(Dart_ActivationFrame activationFrame)
255 {
256 m_isJavaScript = false;
257 m_dartActivationFrame = activationFrame;
258 }
259
260 bool isJavaScript() const { return m_isJavaScript; }
261 ScriptValue asJavaScript() const { return m_scriptValue; }
262 Dart_ActivationFrame asDart() const { return m_dartActivationFrame; }
263
264 private:
265 bool m_isJavaScript;
266 ScriptValue m_scriptValue;
267 Dart_ActivationFrame m_dartActivationFrame;
268 };
269
176 } // namespace WebCore 270 } // namespace WebCore
177 271
178 #endif // ScriptValue_h 272 #endif // ScriptValue_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698