Changeset 116768 in webkit


Ignore:
Timestamp:
May 11, 2012 8:05:42 AM (12 years ago)
Author:
yurys@chromium.org
Message:

Web Inspector: add Profiler.getHeapObjectId command
https://bugs.webkit.org/show_bug.cgi?id=86211

Reviewed by Pavel Feldman.

Added Profiler.getHeapObjectId command to the protocol which allows to convert remote
object id to heap snapshot object id.

  • bindings/js/ScriptProfiler.cpp:

(WebCore::ScriptProfiler::getHeapObjectId):
(WebCore):

  • bindings/js/ScriptProfiler.h:

(WebCore):
(ScriptProfiler):

  • bindings/v8/ScriptProfiler.cpp:

(WebCore::ScriptProfiler::getHeapObjectId):
(WebCore):

  • bindings/v8/ScriptProfiler.h:

(WebCore):
(ScriptProfiler):

  • inspector/InjectedScript.cpp:

(WebCore::InjectedScript::findObjectById):
(WebCore):

  • inspector/InjectedScript.h:

(InjectedScript):

  • inspector/InjectedScriptSource.js:

(.):

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

(WebCore::InspectorProfilerAgent::getHeapObjectId):
(WebCore):

  • inspector/InspectorProfilerAgent.h:

