Web Inspector: count DOM storage cache memory for native snapshot
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Aug 2012 13:55:07 +0000 (13:55 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Aug 2012 13:55:07 +0000 (13:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=91617

Patch by Alexei Filippov <alexeif@chromium.org> on 2012-08-01
Reviewed by Yury Semikhatsky.

Source/Platform:

Add memory size used for DOM storage cache reporting interface.

* chromium/public/WebStorageArea.h:
(WebStorageArea):
(WebKit::WebStorageArea::memoryBytesUsedByCache):

Source/WebCore:

Add memory size used for DOM storage cache reporting interface.
Report it to the native memory snapshot instrumentation framework.

* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
* inspector/InspectorDOMStorageAgent.cpp:
(WebCore::InspectorDOMStorageAgent::memoryBytesUsedByStorageCache):
(WebCore):
* inspector/InspectorDOMStorageAgent.h:
(InspectorDOMStorageAgent):
* inspector/InspectorMemoryAgent.cpp:
(MemoryBlockName):
(WebCore):
(WebCore::dumpDOMStorageCache):
(WebCore::InspectorMemoryAgent::getProcessMemoryDistribution):
(WebCore::InspectorMemoryAgent::InspectorMemoryAgent):
* inspector/InspectorMemoryAgent.h:
(WebCore):
(WebCore::InspectorMemoryAgent::create):
(InspectorMemoryAgent):
* inspector/front-end/NativeMemorySnapshotView.js:
(WebInspector.MemoryBlockViewProperties._initialize):
* storage/StorageArea.h:
(StorageArea):
* storage/StorageAreaImpl.cpp:
(WebCore::StorageAreaImpl::memoryBytesUsedByCache):
(WebCore):
* storage/StorageAreaImpl.h:
(StorageAreaImpl):

Source/WebKit/chromium:

Add memory size used for DOM storage cache reporting interface.

* src/StorageAreaProxy.cpp:
(WebCore::StorageAreaProxy::memoryBytesUsedByCache):
(WebCore):
* src/StorageAreaProxy.h:
(StorageAreaProxy):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@124332 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/Platform/ChangeLog
Source/Platform/chromium/public/WebStorageArea.h
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorDOMStorageAgent.cpp
Source/WebCore/inspector/InspectorDOMStorageAgent.h
Source/WebCore/inspector/InspectorMemoryAgent.cpp
Source/WebCore/inspector/InspectorMemoryAgent.h
Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js
Source/WebCore/storage/StorageArea.h
Source/WebCore/storage/StorageAreaImpl.cpp
Source/WebCore/storage/StorageAreaImpl.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/StorageAreaProxy.cpp
Source/WebKit/chromium/src/StorageAreaProxy.h

index 549ca53..089f85e 100644 (file)
@@ -1,3 +1,16 @@
+2012-08-01  Alexei Filippov  <alexeif@chromium.org>
+
+        Web Inspector: count DOM storage cache memory for native snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=91617
+
+        Reviewed by Yury Semikhatsky.
+
+        Add memory size used for DOM storage cache reporting interface.
+
+        * chromium/public/WebStorageArea.h:
+        (WebStorageArea):
+        (WebKit::WebStorageArea::memoryBytesUsedByCache):
+
 2012-07-31  Chris Rogers  <crogers@google.com>
 
         Allow AudioDestination to support local/live audio input
index f75e56d..3b1f967 100644 (file)
@@ -84,6 +84,9 @@ public:
         clear(pageUrl, unused);
     }
 
+    // Returns amount of bytes occupied by the storage cache in physical memory.
+    virtual size_t memoryBytesUsedByCache() const { return 0; }
+
     // DEPRECATED - being replaced by the async variants above which do not return oldValues or block until completion.
     virtual void setItem(const WebString& key, const WebString& newValue, const WebURL&, Result&, WebString& oldValue) { }
     virtual void removeItem(const WebString& key, const WebURL& pageUrl, WebString& oldValue)  { }
index 1e7337c..cfc50da 100644 (file)
@@ -1,3 +1,40 @@
+2012-08-01  Alexei Filippov  <alexeif@chromium.org>
+
+        Web Inspector: count DOM storage cache memory for native snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=91617
+
+        Reviewed by Yury Semikhatsky.
+
+        Add memory size used for DOM storage cache reporting interface.
+        Report it to the native memory snapshot instrumentation framework.
+
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        * inspector/InspectorDOMStorageAgent.cpp:
+        (WebCore::InspectorDOMStorageAgent::memoryBytesUsedByStorageCache):
+        (WebCore):
+        * inspector/InspectorDOMStorageAgent.h:
+        (InspectorDOMStorageAgent):
+        * inspector/InspectorMemoryAgent.cpp:
+        (MemoryBlockName):
+        (WebCore):
+        (WebCore::dumpDOMStorageCache):
+        (WebCore::InspectorMemoryAgent::getProcessMemoryDistribution):
+        (WebCore::InspectorMemoryAgent::InspectorMemoryAgent):
+        * inspector/InspectorMemoryAgent.h:
+        (WebCore):
+        (WebCore::InspectorMemoryAgent::create):
+        (InspectorMemoryAgent):
+        * inspector/front-end/NativeMemorySnapshotView.js:
+        (WebInspector.MemoryBlockViewProperties._initialize):
+        * storage/StorageArea.h:
+        (StorageArea):
+        * storage/StorageAreaImpl.cpp:
+        (WebCore::StorageAreaImpl::memoryBytesUsedByCache):
+        (WebCore):
+        * storage/StorageAreaImpl.h:
+        (StorageAreaImpl):
+
 2012-07-31  Yury Semikhatsky  <yurys@chromium.org>
 
         Web Inspector: add CSSStyleSheet memory instrumentation
index ab6e377..e26a1c0 100644 (file)
@@ -114,7 +114,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
     OwnPtr<InspectorDOMStorageAgent> domStorageAgentPtr(InspectorDOMStorageAgent::create(m_instrumentingAgents.get(), m_state.get()));
     InspectorDOMStorageAgent* domStorageAgent = domStorageAgentPtr.get();
     m_agents.append(domStorageAgentPtr.release());
-    m_agents.append(InspectorMemoryAgent::create(m_instrumentingAgents.get(), m_state.get(), m_page, m_domAgent));
+    m_agents.append(InspectorMemoryAgent::create(m_instrumentingAgents.get(), m_state.get(), m_page, domStorageAgent));
     m_agents.append(InspectorTimelineAgent::create(m_instrumentingAgents.get(), pageAgent, m_state.get(), InspectorTimelineAgent::PageInspector,
        inspectorClient));
     m_agents.append(InspectorApplicationCacheAgent::create(m_instrumentingAgents.get(), m_state.get(), pageAgent));
index f62784e..93999d1 100644 (file)
@@ -214,6 +214,14 @@ void InspectorDOMStorageAgent::clearResources()
     m_resources.clear();
 }
 
