Chromium Code Reviews| Index: Source/bindings/dart/DartInjectedScript.h |
| diff --git a/Source/bindings/dart/DartInjectedScript.h b/Source/bindings/dart/DartInjectedScript.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..71dab0ea56a5e6282237969c822eeb811b89643e |
| --- /dev/null |
| +++ b/Source/bindings/dart/DartInjectedScript.h |
| @@ -0,0 +1,200 @@ |
| +/* |
| + * Copyright (C) 2014 Google Inc. All rights reserved. |
| + * |
| + * Redistribution and use in source and binary forms, with or without |
| + * modification, are permitted provided that the following conditions are |
| + * met: |
| + * |
| + * * Redistributions of source code must retain the above copyright |
| + * notice, this list of conditions and the following disclaimer. |
| + * * Redistributions in binary form must reproduce the above |
| + * copyright notice, this list of conditions and the following disclaimer |
| + * in the documentation and/or other materials provided with the |
| + * distribution. |
| + * * Neither the name of Google Inc. nor the names of its |
| + * contributors may be used to endorse or promote products derived from |
| + * this software without specific prior written permission. |
| + * |
| + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| + */ |
| + |
| +#ifndef DartInjectedScript_h |
| +#define DartInjectedScript_h |
| + |
| +#include "InspectorTypeBuilder.h" |
| +#include "bindings/v8/ScriptObject.h" |
| +#include "core/inspector/InjectedScript.h" |
| +#include "core/inspector/InjectedScriptBase.h" |
| +#include "core/inspector/InjectedScriptManager.h" |
| +#include "core/inspector/ScriptArguments.h" |
| +#include "wtf/Forward.h" |
| +#include "wtf/HashMap.h" |
| + |
| +namespace WebCore { |
| + |
| +class DartScriptState; |
| + |
| +class DartDebuggerObject { |
| +public: |
| + 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
|
| + Object, |
| + 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
|
| + Function, |
| + Method, |
| + Class, |
| + StaticClass, |
| + Library, |
| + CurrentLibrary, |
| + Libraries, |
|
rmacnak
2014/06/04 00:45:13
Isolate?
|
| + LocalVariables, |
| + Error |
| + }; |
| + |
| + 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
|
| + |
| + const String& group() const { return m_group; } |
| + Dart_PersistentHandle persistentHandle() const { return m_handle; } |
| + Dart_Handle handle() const { return m_handle; } |
| + Type type() const { return m_type; } |
| + |
| +private: |
| + 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
|
| + String m_group; |
| + Type m_type; |
| +}; |
| + |
| +class DartInjectedScript : public InjectedScript { |
| +public: |
| + DartInjectedScript(); |
| + virtual ~DartInjectedScript(); |
| + |
| + virtual bool isJavaScript() const { return false; } |
| + virtual const String& name() const { return m_name; } |
| + |
| + virtual void evaluate(ErrorString*, |
| + const String& expression, |
| + const String& objectGroup, |
| + bool includeCommandLineAPI, |
| + bool returnByValue, |
| + bool generatePreview, |
| + RefPtr<TypeBuilder::Runtime::RemoteObject>* result, |
| + TypeBuilder::OptOutput<bool>* wasThrown); |
| + virtual void callFunctionOn(ErrorString*, |
| + const String& objectId, |
| + const String& expression, |
| + const String& arguments, |
| + bool returnByValue, |
| + bool generatePreview, |
| + RefPtr<TypeBuilder::Runtime::RemoteObject>* result, |
| + TypeBuilder::OptOutput<bool>* wasThrown); |
| + virtual void evaluateOnCallFrame(ErrorString*, |
| + const StackTrace& callFrames, |
| + const Vector<StackTrace>& asyncCallStacks, |
| + const String& callFrameId, |
| + const String& expression, |
| + const String& objectGroup, |
| + bool includeCommandLineAPI, |
| + bool returnByValue, |
| + bool generatePreview, |
| + RefPtr<TypeBuilder::Runtime::RemoteObject>* result, |
| + TypeBuilder::OptOutput<bool>* wasThrown); |
| + virtual void getCompletionsOnCallFrame( |
| + ErrorString*, |
| + const StackTrace& callFrames, |
| + const Vector<StackTrace>& asyncCallStacks, |
| + const String& callFrameId, |
| + const String& expression, |
| + RefPtr<TypeBuilder::Array<String> >* result); |
| + virtual void restartFrame(ErrorString*, const StackTrace& callFrames, const String& callFrameId, RefPtr<JSONObject>* result); |
| + virtual void getStepInPositions(ErrorString*, const StackTrace& callFrames, const String& callFrameId, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::Location> >& positions); |
| + virtual void setVariableValue(ErrorString*, const StackTrace& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOpt, int scopeNumber, const String& variableName, const String& newValueStr); |
| + virtual void getFunctionDetails(ErrorString*, const String& functionId, RefPtr<TypeBuilder::Debugger::FunctionDetails>* result); |
| + virtual void getCompletions(ErrorString*, const String& expression, RefPtr<TypeBuilder::Array<String> >* out_result); |
| + virtual void getProperties(ErrorString*, const String& objectId, bool ownProperties, bool accessorPropertiesOnly, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >* result); |
| + virtual void getInternalProperties(ErrorString*, const String& objectId, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::InternalPropertyDescriptor> >* result); |
| + virtual void getProperty(ErrorString*, const String& objectId, const RefPtr<JSONArray>& propertyPath, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); |
| + |
| + virtual Node* nodeForObjectId(const String& objectId); |
| + virtual void releaseObject(const String& objectId); |
| + |
| + virtual PassRefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> > wrapCallFrames(const StackTrace&, int asyncOrdinal); |
| + |
| + virtual PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapObject(const ScriptValue&, const String& groupName, bool generatePreview = false); |
| + virtual PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapTable(const ScriptValue& table, const ScriptValue& columns); |
| + virtual ActivationFrame findCallFrameById(ErrorString*, const StackTrace& topCallFrame, const String& callFrameId); |
| + |
| + virtual void releaseObjectGroup(const String&); |
| + |
| + virtual bool isEmpty() const { return !m_scriptState; } |
| + |
| + virtual ScriptState* scriptState() const; |
| + |
| + PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapDartObject(Dart_Handle, const String& groupName, bool generatePreview = false); |
| + |
| + bool canAccessInspectedWindow() const; |
| + |
| +private: |
| + Dart_Handle library(); |
| + |
| + friend class InjectedScriptModule; |
| + friend InjectedScript& InjectedScriptManager::injectedScriptFor(ScriptState*); |
| + DartInjectedScript(DartScriptState*, InspectedStateAccessCheck, int injectedScriptId, InjectedScriptHost*); |
| + |
| + bool validateObjectId(const String& objectId); |
| + |
| + PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapDartHandle(Dart_Handle, DartDebuggerObject::Type, const String& groupName, bool generatePreview); |
| + |
| + DartDebuggerObject::Type inferType(Dart_Handle); |
| + |
| + String cacheObject(Dart_Handle, const String& objectGroup, DartDebuggerObject::Type); |
| + DartDebuggerObject* lookupObject(const String& objectId); |
| + |
| + void evaluateAndPackageResult(Dart_Handle target, const String& rawExpression, Dart_Handle localVariables, bool includeCommandLineAPI, const String& objectGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); |
| + Dart_Handle evaluateHelper(Dart_Handle target, const String& rawExpression, Dart_Handle localVariables, bool includeCommandLineAPI, Dart_Handle& exception); |
| + |
| + void packageResult(Dart_Handle, DartDebuggerObject::Type, const String& objectGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); |
| + void packageObjectResult(Dart_Handle, const String& objectGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); |
| + void packageObjectClassResult(Dart_Handle, const String& objectGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); |
| + void packageLibraryResult(Dart_Handle, DartDebuggerObject::Type, const String& objectGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); |
| + void packageLibrariesResult(Dart_Handle, const String& objectGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); |
| + void packageClassResult(Dart_Handle, DartDebuggerObject::Type, const String& objectGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); |
| + void packageFunctionResult(Dart_Handle, const String& objectGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); |
| + void packageMethodResult(Dart_Handle, const String& objectGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); |
| + void packageLocalVariablesResult(Dart_Handle, const String& objectGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); |
| + void packageErrorResult(Dart_Handle, const String& objectGroup, ErrorString*, bool returnByValue, bool generatePreview, RefPtr<TypeBuilder::Runtime::RemoteObject>* result, TypeBuilder::OptOutput<bool>* wasThrown); |
| + |
| + String getCallFrameId(int ordinal, int asyncOrdinal); |
| + Dart_ActivationFrame callFrameForId(const StackTrace& callFrames, const Vector<StackTrace>& asyncCallStacks, const String& callFrameId); |
| + |
| + Dart_Handle consoleApi(); |
| + |
| + String m_name; |
| + InspectedStateAccessCheck m_inspectedStateAccessCheck; |
| + |
| + typedef HashMap<String, Vector<String>* > ObjectGroupMap; |
| + ObjectGroupMap m_objectGroups; |
| + |
| + 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
|
| + DebuggerObjectMap m_objects; |
| + |
| + DartScriptState* m_scriptState; |
| + |
| + size_t m_nextObjectId; |
| + int m_injectedScriptId; |
| + InjectedScriptHost* m_host; |
| + Dart_PersistentHandle m_consoleApi; |
| +}; |
| + |
| +} // namespace WebCore |
| + |
| +#endif |