(InspectorProfilerAgent):

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r116767 r116768  
     12012-05-11  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: add Profiler.getHeapObjectId command
     4        https://bugs.webkit.org/show_bug.cgi?id=86211
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Added Profiler.getHeapObjectId command to the protocol which allows to convert remote
     9        object id to heap snapshot object id.
     10
     11        * bindings/js/ScriptProfiler.cpp:
     12        (WebCore::ScriptProfiler::getHeapObjectId):
     13        (WebCore):
     14        * bindings/js/ScriptProfiler.h:
     15        (WebCore):
     16        (ScriptProfiler):
     17        * bindings/v8/ScriptProfiler.cpp:
     18        (WebCore::ScriptProfiler::getHeapObjectId):
     19        (WebCore):
     20        * bindings/v8/ScriptProfiler.h:
     21        (WebCore):
     22        (ScriptProfiler):
     23        * inspector/InjectedScript.cpp:
     24        (WebCore::InjectedScript::findObjectById):
     25        (WebCore):
     26        * inspector/InjectedScript.h:
     27        (InjectedScript):
     28        * inspector/InjectedScriptSource.js:
     29        (.):
     30        * inspector/Inspector.json:
     31        * inspector/InspectorProfilerAgent.cpp:
     32        (WebCore::InspectorProfilerAgent::getHeapObjectId):
     33        (WebCore):
     34        * inspector/InspectorProfilerAgent.h:
     35        (InspectorProfilerAgent):
     36
    1372012-05-11  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
    238
  • trunk/Source/WebCore/bindings/js/ScriptProfiler.cpp

    r115288 r116768  
    5252}
    5353
     54unsigned ScriptProfiler::getHeapObjectId(ScriptValue)
     55{
     56    return 0;
     57}
     58
    5459void ScriptProfiler::start(ScriptState* state, const String& title)
    5560{
  • trunk/Source/WebCore/bindings/js/ScriptProfiler.h

    r109214 r116768  
    4040class Page;
    4141class ScriptObject;
     42class ScriptValue;
    4243class WorkerContext;
    4344
     
    5657    static void collectGarbage();
    5758    static ScriptObject objectByHeapObjectId(unsigned id);
     59    static unsigned getHeapObjectId(ScriptValue);
    5860    static void start(ScriptState* state, const String& title);
    5961    static void startForPage(Page*, const String& title);
  • trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp

    r114042 r116768  
    122122}
    123123
     124unsigned ScriptProfiler::getHeapObjectId(ScriptValue value)
     125{
     126    v8::SnapshotObjectId id = v8::HeapProfiler::GetSnapshotObjectId(value.v8Value());
     127    return id;
     128}
     129
    124130namespace {
    125131
  • trunk/Source/WebCore/bindings/v8/ScriptProfiler.h

    r109214 r116768  
    4444class Page;
    4545class ScriptObject;
     46class ScriptValue;
    4647class WorkerContext;
    4748
     
    6061    static void collectGarbage();
    6162    static ScriptObject objectByHeapObjectId(unsigned id);
     63    static unsigned getHeapObjectId(ScriptValue);
    6264    static void start(ScriptState* state, const String& title);
    6365    static void startForPage(Page*, const String& title);
  • trunk/Source/WebCore/inspector/InjectedScript.cpp

    r112428 r116768  
    191191}
    192192
     193ScriptValue InjectedScript::findObjectById(const String& objectId) const
     194{
     195    ASSERT(!hasNoValue());
     196    ScriptFunctionCall function(m_injectedScriptObject, "findObjectById");
     197    function.appendArgument(objectId);
     198
     199    bool hadException = false;
     200    ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException);
     201    ASSERT(!hadException);
     202    return resultValue;
     203}
     204
    193205void InjectedScript::inspectNode(Node* node)
    194206{
  • trunk/Source/WebCore/inspector/InjectedScript.h

    r112428 r116768  
    9494    PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapNode(Node*, const String& groupName);
    9595    PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapSerializedObject(SerializedScriptValue*, const String& groupName) const;
     96    ScriptValue findObjectById(const String& objectId) const;
     97
    9698    void inspectNode(Node*);
    9799    void releaseObjectGroup(const String&);
  • trunk/Source/WebCore/inspector/InjectedScriptSource.js

    r112102 r116768  
    385385    },
    386386
     387    findObjectById: function(objectId)
     388    {
     389        var parsedObjectId = this._parseObjectId(objectId);
     390        return this._objectForId(parsedObjectId);
     391    },
     392
    387393    nodeForObjectId: function(objectId)
    388394    {
    389         var parsedObjectId = this._parseObjectId(objectId);
    390         var object = this._objectForId(parsedObjectId);
     395        var object = this.findObjectById(objectId);
    391396        if (!object || this._subtype(object) !== "node")
    392397            return null;
  • trunk/Source/WebCore/inspector/Inspector.json

    r116744 r116768  
    25972597                    { "name": "bottomUpHead", "type": "object", "optional": true }
    25982598                ]
     2599            },
     2600            {
     2601                "id": "HeapSnapshotObjectId",
     2602                "type": "string",
     2603                "description": "Heap snashot object id."
    25992604            }
    26002605        ],
     
    26652670                "name": "getObjectByHeapObjectId",
    26662671                "parameters": [
    2667                     { "name": "objectId", "type": "integer" },
     2672                    { "name": "objectId", "$ref": "HeapSnapshotObjectId" },
    26682673                    { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." }
    26692674                ],
    26702675                "returns": [
    26712676                    { "name": "result", "$ref": "Runtime.RemoteObject", "description": "Evaluation result." }
     2677                ]
     2678            },
     2679            {
     2680                "name": "getHeapObjectId",
     2681                "parameters": [
     2682                    { "name": "objectId", "$ref": "Runtime.RemoteObjectId", "description": "Identifier of the object to get heap object id for." }
     2683                ],
     2684                "returns": [
     2685                    { "name": "heapSnapshotObjectId", "$ref": "HeapSnapshotObjectId", "description": "Id of the heap snapshot object corresponding to the passed remote object id." }
    26722686                ]
    26732687            }
  • trunk/Source/WebCore/inspector/InspectorProfilerAgent.cpp

    r116210 r116768  
    429429}
    430430
    431 void InspectorProfilerAgent::getObjectByHeapObjectId(ErrorString* error, int id, const String* objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result)
    432 {
     431void InspectorProfilerAgent::getObjectByHeapObjectId(ErrorString* error, const String& heapSnapshotObjectId, const String* objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result)
     432{
     433    bool ok;
     434    unsigned id = heapSnapshotObjectId.toUInt(&ok);
     435    if (!ok) {
     436        *error = "Invalid heap snapshot object id";
     437        return;
     438    }
    433439    ScriptObject heapObject = ScriptProfiler::objectByHeapObjectId(id);
    434440    if (heapObject.hasNoValue()) {
     
    446452}
    447453
     454void InspectorProfilerAgent::getHeapObjectId(ErrorString* errorString, const String& objectId, String* heapSnapshotObjectId)
     455{
     456    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
     457    if (injectedScript.hasNoValue()) {
     458        *errorString = "Inspected context has gone";
     459        return;
     460    }
     461    ScriptValue value = injectedScript.findObjectById(objectId);
     462    if (value.hasNoValue() || value.isUndefined()) {
     463        *errorString = "Object with given id not found";
     464        return;
     465    }
     466    unsigned id = ScriptProfiler::getHeapObjectId(value);
     467    *heapSnapshotObjectId = String::number(id);
     468}
     469
    448470} // namespace WebCore
    449471
  • trunk/Source/WebCore/inspector/InspectorProfilerAgent.h

    r116210 r116768  
    9797    void toggleRecordButton(bool isProfiling);
    9898
    99     virtual void getObjectByHeapObjectId(ErrorString*, int id, const String* objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result);
     99    virtual void getObjectByHeapObjectId(ErrorString*, const String& heapSnapshotObjectId, const String* objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result);
     100    virtual void getHeapObjectId(ErrorString*, const String& objectId, String* heapSnapshotObjectId);
    100101
    101102protected:
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js

    r115189 r116768  
    340340                    callback(WebInspector.RemoteObject.fromPrimitiveValue(WebInspector.UIString("Not available")));
    341341            }
    342             ProfilerAgent.getObjectByHeapObjectId(this.snapshotNodeId, objectGroupName, formatResult);
     342            ProfilerAgent.getObjectByHeapObjectId(String(this.snapshotNodeId), objectGroupName, formatResult);
    343343        }
    344344    },
Note: See TracChangeset for help on using the changeset viewer.