+size_t InspectorDOMStorageAgent::memoryBytesUsedByStorageCache() const
+{
+    size_t size = 0;
+    for (DOMStorageResourcesMap::const_iterator it = m_resources.begin(); it != m_resources.end(); ++it)
+        size += it->second->storageArea()->memoryBytesUsedByCache();
+    return size;
+}
+
 
 } // namespace WebCore
 
index f69f097..6664a8d 100644 (file)
@@ -78,6 +78,9 @@ public:
     void didUseDOMStorage(StorageArea*, bool isLocalStorage, Frame*);
     void didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*, Page*);
 
+    // Called from InspectorMemoryAgent
+    size_t memoryBytesUsedByStorageCache() const;
+
 private:
     InspectorDOMStorageAgent(InstrumentingAgents*, InspectorState*);
 
index ed32cdc..bda75b0 100644 (file)
@@ -39,6 +39,7 @@
 #include "Document.h"
 #include "EventListenerMap.h"
 #include "Frame.h"
+#include "InspectorDOMStorageAgent.h"
 #include "InspectorFrontend.h"
 #include "InspectorState.h"
 #include "InspectorValues.h"
@@ -97,6 +98,8 @@ static const char domTreeDOM[] = "DOMTreeDOM";
 static const char domTreeCSS[] = "DOMTreeCSS";
 static const char domTreeBinding[] = "DOMTreeBinding";
 static const char domTreeLoader[] = "DOMTreeLoader";
