Changeset 126028 in webkit


Ignore:
Timestamp:
Aug 20, 2012 8:05:09 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: [WebGL] Add minimum transport protocol from backend to frontend
https://bugs.webkit.org/show_bug.cgi?id=88973

Patch by Andrey Adaikin <aandrey@chromium.org> on 2012-08-20
Reviewed by Pavel Feldman.

Added the following protocol methods to communicate with the WebGL injected
module: captureFrame, getTraceLog, dropTraceLog, replayTraceLog.

  • inspector/CodeGeneratorInspector.py:
  • inspector/InjectedScriptWebGLModule.cpp:

(WebCore::InjectedScriptWebGLModule::captureFrame):
(WebCore):
(WebCore::InjectedScriptWebGLModule::dropTraceLog):
(WebCore::InjectedScriptWebGLModule::getTraceLog):
(WebCore::InjectedScriptWebGLModule::replayTraceLog):

  • inspector/InjectedScriptWebGLModule.h:

(InjectedScriptWebGLModule):

  • inspector/Inspector.json:
  • inspector/InspectorController.cpp:

(WebCore::InspectorController::InspectorController):

  • inspector/InspectorWebGLAgent.cpp:

(WebCore::InspectorWebGLAgent::InspectorWebGLAgent):
(WebCore::InspectorWebGLAgent::dropTraceLog):
(WebCore):
(WebCore::InspectorWebGLAgent::captureFrame):
(WebCore::InspectorWebGLAgent::getTraceLog):
(WebCore::InspectorWebGLAgent::replayTraceLog):

  • inspector/InspectorWebGLAgent.h:

