Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 DartInjectedScript_h | |
| 32 #define DartInjectedScript_h | |
| 33 | |
| 34 #include "InspectorTypeBuilder.h" | |
| 35 #include "bindings/v8/ScriptObject.h" | |
| 36 #include "core/inspector/InjectedScript.h" | |
| 37 #include "core/inspector/InjectedScriptBase.h" | |
| 38 #include "core/inspector/InjectedScriptManager.h" | |
| 39 #include "core/inspector/ScriptArguments.h" | |
| 40 #include "wtf/Forward.h" | |
| 41 #include "wtf/HashMap.h" | |
| 42 | |
| 43 namespace WebCore { | |
| 44 | |
| 45 class DartScriptState; | |
| 46 | |
| 47 class DartDebuggerObject { | |
| 48 public: | |
| 49 enum Type { | |
|
vsm
2014/06/03 14:24:49
Consider "Kind".
Jacob
2014/06/03 20:23:13
That is better. Switched it here and elsewhere in
| |
| 50 Object, | |
| 51 ObjectClass, | |
|
vsm
2014/06/03 14:24:49
What's the difference between ObjectClass, Class,
Jacob
2014/06/03 20:23:13
I'll add a FIXME. Having those three kinds is a b
| |
| 52 Function, | |
| 53 Method, | |
| 54 Class, | |
| 55 StaticClass, | |
| 56 Library, | |
| 57 CurrentLibrary, | |
| 58 Libraries, | |
|
rmacnak
2014/06/04 00:45:13
Isolate?
| |
| 59 LocalVariables, | |
| 60 Error | |
| 61 }; | |
| 62 | |
| 63 DartDebuggerObject(Dart_PersistentHandle, const String& objectGroup, Type); | |
|
vsm
2014/06/03 14:24:49
What is objectGroup here? We use the term for GC
Jacob
2014/06/03 20:23:13
this is just the devtools notion of an object grou
| |
| 64 | |
| 65 const String& group() const { return m_group; } | |
| 66 Dart_PersistentHandle persistentHandle() const { return m_handle; } | |
| 67 Dart_Handle handle() const { return m_handle; } | |
| 68 Type type() const { return m_type; } | |
| 69 | |
| 70 private: | |
| 71 Dart_PersistentHandle m_handle; | |
|
vsm
2014/06/03 14:24:49
Free handle in destructor?
Jacob
2014/06/03 20:23:13
good catch. done. cleaned up DartDebuggerObject fr
| |
| 72 String m_group; | |
| 73 Type m_type; | |
| 74 }; | |
| 75 | |
| 76 class DartInjectedScript : public InjectedScript { | |
| 77 public: | |
| 78 DartInjectedScript(); | |
| 79 virtual ~DartInjectedScript(); | |
| 80 | |
| 81 virtual bool isJavaScript() const { return false; } | |
| 82 virtual const String& name() const { return m_name; } | |
| 83 | |
| 84 virtual void evaluate(ErrorString*, | |
| 85 const String& expression, | |
| 86 const String& objectGroup, | |
| 87 bool includeCommandLineAPI, | |
| 88 bool returnByValue, | |
| 89 bool generatePreview, | |
| 90 RefPtr<TypeBuilder::Runtime::RemoteObject>* result, | |
| 91 TypeBuilder::OptOutput<bool>* wasThrown); | |
| 92 virtual void callFunctionOn(ErrorString*, | |
| 93 const String& objectId, | |
| 94 const String& expression, | |
| 95 const String& arguments, | |
| 96 bool returnByValue, | |
| 97 bool generatePreview, | |
| 98 RefPtr<TypeBuilder::Runtime::RemoteObject>* result, | |
| 99 TypeBuilder::OptOutput<bool>* wasThrown); | |
| 100 virtual void evaluateOnCallFrame(ErrorString*, | |
| 101 const StackTrace& callFrames, | |
| 102 const Vector<StackTrace>& asyncCallStacks, | |
| 103 const String& callFrameId, | |
| 104 const String& expression, | |
| 105 const String& objectGroup, | |
| 106 bool includeCommandLineAPI, | |
| 107 bool returnByValue, | |
| 108 bool generatePreview, | |
| 109 RefPtr<TypeBuilder::Runtime::RemoteObject>* result, | |
| 110 TypeBuilder::OptOutput<bool>* wasThrown); | |
| 111 virtual void getCompletionsOnCallFrame( | |
| 112 ErrorString*, | |
| 113 const StackTrace& callFrames, | |
| 114 const Vector<StackTrace>& asyncCallStacks, | |
| 115 const String& callFrameId, | |
| 116 const String& expression, | |
| 117 RefPtr<TypeBuilder::Array<String> >* result); | |
| 118 virtual void restartFrame(ErrorString*, const StackTrace& callFrames, const String& callFrameId, RefPtr<JSONObject>* result); | |
| 119 virtual void getStepInPositions(ErrorString*, const StackTrace& callFrames, const String& callFrameId, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::Loca tion> >& positions); | |
| 120 virtual void setVariableValue(ErrorString*, const StackTrace& callFrames, co nst String* callFrameIdOpt, const String* functionObjectIdOpt, int scopeNumber, const String& variableName, const String& newValueStr); | |
| 121 virtual void getFunctionDetails(ErrorString*, const String& functionId, RefP tr<TypeBuilder::Debugger::FunctionDetails>* result); | |
| 122 virtual void getCompletions(ErrorString*, const String& expression, RefPtr<T ypeBuilder::Array<String> >* out_result); | |
| 123 virtual void getProperties(ErrorString*, const String& objectId, bool ownPro perties, bool accessorPropertiesOnly, RefPtr<TypeBuilder::Array<TypeBuilder::Run time::PropertyDescriptor> >* result); | |
| 124 virtual void getInternalProperties(ErrorString*, const String& objectId, Ref Ptr<TypeBuilder::Array<TypeBuilder::Runtime::InternalPropertyDescriptor> >* resu lt); | |
| 125 virtual void getProperty(ErrorString*, const String& objectId, const RefPtr< JSONArray>& propertyPath, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, Ty peBuilder::OptOutput<bool>* wasThrown); | |
| 126 | |
| 127 virtual Node* nodeForObjectId(const String& objectId); | |
| 128 virtual void releaseObject(const String& objectId); | |
| 129 | |
| 130 virtual PassRefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> > wr apCallFrames(const StackTrace&, int asyncOrdinal); | |
| 131 | |
| 132 virtual PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapObject(const Scri ptValue&, const String& groupName, bool generatePreview = false); | |
| 133 virtual PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapTable(const Scrip tValue& table, const ScriptValue& columns); | |
| 134 virtual ActivationFrame findCallFrameById(ErrorString*, const StackTrace& to pCallFrame, const String& callFrameId); | |
| 135 | |
| 136 virtual void releaseObjectGroup(const String&); | |
| 137 | |
| 138 virtual bool isEmpty() const { return !m_scriptState; } | |
| 139 | |
| 140 virtual ScriptState* scriptState() const; | |
| 141 | |
| 142 PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapDartObject(Dart_Handle, c onst String& groupName, bool generatePreview = false); | |
| 143 | |
| 144 bool canAccessInspectedWindow() const; | |
| 145 | |
| 146 private: | |
| 147 Dart_Handle library(); | |
| 148 | |
| 149 friend class InjectedScriptModule; | |
| 150 friend InjectedScript& InjectedScriptManager::injectedScriptFor(ScriptState* ); | |
| 151 DartInjectedScript(DartScriptState*, InspectedStateAccessCheck, int injected ScriptId, InjectedScriptHost*); | |
| 152 | |
| 153 bool validateObjectId(const String& objectId); | |
| 154 | |
| 155 PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapDartHandle(Dart_Handle, D artDebuggerObject::Type, const String& groupName, bool generatePreview); | |
| 156 | |
| 157 DartDebuggerObject::Type inferType(Dart_Handle); | |
| 158 | |
| 159 String cacheObject(Dart_Handle, const String& objectGroup, DartDebuggerObjec t::Type); | |
| 160 DartDebuggerObject* lookupObject(const String& objectId); | |
| 161 | |
| 162 void evaluateAndPackageResult(Dart_Handle target, const String& rawExpressio n, Dart_Handle localVariables, bool includeCommandLineAPI, const String& objectG roup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder ::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); | |
| 163 Dart_Handle evaluateHelper(Dart_Handle target, const String& rawExpression, Dart_Handle localVariables, bool includeCommandLineAPI, Dart_Handle& exception); | |
| 164 | |
| 165 void packageResult(Dart_Handle, DartDebuggerObject::Type, const String& obje ctGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuil der::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); | |
| 166 void packageObjectResult(Dart_Handle, const String& objectGroup, ErrorString *, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::Remote Object>* result, TypeBuilder::OptOutput<bool>* wasThrown); | |
| 167 void packageObjectClassResult(Dart_Handle, const String& objectGroup, ErrorS tring*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::R emoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); | |
| 168 void packageLibraryResult(Dart_Handle, DartDebuggerObject::Type, const Strin g& objectGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<T ypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThr own); | |
| 169 void packageLibrariesResult(Dart_Handle, const String& objectGroup, ErrorStr ing*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::Rem oteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); | |
| 170 void packageClassResult(Dart_Handle, DartDebuggerObject::Type, const String& objectGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<Typ eBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrow n); | |
| 171 void packageFunctionResult(Dart_Handle, const String& objectGroup, ErrorStri ng*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::Remo teObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); | |
| 172 void packageMethodResult(Dart_Handle, const String& objectGroup, ErrorString *, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::Remote Object>* result, TypeBuilder::OptOutput<bool>* wasThrown); | |
| 173 void packageLocalVariablesResult(Dart_Handle, const String& objectGroup, Err orString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime ::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); | |
| 174 void packageErrorResult(Dart_Handle, const String& objectGroup, ErrorString* , bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteO bject>* result, TypeBuilder::OptOutput<bool>* wasThrown); | |
| 175 | |
| 176 String getCallFrameId(int ordinal, int asyncOrdinal); | |
| 177 Dart_ActivationFrame callFrameForId(const StackTrace& callFrames, const Vect or<StackTrace>& asyncCallStacks, const String& callFrameId); | |
| 178 | |
| 179 Dart_Handle consoleApi(); | |
| 180 | |
| 181 String m_name; | |
| 182 InspectedStateAccessCheck m_inspectedStateAccessCheck; | |
| 183 | |
| 184 typedef HashMap<String, Vector<String>* > ObjectGroupMap; | |
| 185 ObjectGroupMap m_objectGroups; | |
| 186 | |
| 187 typedef HashMap<String, DartDebuggerObject*> DebuggerObjectMap; | |
|
vsm
2014/06/03 14:24:49
Unless these two maps can have NULL values, probab
Jacob
2014/06/03 20:23:13
eliminated the ptr from ObjectGroupMap.
DartDebugg
| |
| 188 DebuggerObjectMap m_objects; | |
| 189 | |
| 190 DartScriptState* m_scriptState; | |
| 191 | |
| 192 size_t m_nextObjectId; | |
| 193 int m_injectedScriptId; | |
| 194 InjectedScriptHost* m_host; | |
| 195 Dart_PersistentHandle m_consoleApi; | |
| 196 }; | |
| 197 | |
| 198 } // namespace WebCore | |
| 199 | |
| 200 #endif | |
| OLD | NEW |