+
+static const char domStorageCache[] = "DOMStorageCache";
 }
 
 namespace {
@@ -569,6 +572,13 @@ static PassRefPtr<InspectorMemoryBlock> jsExternalResourcesInfo(VisitedObjects&
     return externalResourcesStats.release();
 }
 
+static PassRefPtr<InspectorMemoryBlock> dumpDOMStorageCache(size_t cacheSize)
+{
+    RefPtr<InspectorMemoryBlock> domStorageCache = InspectorMemoryBlock::create().setName(MemoryBlockName::domStorageCache);
+    domStorageCache->setSize(cacheSize);
+    return domStorageCache;
+}
+
 void InspectorMemoryAgent::getProcessMemoryDistribution(ErrorString*, RefPtr<InspectorMemoryBlock>& processMemory)
 {
     processMemory = InspectorMemoryBlock::create().setName(MemoryBlockName::processPrivateMemory);
@@ -584,6 +594,7 @@ void InspectorMemoryAgent::getProcessMemoryDistribution(ErrorString*, RefPtr<Ins
     children->addItem(domTreeInfo(m_page, visitedObjects, &inspectorData)); // FIXME: collect for all pages?
     children->addItem(jsExternalResourcesInfo(visitedObjects));
     children->addItem(inspectorData.dumpStatistics());
+    children->addItem(dumpDOMStorageCache(m_domStorageAgent->memoryBytesUsedByStorageCache()));
     addPlatformComponentsInfo(children);
     processMemory->setChildren(children);
 
@@ -593,9 +604,10 @@ void InspectorMemoryAgent::getProcessMemoryDistribution(ErrorString*, RefPtr<Ins
     processMemory->setSize(privateBytes);
 }
 
-InspectorMemoryAgent::InspectorMemoryAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, Page* page, InspectorDOMAgent*)
+InspectorMemoryAgent::InspectorMemoryAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, Page* page, InspectorDOMStorageAgent* domStorageAgent)
     : InspectorBaseAgent<InspectorMemoryAgent>("Memory", instrumentingAgents, state)
     , m_page(page)
+    , m_domStorageAgent(domStorageAgent)
 {
 }
 
index 91f3fbe..3b64864 100644 (file)
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
-class InspectorDOMAgent;
-class InspectorFrontend;
+
+class InspectorDOMStorageAgent;
 class InspectorState;
-class InspectorArray;
 class InstrumentingAgents;
 class Page;
 
@@ -52,19 +51,19 @@ class InspectorMemoryAgent : public InspectorBaseAgent<InspectorMemoryAgent>, pu
 public:
     typedef Vector<OwnPtr<InspectorBaseAgentInterface> > InspectorAgents;
 
-    static PassOwnPtr<InspectorMemoryAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, Page* page, InspectorDOMAgent* domAgent)
+    static PassOwnPtr<InspectorMemoryAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, Page* page, InspectorDOMStorageAgent* domStorageAgent)
     {
-        return adoptPtr(new InspectorMemoryAgent(instrumentingAgents, state, page, domAgent));
+        return adoptPtr(new InspectorMemoryAgent(instrumentingAgents, state, page, domStorageAgent));
     }
     virtual ~InspectorMemoryAgent();
 
     virtual void getDOMNodeCount(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder::Memory::DOMGroup> >& domGroups, RefPtr<TypeBuilder::Memory::StringStatistics>& strings);
     virtual void getProcessMemoryDistribution(ErrorString*, RefPtr<TypeBuilder::Memory::MemoryBlock>& processMemory);
 
-
 private:
-    InspectorMemoryAgent(InstrumentingAgents*, InspectorState*, Page*, InspectorDOMAgent* domAgent);
+    InspectorMemoryAgent(InstrumentingAgents*, InspectorState*, Page*, InspectorDOMStorageAgent*);
     Page* m_page;
