Changeset 138005 in webkit
- Timestamp:
- Dec 18, 2012 3:46:05 AM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r137994 r138005 1 2012-12-18 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: show cached images under MemoryCache -> Images section 4 https://bugs.webkit.org/show_bug.cgi?id=105261 5 6 Reviewed by Pavel Feldman. 7 8 Use first provided name and class name. If one of the ancestors tries to overwrite 9 it just ignore the call. 10 11 * wtf/MemoryObjectInfo.h: 12 (WTF::MemoryObjectInfo::setClassName): 13 (WTF::MemoryObjectInfo::setName): 14 1 15 2012-12-18 Uli Schlachter <psychon@znc.in> 2 16 -
trunk/Source/WTF/wtf/MemoryObjectInfo.h
r137589 r138005 62 62 void setCustomAllocation(bool customAllocation) { m_customAllocation = customAllocation; } 63 63 64 void setClassName(const String& className) { m_className = className; } 64 void setClassName(const String& className) 65 { 66 if (m_className.isEmpty()) 67 m_className = className; 68 } 65 69 const String& className() const { return m_className; } 66 void setName(const String& name) { m_name = name; } 70 void setName(const String& name) 71 { 72 if (m_name.isEmpty()) 73 m_name = name; 74 } 67 75 const String& name() const { return m_name; } 68 76 -
trunk/Source/WebCore/ChangeLog
r138004 r138005 1 2012-12-18 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: show cached images under MemoryCache -> Images section 4 https://bugs.webkit.org/show_bug.cgi?id=105261 5 6 Reviewed by Pavel Feldman. 7 8 Provided class name and name for several objects related to CachedImage. 9 Changed native memory snapsho view so that MemoryCache.Image section can 10 be expanded into individual images. 11 12 * inspector/front-end/NativeMemorySnapshotView.js: 13 (WebInspector.NativeMemorySnapshotView): 14 (WebInspector.NativeSnapshotNode.prototype._addChildrenFromGraph): 15 (WebInspector.NativeHeapGraphEdge): 16 (WebInspector.NativeHeapGraphEdge.prototype.type): 17 (WebInspector.NativeHeapGraphEdge.prototype.name): 18 (WebInspector.NativeHeapGraphEdge.prototype.target): 19 (WebInspector.NativeHeapGraphEdge.prototype._getStringField): 20 (WebInspector.NativeHeapGraphEdge.prototype.toString): 21 (WebInspector.NativeHeapGraphNode.prototype.size): 22 (WebInspector.NativeHeapGraphNode.prototype.referencedNodes): 23 (WebInspector.NativeHeapGraphNode.prototype.outgoingEdges): 24 (WebInspector.NativeHeapGraphNode.prototype.targetOfEdge): 25 (WebInspector.NativeHeapGraphNode.prototype.targetsOfAllEdges): 26 (WebInspector.NativeHeapGraphNode.prototype._firstEdgePoistion): 27 (WebInspector.NativeHeapGraphNode.prototype._afterLastEdgePosition): 28 (WebInspector.NativeHeapGraphNode.prototype._getStringField): 29 (WebInspector.NativeHeapGraphNode.prototype.toString): 30 (WebInspector.NativeHeapGraph): 31 (WebInspector.NativeHeapGraph.prototype.rootNodes): 32 (WebInspector.NativeHeapGraph.prototype._calculateNodeEdgeIndexes): 33 (WebInspector.NativeHeapGraph.prototype._addDummyNode): 34 (WebInspector.NativeMemoryProfileType.prototype.buttonClicked.didReceiveMemorySnapshot): 35 (WebInspector.NativeMemoryProfileType.prototype.buttonClicked): 36 * loader/cache/CachedImage.cpp: 37 (WebCore::CachedImage::reportMemoryUsage): 38 * loader/cache/CachedResource.cpp: 39 (WebCore::CachedResource::reportMemoryUsage): 40 * loader/cache/MemoryCache.cpp: 41 (WebCore::MemoryCache::reportMemoryUsage): 42 * platform/graphics/BitmapImage.cpp: 43 (WebCore::BitmapImage::reportMemoryUsage): 44 (WebCore::FrameData::reportMemoryUsage): 45 * platform/graphics/Image.cpp: 46 (WebCore::Image::reportMemoryUsage): 47 * platform/graphics/skia/MemoryInstrumentationSkia.cpp: 48 (reportMemoryUsage): 49 1 50 2012-12-18 Eugene Klyuchnikov <eustas@chromium.org> 2 51 -
trunk/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js
r137742 r138005 40 40 41 41 this.element.addStyleClass("native-snapshot-view"); 42 this._containmentDataGrid = new WebInspector.NativeSnapshotDataGrid(profile ._memoryBlock);42 this._containmentDataGrid = new WebInspector.NativeSnapshotDataGrid(profile); 43 43 this._containmentDataGrid.show(this.element); 44 44 45 this._heapGraphDataGrid = new WebInspector.NativeHeapGraphDataGrid( new WebInspector.NativeHeapGraph(profile._graph));45 this._heapGraphDataGrid = new WebInspector.NativeHeapGraphDataGrid(profile._graph); 46 46 47 47 this._viewSelectElement = document.createElement("select"); … … 91 91 * @constructor 92 92 * @extends {WebInspector.DataGrid} 93 * @param { MemoryAgent.MemoryBlock} profile93 * @param {WebInspector.NativeMemoryProfileHeader} profile 94 94 */ 95 95 WebInspector.NativeSnapshotDataGrid = function(profile) … … 100 100 }; 101 101 WebInspector.DataGrid.call(this, columns); 102 this._totalNode = new WebInspector.NativeSnapshotNode(profile, profile); 102 this._profile = profile; 103 this._totalNode = new WebInspector.NativeSnapshotNode(profile._memoryBlock, profile._memoryBlock); 103 104 if (WebInspector.settings.showNativeSnapshotUninstrumentedSize.get()) { 104 105 this.setRootNode(new WebInspector.DataGridNode(null, true)); … … 146 147 * @extends {WebInspector.DataGridNode} 147 148 * @param {MemoryAgent.MemoryBlock} nodeData 148 * @param {MemoryAgent.MemoryBlock} profile149 */ 150 WebInspector.NativeSnapshotNode = function(nodeData, profile)149 * @param {MemoryAgent.MemoryBlock} rootMemoryBlock 150 */ 151 WebInspector.NativeSnapshotNode = function(nodeData, rootMemoryBlock) 151 152 { 152 153 this._nodeData = nodeData; 153 this._ profile = profile;154 this._rootMemoryBlock = rootMemoryBlock; 154 155 var viewProperties = WebInspector.MemoryBlockViewProperties._forMemoryBlock(nodeData); 155 156 var data = { name: viewProperties._description, size: this._nodeData.size }; … … 224 225 225 226 var sizeKB = this._nodeData.size / 1024; 226 var totalSize = this._ profile.size;227 var totalSize = this._rootMemoryBlock.size; 227 228 var percentage = this._nodeData.size / totalSize * 100; 228 229 … … 260 261 this.removeEventListener("populate", this._populate, this); 261 262 this._nodeData.children.sort(this.dataGrid._sortingFunction.bind(this.dataGrid)); 263 262 264 for (var node in this._nodeData.children) { 263 265 var nodeData = this._nodeData.children[node]; 266 this._addChildrenFromGraph(nodeData); 264 267 if (WebInspector.settings.showNativeSnapshotUninstrumentedSize.get() || nodeData.name !== "Other") 265 this.appendChild(new WebInspector.NativeSnapshotNode(nodeData, this._profile)); 266 } 268 this.appendChild(new WebInspector.NativeSnapshotNode(nodeData, this._rootMemoryBlock)); 269 } 270 }, 271 272 /** 273 * @param {MemoryAgent.MemoryBlock} memoryBlock 274 */ 275 _addChildrenFromGraph: function(memoryBlock) 276 { 277 if (memoryBlock.children) 278 return; 279 if (memoryBlock.name !== "Image" || this._nodeData.name !== "MemoryCache") 280 return; 281 282 // Collect objects on the path MemoryCache -> CachedImage -m_image-> BitmapImage -m_frames-> FrameData -m_frame-> SkBitmap -> SkPixelRef 283 var graph = this.dataGrid._profile._graph; 284 var roots = graph.rootNodes(); 285 var memoryCache; 286 for (var i = 0; i < roots.length; i++) { 287 var root = roots[i]; 288 if (root.className() === "MemoryCache") { 289 memoryCache = root; 290 break; 291 } 292 } 293 var edges = memoryCache.outgoingEdges(); 294 var cachedImages = []; 295 for (var i = 0; i < edges.length; i++) { 296 var target = edges[i].target(); 297 if (target.className() === "CachedImage") { 298 var cachedImage = { 299 name: target.name(), 300 size: target.size(), 301 children: [] 302 }; 303 cachedImages.push(cachedImage); 304 var image = target.targetOfEdge("m_image"); 305 if (image.className() === "BitmapImage") { 306 var frames = image.targetsOfAllEdges("m_frame"); 307 for (var j = 0; j < frames.length; j++) { 308 var pixels = frames[j].targetOfEdge("pixels"); 309 if (pixels) { 310 cachedImage.size += pixels.size(); 311 cachedImage.children.push({ 312 name: "Bitmap pixels", 313 size: pixels.size() 314 }); 315 } 316 } 317 } 318 } 319 } 320 memoryBlock.children = cachedImages; 267 321 }, 268 322 … … 276 330 * @param {number} position 277 331 */ 278 WebInspector.NativeHeapGraph Node = function(graph, position)332 WebInspector.NativeHeapGraphEdge = function(graph, position) 279 333 { 280 334 this._graph = graph; … … 282 336 } 283 337 338 WebInspector.NativeHeapGraphEdge.prototype = { 339 type: function() 340 { 341 return this._getStringField(this._graph._edgeTypeOffset); 342 }, 343 344 name: function() 345 { 346 return this._getStringField(this._graph._edgeNameOffset); 347 }, 348 349 target: function() 350 { 351 var edges = this._graph._edges; 352 var targetPosition = edges[this._position + this._graph._edgeTargetOffset] * this._graph._nodeFieldCount; 353 return new WebInspector.NativeHeapGraphNode(this._graph, targetPosition); 354 }, 355 356 _getStringField: function(offset) 357 { 358 var typeIndex = this._graph._edges[this._position + offset]; 359 return this._graph._rawGraph.strings[typeIndex]; 360 }, 361 362 toString: function() 363 { 364 return "Edge#" + this._position + " -" + this.name() + "-> " + this.target(); 365 } 366 367 } 368 369 370 /** 371 * @constructor 372 * @param {WebInspector.NativeHeapGraph} graph 373 * @param {number} position 374 */ 375 WebInspector.NativeHeapGraphNode = function(graph, position) 376 { 377 this._graph = graph; 378 this._position = position; 379 } 380 284 381 WebInspector.NativeHeapGraphNode.prototype = { 285 382 id: function() … … 295 392 size: function() 296 393 { 297 return this._graph._ rawGraph.nodes[this._position + this._graph._nodeSizeOffset];394 return this._graph._nodes[this._position + this._graph._nodeSizeOffset]; 298 395 }, 299 396 … … 315 412 referencedNodes: function() 316 413 { 317 var edges = this._graph._ rawGraph.edges;318 var nodes = this._graph._ rawGraph.nodes;414 var edges = this._graph._edges; 415 var nodes = this._graph._nodes; 319 416 var edgeFieldCount = this._graph._edgeFieldCount; 320 417 var nodeFieldCount = this._graph._nodeFieldCount; … … 328 425 }, 329 426 427 outgoingEdges: function() 428 { 429 var edges = this._graph._edges; 430 var edgeFieldCount = this._graph._edgeFieldCount; 431 432 var firstEdgePosition = this._firstEdgePoistion(); 433 var afterLastEdgePosition = this._afterLastEdgePosition(); 434 var result = []; 435 for (var i = firstEdgePosition; i < afterLastEdgePosition; i += edgeFieldCount) 436 result.push(new WebInspector.NativeHeapGraphEdge(this._graph, i)); 437 return result; 438 }, 439 440 targetOfEdge: function(edgeName) 441 { 442 return this.targetsOfAllEdges(edgeName)[0]; 443 }, 444 445 targetsOfAllEdges: function(edgeName) 446 { 447 var edges = this._graph._edges; 448 var edgeFieldCount = this._graph._edgeFieldCount; 449 450 var firstEdgePosition = this._firstEdgePoistion(); 451 var afterLastEdgePosition = this._afterLastEdgePosition(); 452 453 var edge = new WebInspector.NativeHeapGraphEdge(this._graph, firstEdgePosition) 454 var result = []; 455 for (var i = firstEdgePosition; i < afterLastEdgePosition; i += edgeFieldCount) { 456 edge._position = i; 457 if (edge.name() === edgeName) 458 result.push(edge.target()); 459 } 460 return result; 461 }, 462 330 463 _firstEdgePoistion: function() 331 464 { 332 return this._graph._ rawGraph.nodes[this._position + this._graph._nodeFirstEdgeOffset] * this._graph._edgeFieldCount;465 return this._graph._nodes[this._position + this._graph._nodeFirstEdgeOffset] * this._graph._edgeFieldCount; 333 466 }, 334 467 335 468 _afterLastEdgePosition: function() 336 469 { 337 var edges = this._graph._rawGraph.edges; 338 var nodes = this._graph._rawGraph.nodes; 339 var afterLastEdgePosition = nodes[this._position + this._graph._nodeFieldCount + this._graph._nodeFirstEdgeOffset]; 340 if (afterLastEdgePosition) 341 afterLastEdgePosition *= this._graph._edgeFieldCount; 342 else 343 afterLastEdgePosition = edges.length; 344 return afterLastEdgePosition; 470 return this._graph._nodes[this._position + this._graph._nodeFieldCount + this._graph._nodeFirstEdgeOffset] * this._graph._edgeFieldCount; 345 471 }, 346 472 347 473 _getStringField: function(offset) 348 474 { 349 var typeIndex = this._graph._ rawGraph.nodes[this._position + offset];475 var typeIndex = this._graph._nodes[this._position + offset]; 350 476 return this._graph._rawGraph.strings[typeIndex]; 477 }, 478 479 toString: function() 480 { 481 return "Node#" + this.id() + " " + this.name() + "(" + this.className() + ")"; 351 482 } 352 483 } … … 373 504 this._edgeNameOffset = 2; 374 505 506 this._nodeCount = rawGraph.nodes.length / this._nodeFieldCount; 507 this._nodes = rawGraph.nodes; 508 this._edges = rawGraph.edges; 509 this._strings = rawGraph.strings; 510 375 511 this._calculateNodeEdgeIndexes(); 376 512 } … … 379 515 rootNodes: function() 380 516 { 381 var nodeHasIncomingEdges = new Uint8Array(this._ rawGraph.nodes.length / this._nodeFieldCount);382 var edges = this._ rawGraph.edges;517 var nodeHasIncomingEdges = new Uint8Array(this._nodeCount); 518 var edges = this._edges; 383 519 var edgesLength = edges.length; 384 520 var edgeFieldCount = this._edgeFieldCount; … … 399 535 _calculateNodeEdgeIndexes: function() 400 536 { 401 var nodes = this._ rawGraph.nodes;537 var nodes = this._nodes; 402 538 var nodeFieldCount = this._nodeFieldCount; 403 539 var nodeLength = nodes.length; … … 408 544 firstEdgeIndex += count; 409 545 } 546 this._addDummyNode(); 547 }, 548 549 _addDummyNode: function() 550 { 551 var firstEdgePosition = this._nodes.length + this._nodeFirstEdgeOffset; 552 for (var i = 0; i < this._nodeFieldCount; i++) 553 this._nodes.push(0); 554 this._nodes[firstEdgePosition] = this._edges.length; 410 555 } 411 556 } … … 546 691 } 547 692 profileHeader._memoryBlock = memoryBlock; 548 profileHeader._graph = graph;693 profileHeader._graph = new WebInspector.NativeHeapGraph(graph); 549 694 profileHeader.isTemporary = false; 550 695 profileHeader.sidebarElement.subtitle = Number.bytesToString(/** @type{number} */(memoryBlock.size)); -
trunk/Source/WebCore/loader/cache/CachedImage.cpp
r137981 r138005 40 40 #include "SubresourceLoader.h" 41 41 #include <wtf/CurrentTime.h> 42 #include <wtf/MemoryObjectInfo.h> 42 43 #include <wtf/StdLibExtras.h> 43 44 #include <wtf/Vector.h> … … 483 484 { 484 485 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResourceImage); 486 memoryObjectInfo->setClassName("CachedImage"); 485 487 CachedResource::reportMemoryUsage(memoryObjectInfo); 486 info.addMember(m_image );488 info.addMember(m_image, "m_image"); 487 489 #if ENABLE(SVG) 488 490 info.addMember(m_svgImageCache); -
trunk/Source/WebCore/loader/cache/CachedResource.cpp
r137604 r138005 52 52 #include <wtf/MemoryInstrumentationHashCountedSet.h> 53 53 #include <wtf/MemoryInstrumentationHashSet.h> 54 #include <wtf/MemoryObjectInfo.h> 54 55 #include <wtf/RefCountedLeakCounter.h> 55 56 #include <wtf/StdLibExtras.h> … … 889 890 { 890 891 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResource); 892 memoryObjectInfo->setName(url().string()); 891 893 info.addMember(m_resourceRequest); 892 894 info.addMember(m_clients); -
trunk/Source/WebCore/loader/cache/MemoryCache.cpp
r133469 r138005 48 48 #include <wtf/MemoryInstrumentationHashMap.h> 49 49 #include <wtf/MemoryInstrumentationVector.h> 50 #include <wtf/MemoryObjectInfo.h> 50 51 #include <wtf/TemporaryChange.h> 51 52 #include <wtf/text/CString.h> … … 724 725 { 725 726 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::MemoryCacheStructures); 727 memoryObjectInfo->setClassName("MemoryCache"); 726 728 info.addMember(m_resources); 727 729 info.addMember(m_allResources); -
trunk/Source/WebCore/platform/graphics/BitmapImage.cpp
r130289 r138005 36 36 #include <wtf/CurrentTime.h> 37 37 #include <wtf/MemoryInstrumentationVector.h> 38 #include <wtf/MemoryObjectInfo.h> 38 39 #include <wtf/Vector.h> 39 40 #include <wtf/text/WTFString.h> … … 577 578 { 578 579 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image); 580 memoryObjectInfo->setClassName("BitmapImage"); 579 581 Image::reportMemoryUsage(memoryObjectInfo); 580 info.addMember(m_source );582 info.addMember(m_source, "m_source"); 581 583 info.addMember(m_frameTimer); 582 info.addMember(m_frames );584 info.addMember(m_frames, "m_frames"); 583 585 } 584 586 … … 586 588 { 587 589 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image); 590 memoryObjectInfo->setClassName("FrameData"); 588 591 #if OS(WINCE) && !PLATFORM(QT) 589 592 info.addRawBuffer(m_frame.get(), m_frameBytes); 590 593 #elif USE(SKIA) 591 info.addMember(m_frame );594 info.addMember(m_frame, "m_frame"); 592 595 #else 593 info.addRawBuffer(m_frame, m_frameBytes );596 info.addRawBuffer(m_frame, m_frameBytes, "m_frame"); 594 597 #endif 595 598 } -
trunk/Source/WebCore/platform/graphics/Image.cpp
r137011 r138005 39 39 #include <math.h> 40 40 #include <wtf/MainThread.h> 41 #include <wtf/MemoryObjectInfo.h> 41 42 #include <wtf/StdLibExtras.h> 42 43 … … 202 203 { 203 204 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image); 204 info.addMember(m_data); 205 memoryObjectInfo->setClassName("Image"); 206 info.addMember(m_data, "m_data"); 205 207 info.addWeakPointer(m_imageObserver); 206 208 } -
trunk/Source/WebCore/platform/graphics/skia/MemoryInstrumentationSkia.cpp
r131017 r138005 37 37 #include "SkDevice.h" 38 38 #include "SkPixelRef.h" 39 #include <wtf/MemoryObjectInfo.h> 39 40 40 41 void reportMemoryUsage(const SkBitmap* const& image, WTF::MemoryObjectInfo* memoryObjectInfo) 41 42 { 42 43 WTF::MemoryClassInfo info(memoryObjectInfo, image); 44 memoryObjectInfo->setClassName("SkBitmap"); 45 43 46 SkPixelRef* pixelRef = image->pixelRef(); 44 47 info.addMember(pixelRef); 45 48 if (pixelRef) 46 info.addRawBuffer(pixelRef->pixels(), image->getSize() );49 info.addRawBuffer(pixelRef->pixels(), image->getSize(), 0, "pixels"); 47 50 } 48 51
Note: See TracChangeset
for help on using the changeset viewer.