Changeset 116768 in webkit
- Timestamp:
- May 11, 2012 8:05:42 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r116767 r116768 1 2012-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 1 37 2012-05-11 Allan Sandfeld Jensen <allan.jensen@nokia.com> 2 38 -
trunk/Source/WebCore/bindings/js/ScriptProfiler.cpp
r115288 r116768 52 52 } 53 53 54 unsigned ScriptProfiler::getHeapObjectId(ScriptValue) 55 { 56 return 0; 57 } 58 54 59 void ScriptProfiler::start(ScriptState* state, const String& title) 55 60 { -
trunk/Source/WebCore/bindings/js/ScriptProfiler.h
r109214 r116768 40 40 class Page; 41 41 class ScriptObject; 42 class ScriptValue; 42 43 class WorkerContext; 43 44 … … 56 57 static void collectGarbage(); 57 58 static ScriptObject objectByHeapObjectId(unsigned id); 59 static unsigned getHeapObjectId(ScriptValue); 58 60 static void start(ScriptState* state, const String& title); 59 61 static void startForPage(Page*, const String& title); -
trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp
r114042 r116768 122 122 } 123 123 124 unsigned ScriptProfiler::getHeapObjectId(ScriptValue value) 125 { 126 v8::SnapshotObjectId id = v8::HeapProfiler::GetSnapshotObjectId(value.v8Value()); 127 return id; 128 } 129 124 130 namespace { 125 131 -
trunk/Source/WebCore/bindings/v8/ScriptProfiler.h
r109214 r116768 44 44 class Page; 45 45 class ScriptObject; 46 class ScriptValue; 46 47 class WorkerContext; 47 48 … … 60 61 static void collectGarbage(); 61 62 static ScriptObject objectByHeapObjectId(unsigned id); 63 static unsigned getHeapObjectId(ScriptValue); 62 64 static void start(ScriptState* state, const String& title); 63 65 static void startForPage(Page*, const String& title); -
trunk/Source/WebCore/inspector/InjectedScript.cpp
r112428 r116768 191 191 } 192 192 193 ScriptValue 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 193 205 void InjectedScript::inspectNode(Node* node) 194 206 { -
trunk/Source/WebCore/inspector/InjectedScript.h
r112428 r116768 94 94 PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapNode(Node*, const String& groupName); 95 95 PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapSerializedObject(SerializedScriptValue*, const String& groupName) const; 96 ScriptValue findObjectById(const String& objectId) const; 97 96 98 void inspectNode(Node*); 97 99 void releaseObjectGroup(const String&); -
trunk/Source/WebCore/inspector/InjectedScriptSource.js
r112102 r116768 385 385 }, 386 386 387 findObjectById: function(objectId) 388 { 389 var parsedObjectId = this._parseObjectId(objectId); 390 return this._objectForId(parsedObjectId); 391 }, 392 387 393 nodeForObjectId: function(objectId) 388 394 { 389 var parsedObjectId = this._parseObjectId(objectId); 390 var object = this._objectForId(parsedObjectId); 395 var object = this.findObjectById(objectId); 391 396 if (!object || this._subtype(object) !== "node") 392 397 return null; -
trunk/Source/WebCore/inspector/Inspector.json
r116744 r116768 2597 2597 { "name": "bottomUpHead", "type": "object", "optional": true } 2598 2598 ] 2599 }, 2600 { 2601 "id": "HeapSnapshotObjectId", 2602 "type": "string", 2603 "description": "Heap snashot object id." 2599 2604 } 2600 2605 ], … … 2665 2670 "name": "getObjectByHeapObjectId", 2666 2671 "parameters": [ 2667 { "name": "objectId", " type": "integer" },2672 { "name": "objectId", "$ref": "HeapSnapshotObjectId" }, 2668 2673 { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." } 2669 2674 ], 2670 2675 "returns": [ 2671 2676 { "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." } 2672 2686 ] 2673 2687 } -
trunk/Source/WebCore/inspector/InspectorProfilerAgent.cpp
r116210 r116768 429 429 } 430 430 431 void InspectorProfilerAgent::getObjectByHeapObjectId(ErrorString* error, int id, const String* objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result) 432 { 431 void 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 } 433 439 ScriptObject heapObject = ScriptProfiler::objectByHeapObjectId(id); 434 440 if (heapObject.hasNoValue()) { … … 446 452 } 447 453 454 void 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 448 470 } // namespace WebCore 449 471 -
trunk/Source/WebCore/inspector/InspectorProfilerAgent.h
r116210 r116768 97 97 void toggleRecordButton(bool isProfiling); 98 98 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); 100 101 101 102 protected: -
trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js
r115189 r116768 340 340 callback(WebInspector.RemoteObject.fromPrimitiveValue(WebInspector.UIString("Not available"))); 341 341 } 342 ProfilerAgent.getObjectByHeapObjectId( this.snapshotNodeId, objectGroupName, formatResult);342 ProfilerAgent.getObjectByHeapObjectId(String(this.snapshotNodeId), objectGroupName, formatResult); 343 343 } 344 344 },
Note: See TracChangeset
for help on using the changeset viewer.