+    InspectorDOMStorageAgent* m_domStorageAgent;
 };
 
 } // namespace WebCore
index 6f84ab0..b4dd51d 100644 (file)
@@ -225,6 +225,7 @@ WebInspector.MemoryBlockViewProperties._initialize = function()
     addBlock("hsl(210, 60%,  80%)", "InspectorData", "Inspector data");
     addBlock("hsl( 30, 60%,  80%)", "MemoryCache", "Memory cache resources");
     addBlock("hsl( 40, 60%,  80%)", "GlyphCache", "Glyph cache resources");
+    addBlock("hsl( 35, 60%,  80%)", "DOMStorageCache", "DOM storage cache");
     addBlock("hsl( 60, 60%,  80%)", "RenderTreeAllocated", "Render tree");
     addBlock("hsl( 60, 60%,  80%)", "RenderTreeUsed", "Render tree used");
 }
index 3b2492a..2ea9117 100644 (file)
@@ -56,6 +56,8 @@ namespace WebCore {
 
         virtual bool disabledByPrivateBrowsingInFrame(const Frame* sourceFrame) const = 0;
 
+        virtual size_t memoryBytesUsedByCache() const = 0;
+
         virtual void incrementAccessCount() { }
         virtual void decrementAccessCount() { }
     };
index 694a97a..37c4f59 100644 (file)
@@ -264,6 +264,11 @@ void StorageAreaImpl::blockUntilImportComplete() const
         m_storageAreaSync->blockUntilImportComplete();
 }
 
+size_t StorageAreaImpl::memoryBytesUsedByCache() const
+{
+    return 0;
+}
+
 void StorageAreaImpl::incrementAccessCount()
 {
     m_accessCount++;
index 4c90e5b..1f2b7e0 100644 (file)
@@ -54,6 +54,8 @@ namespace WebCore {
 
         virtual bool disabledByPrivateBrowsingInFrame(const Frame* sourceFrame) const;
 
+        virtual size_t memoryBytesUsedByCache() const;
+
         virtual void incrementAccessCount();
         virtual void decrementAccessCount();
 
index 99c95ce..40d89e6 100644 (file)
@@ -1,3 +1,18 @@
+2012-08-01  Alexei Filippov  <alexeif@chromium.org>
+
+        Web Inspector: count DOM storage cache memory for native snapshot
+        https://bugs.webkit.org/show_bug.cgi?id=91617
+
+        Reviewed by Yury Semikhatsky.
+
+        Add memory size used for DOM storage cache reporting interface.
+
+        * src/StorageAreaProxy.cpp:
+        (WebCore::StorageAreaProxy::memoryBytesUsedByCache):
+        (WebCore):
+        * src/StorageAreaProxy.h:
+        (StorageAreaProxy):
+
 2012-07-31  Yoshifumi Inoue  <yosin@chromium.org>
 
         [Chromium] Enable ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS
index 576105c..722e80f 100644 (file)
@@ -120,6 +120,11 @@ bool StorageAreaProxy::canAccessStorage(Frame* frame) const
     return !webView->permissionClient() || webView->permissionClient()->allowStorage(webFrame, m_storageType == LocalStorage);
 }
 
+size_t StorageAreaProxy::memoryBytesUsedByCache() const
+{
+    return m_storageArea->memoryBytesUsedByCache();
+}
+
 void StorageAreaProxy::dispatchLocalStorageEvent(PageGroup* pageGroup, const String& key, const String& oldValue, const String& newValue,
                                                  SecurityOrigin* securityOrigin, const KURL& pageURL, WebKit::WebStorageArea* sourceAreaInstance, bool originatedInProcess)
 {
index 83f2eae..cae3593 100644 (file)
@@ -58,6 +58,8 @@ public:
 
     virtual bool disabledByPrivateBrowsingInFrame(const Frame*) const { return false; }
 
+    virtual size_t memoryBytesUsedByCache() const;
+
     static void dispatchLocalStorageEvent(
             PageGroup*, const String& key, const String& oldValue, const String& newValue,
             SecurityOrigin*, const KURL& pageURL, WebKit::WebStorageArea* sourceAreaInstance, bool originatedInProcess);