(WebCore):
(WebCore::InspectorWebGLAgent::create):
(InspectorWebGLAgent):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r126026 r126028  
     12012-08-20  Andrey Adaikin  <aandrey@chromium.org>
     2
     3        Web Inspector: [WebGL] Add minimum transport protocol from backend to frontend
     4        https://bugs.webkit.org/show_bug.cgi?id=88973
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Added the following protocol methods to communicate with the WebGL injected
     9        module: captureFrame, getTraceLog, dropTraceLog, replayTraceLog.
     10
     11        * inspector/CodeGeneratorInspector.py:
     12        * inspector/InjectedScriptWebGLModule.cpp:
     13        (WebCore::InjectedScriptWebGLModule::captureFrame):
     14        (WebCore):
     15        (WebCore::InjectedScriptWebGLModule::dropTraceLog):
     16        (WebCore::InjectedScriptWebGLModule::getTraceLog):
     17        (WebCore::InjectedScriptWebGLModule::replayTraceLog):
     18        * inspector/InjectedScriptWebGLModule.h:
     19        (InjectedScriptWebGLModule):
     20        * inspector/Inspector.json:
     21        * inspector/InspectorController.cpp:
     22        (WebCore::InspectorController::InspectorController):
     23        * inspector/InspectorWebGLAgent.cpp:
     24        (WebCore::InspectorWebGLAgent::InspectorWebGLAgent):
     25        (WebCore::InspectorWebGLAgent::dropTraceLog):
     26        (WebCore):
     27        (WebCore::InspectorWebGLAgent::captureFrame):
     28        (WebCore::InspectorWebGLAgent::getTraceLog):
     29        (WebCore::InspectorWebGLAgent::replayTraceLog):
     30        * inspector/InspectorWebGLAgent.h:
     31        (WebCore):
     32        (WebCore::InspectorWebGLAgent::create):
     33        (InspectorWebGLAgent):
     34
    1352012-08-20  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
    236
  • trunk/Source/WebCore/inspector/CodeGeneratorInspector.py

    r125248 r126028  
    5959
    6060TYPES_WITH_RUNTIME_CAST_SET = frozenset(["Runtime.RemoteObject", "Runtime.PropertyDescriptor",
    61                                          "Debugger.FunctionDetails", "Debugger.CallFrame",
     61                                         "Debugger.FunctionDetails", "Debugger.CallFrame", "WebGL.TraceLog",
    6262                                         # This should be a temporary hack. TimelineEvent should be created via generated C++ API.
    6363                                         "Timeline.TimelineEvent"])
  • trunk/Source/WebCore/inspector/InjectedScriptWebGLModule.cpp

    r120957 r126028  
    7373}
    7474
    75 void InjectedScriptWebGLModule::captureFrame(ErrorString* errorString, const String& contextId)
     75void InjectedScriptWebGLModule::captureFrame(ErrorString* errorString, String* traceLogId)
    7676{
    7777    ScriptFunctionCall function(injectedScriptObject(), "captureFrame");
    78     function.appendArgument(contextId);
     78    RefPtr<InspectorValue> resultValue;
     79    makeCall(function, &resultValue);
     80    if (!resultValue || resultValue->type() != InspectorValue::TypeString || !resultValue->asString(traceLogId))
     81        *errorString = "Internal error: captureFrame";
     82}
     83
     84void InjectedScriptWebGLModule::dropTraceLog(ErrorString* errorString, const String& traceLogId)
     85{
     86    ScriptFunctionCall function(injectedScriptObject(), "dropTraceLog");
     87    function.appendArgument(traceLogId);
    7988    bool hadException = false;
    8089    callFunctionWithEvalEnabled(function, hadException);
    8190    ASSERT(!hadException);
    8291    if (hadException)
    83         *errorString = "Internal error";
     92        *errorString = "Internal error: dropTraceLog";
     93}
     94
     95void InjectedScriptWebGLModule::traceLog(ErrorString* errorString, const String& traceLogId, RefPtr<TypeBuilder::WebGL::TraceLog>* traceLog)
     96{
     97    ScriptFunctionCall function(injectedScriptObject(), "traceLog");
     98    function.appendArgument(traceLogId);
     99    RefPtr<InspectorValue> resultValue;
     100    makeCall(function, &resultValue);
     101    if (!resultValue || resultValue->type() != InspectorValue::TypeObject) {
     102        if (!resultValue->asString(errorString))
     103            *errorString = "Internal error: traceLog";
     104        return;
     105    }
     106    *traceLog = TypeBuilder::WebGL::TraceLog::runtimeCast(resultValue);
     107}
     108
     109void InjectedScriptWebGLModule::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, String* result)
     110{
     111    ScriptFunctionCall function(injectedScriptObject(), "replayTraceLog");
     112    function.appendArgument(traceLogId);
     113    function.appendArgument(stepNo);
     114    RefPtr<InspectorValue> resultValue;
     115    makeCall(function, &resultValue);
     116    if (!resultValue || resultValue->type() != InspectorValue::TypeString || !resultValue->asString(result))
     117        *errorString = "Internal error: replayTraceLog";
    84118}
    85119
  • trunk/Source/WebCore/inspector/InjectedScriptWebGLModule.h

    r120929 r126028  
    4545class InjectedScriptWebGLModule : public InjectedScriptModule {
    4646public:
     47    InjectedScriptWebGLModule();
     48   
    4749    virtual String source() const;
    4850
     
    5052
    5153    ScriptObject wrapWebGLContext(const ScriptObject& glContext);
    52     void captureFrame(ErrorString*, const String& contextId);
    53 
    54 private:
    55     InjectedScriptWebGLModule();
     54    void captureFrame(ErrorString*, String*);
     55    void dropTraceLog(ErrorString*, const String&);
     56    void traceLog(ErrorString*, const String&, RefPtr<TypeBuilder::WebGL::TraceLog>*);
     57    void replayTraceLog(ErrorString*, const String&, int, String*);
    5658};
    5759
  • trunk/Source/WebCore/inspector/Inspector.json

    r125399 r126028  
    31183118        "domain": "WebGL",
    31193119        "hidden": true,
    3120         "types": [],
     3120        "types": [
     3121            {
     3122                "id": "TraceLogId",
     3123                "type": "string",
     3124                "description": "Unique object identifier."
     3125            },
     3126            {
     3127                "id": "Call",
     3128                "type": "object",
     3129                "properties": [
     3130                    { "name": "functionName", "type": "string" }
     3131                ]
     3132            },
     3133            {
     3134                "id": "TraceLog",
     3135                "type": "object",
     3136                "properties": [
     3137                    { "name": "id", "$ref": "TraceLogId" },
     3138                    { "name": "calls", "type": "array", "items": { "$ref": "Call" }}
     3139                ]
     3140            }
     3141        ],
    31213142        "commands": [
    31223143            {
     
    31273148                "name": "disable",
    31283149                "description": "Disables WebGL inspection."
     3150            },
     3151            {
     3152                "name": "dropTraceLog",
     3153                "parameters": [
     3154                    { "name": "traceLogId", "$ref": "TraceLogId" }
     3155                ]
     3156            },
     3157            {
     3158                "name": "captureFrame",
     3159                "returns": [
     3160                    { "name": "traceLogId", "$ref": "TraceLogId" }
     3161                ]
     3162            },
     3163            {
     3164                "name": "getTraceLog",
     3165                "parameters": [
     3166                    { "name": "traceLogId", "$ref": "TraceLogId" }
     3167                ],
     3168                "returns": [
     3169                    { "name": "traceLog", "$ref": "TraceLog" }
     3170                ]
     3171            },
     3172            {
     3173                "name": "replayTraceLog",
     3174                "parameters": [
     3175                    { "name": "traceLogId", "$ref": "TraceLogId" },
     3176                    { "name": "stepNo", "type": "integer" }
     3177                ],
     3178                "returns": [
     3179                    { "name": "screenshotDataUrl", "type": "string" }
     3180                ]
    31293181            }
    31303182        ],
  • trunk/Source/WebCore/inspector/InspectorController.cpp

    r125025 r126028  
    149149
    150150#if ENABLE(WEBGL)
    151     m_agents.append(InspectorWebGLAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get()));
     151    m_agents.append(InspectorWebGLAgent::create(m_instrumentingAgents.get(), m_state.get(), page, m_injectedScriptManager.get()));
    152152#endif
    153153
  • trunk/Source/WebCore/inspector/InspectorWebGLAgent.cpp

    r120929 r126028  
    3535#include "InspectorWebGLAgent.h"
    3636
     37#include "InjectedScript.h"
    3738#include "InjectedScriptManager.h"
    3839#include "InjectedScriptWebGLModule.h"
     
    4041#include "InspectorState.h"
    4142#include "InstrumentingAgents.h"
     43#include "Page.h"
    4244#include "ScriptObject.h"
    4345#include "ScriptState.h"
     
    4951};
    5052
    51 InspectorWebGLAgent::InspectorWebGLAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager)
     53InspectorWebGLAgent::InspectorWebGLAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, Page* page, InjectedScriptManager* injectedScriptManager)
    5254    : InspectorBaseAgent<InspectorWebGLAgent>("WebGL", instrumentingAgents, state)
     55    , m_inspectedPage(page)
    5356    , m_injectedScriptManager(injectedScriptManager)
    5457    , m_frontend(0)
     
    9699}
    97100
     101void InspectorWebGLAgent::dropTraceLog(ErrorString* errorString, const String& traceLogId)
     102{
     103    InjectedScriptWebGLModule module = injectedScriptWebGLModuleForTraceLogId(errorString, traceLogId);
     104    if (!module.hasNoValue())
     105        module.dropTraceLog(errorString, traceLogId);
     106}
     107
     108void InspectorWebGLAgent::captureFrame(ErrorString* errorString, String* traceLogId)
     109{
     110    ScriptState* scriptState = mainWorldScriptState(m_inspectedPage->mainFrame());
     111    InjectedScriptWebGLModule module = InjectedScriptWebGLModule::moduleForState(m_injectedScriptManager, scriptState);
     112    if (module.hasNoValue()) {
     113        *errorString = "Inspected frame has gone";
     114        return;
     115    }
     116    module.captureFrame(errorString, traceLogId);
     117}
     118
     119void InspectorWebGLAgent::getTraceLog(ErrorString* errorString, const String& traceLogId, RefPtr<TypeBuilder::WebGL::TraceLog>& traceLog)
     120{
     121    InjectedScriptWebGLModule module = injectedScriptWebGLModuleForTraceLogId(errorString, traceLogId);
     122    if (!module.hasNoValue())
     123        module.traceLog(errorString, traceLogId, &traceLog);
     124}
     125
     126void InspectorWebGLAgent::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, String* result)
     127{
     128    InjectedScriptWebGLModule module = injectedScriptWebGLModuleForTraceLogId(errorString, traceLogId);
     129    if (!module.hasNoValue())
     130        module.replayTraceLog(errorString, traceLogId, stepNo, result);
     131}
     132
    98133ScriptObject InspectorWebGLAgent::wrapWebGLRenderingContextForInstrumentation(const ScriptObject& glContext)
    99134{
     
    110145}
    111146
     147InjectedScriptWebGLModule InspectorWebGLAgent::injectedScriptWebGLModuleForTraceLogId(ErrorString* errorString, const String& traceLogId)
     148{
     149    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(traceLogId);
     150    if (injectedScript.hasNoValue()) {
     151        *errorString = "Inspected frame has gone";
     152        return InjectedScriptWebGLModule();
     153    }
     154    InjectedScriptWebGLModule module = InjectedScriptWebGLModule::moduleForState(m_injectedScriptManager, injectedScript.scriptState());
     155    if (module.hasNoValue()) {
     156        ASSERT_NOT_REACHED();
     157        *errorString = "Internal error: no WebGL module";
     158        return InjectedScriptWebGLModule();
     159    }
     160    return module;
     161}
     162
    112163} // namespace WebCore
    113164
  • trunk/Source/WebCore/inspector/InspectorWebGLAgent.h

    r119589 r126028  
    3636#include "InspectorBaseAgent.h"
    3737#include "InspectorFrontend.h"
     38#include "InspectorTypeBuilder.h"
    3839#include "PlatformString.h"
    3940#include "ScriptState.h"
     
    4445
    4546class InjectedScriptManager;
     47class InjectedScriptWebGLModule;
    4648class InspectorState;
    4749class InstrumentingAgents;
     50class Page;
    4851class ScriptObject;
    4952
     
    5255class InspectorWebGLAgent : public InspectorBaseAgent<InspectorWebGLAgent>, public InspectorBackendDispatcher::WebGLCommandHandler {
    5356public:
    54     static PassOwnPtr<InspectorWebGLAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager)
     57    static PassOwnPtr<InspectorWebGLAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, Page* page, InjectedScriptManager* injectedScriptManager)
    5558    {
    56         return adoptPtr(new InspectorWebGLAgent(instrumentingAgents, state, injectedScriptManager));
     59        return adoptPtr(new InspectorWebGLAgent(instrumentingAgents, state, page, injectedScriptManager));
    5760    }
    5861    ~InspectorWebGLAgent();
     
    6972    virtual void enable(ErrorString*);
    7073    virtual void disable(ErrorString*);
     74    virtual void dropTraceLog(ErrorString*, const String&);
     75    virtual void captureFrame(ErrorString*, String*);
     76    virtual void getTraceLog(ErrorString*, const String&, RefPtr<TypeBuilder::WebGL::TraceLog>&);
     77    virtual void replayTraceLog(ErrorString*, const String&, int, String*);
    7178
    7279    // Called from the injected script.
     
    7582
    7683private:
    77     InspectorWebGLAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*);
     84    InspectorWebGLAgent(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptManager*);
    7885
     86    InjectedScriptWebGLModule injectedScriptWebGLModuleForTraceLogId(ErrorString*, const String&);
     87
     88    Page* m_inspectedPage;
    7989    InjectedScriptManager* m_injectedScriptManager;
    8090    InspectorFrontend::WebGL* m_frontend;
Note: See TracChangeset for help on using the changeset viewer.