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

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

Issue 300393002: Merge DevTools Refactor CL to Blink36 (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/1985
Patch Set: 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 48
48 // 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
49 // value. 50 // value.
50 // 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
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 178
178 AbstractScriptValue* scriptValue() const 179 AbstractScriptValue* scriptValue() const
179 { 180 {
180 return m_implScriptValue.get(); 181 return m_implScriptValue.get();
181 } 182 }
182 183
183 private: 184 private:
184 RefPtr<AbstractScriptValue> m_implScriptValue; 185 RefPtr<AbstractScriptValue> m_implScriptValue;
185 }; 186 };
186 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 {
vsm 2014/06/03 14:24:49 ASSERT(m_isJavaScript) ?
Jacob 2014/06/03 20:23:12 Done.
218 return m_scriptValue;
219 }
220
221 Dart_StackTrace asDart() const
222 {
vsm 2014/06/03 14:24:49 ASSERT(!m_isJavaScript) ?
Jacob 2014/06/03 20:23:12 Done.
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;
rmacnak 2014/06/03 17:32:34 RefPtr<V8ScriptValue>
Jacob 2014/06/03 20:23:13 Done.
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; }
vsm 2014/06/03 14:24:49 Ditto on asserts for these two.
Jacob 2014/06/03 20:23:13 Done.
263
264 private:
265 bool m_isJavaScript;
266 ScriptValue m_scriptValue;
rmacnak 2014/06/03 17:32:34 RefPtr<V8ScriptValue>
Jacob 2014/06/03 20:23:12 Done.
267 Dart_ActivationFrame m_dartActivationFrame;
268 };
269
187 } // namespace WebCore 270 } // namespace WebCore
188 271
189 #endif // ScriptValue_h 272 #endif // ScriptValue_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698