Web Inspector: memory instrumentation for Resource{Request/Response}Base
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Aug 2012 09:18:34 +0000 (09:18 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Aug 2012 09:18:34 +0000 (09:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94109

Reviewed by Vsevolod Vlasov.

Added reportMemoryUsage methods to ResourceRequestBase, ResourceResponseBase
and several related classes.

* dom/MemoryInstrumentation.cpp:
(WebCore::MemoryInstrumentation::addInstrumentedObjectImpl): added overrides
for String, StringImpl and AtomicString object types so that we can reuse
existing addInstrumentedCollection method instead of adding a counterpart
that would operate on not instrumented content. Next step would be to get
rid od addObject overrides for these types so that all kinds of Strings are
considered as instrumented classes despite they don't have reportMemoryUsage
method.
(WebCore):
* dom/MemoryInstrumentation.h:
(WebCore::MemoryInstrumentation::addInstrumentedObjectImpl):
(MemoryInstrumentation):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::reportMemoryUsage):
* platform/network/FormData.cpp:
(WebCore::FormData::reportMemoryUsage):
(WebCore):
* platform/network/FormData.h:
(WebCore):
(FormData):
* platform/network/ResourceRequestBase.cpp:
(WebCore::ResourceRequestBase::reportMemoryUsage):
(WebCore):
* platform/network/ResourceRequestBase.h:
(ResourceRequestBase):
* platform/network/ResourceResponseBase.cpp:
(WebCore):
(WebCore::ResourceResponseBase::reportMemoryUsage):
* platform/network/ResourceResponseBase.h:
(WebCore):
(ResourceResponseBase):

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

Source/WebCore/ChangeLog
Source/WebCore/dom/MemoryInstrumentation.cpp
Source/WebCore/dom/MemoryInstrumentation.h
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/platform/network/FormData.cpp
Source/WebCore/platform/network/FormData.h
Source/WebCore/platform/network/ResourceRequestBase.cpp
Source/WebCore/platform/network/ResourceRequestBase.h
Source/WebCore/platform/network/ResourceResponseBase.cpp
Source/WebCore/platform/network/ResourceResponseBase.h

index fd5d070..f6964d1 100644 (file)
@@ -1,3 +1,45 @@
+2012-08-16  Yury Semikhatsky  <yurys@chromium.org>
+
+        Web Inspector: memory instrumentation for Resource{Request/Response}Base
+        https://bugs.webkit.org/show_bug.cgi?id=94109
+
+        Reviewed by Vsevolod Vlasov.
+
+        Added reportMemoryUsage methods to ResourceRequestBase, ResourceResponseBase
+        and several related classes.
+
+        * dom/MemoryInstrumentation.cpp:
+        (WebCore::MemoryInstrumentation::addInstrumentedObjectImpl): added overrides
+        for String, StringImpl and AtomicString object types so that we can reuse
+        existing addInstrumentedCollection method instead of adding a counterpart
+        that would operate on not instrumented content. Next step would be to get
+        rid od addObject overrides for these types so that all kinds of Strings are
+        considered as instrumented classes despite they don't have reportMemoryUsage
+        method.
+        (WebCore):
+        * dom/MemoryInstrumentation.h:
+        (WebCore::MemoryInstrumentation::addInstrumentedObjectImpl):
+        (MemoryInstrumentation):
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::reportMemoryUsage):
+        * platform/network/FormData.cpp:
+        (WebCore::FormData::reportMemoryUsage):
+        (WebCore):
+        * platform/network/FormData.h:
+        (WebCore):
+        (FormData):
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::ResourceRequestBase::reportMemoryUsage):
+        (WebCore):
+        * platform/network/ResourceRequestBase.h:
+        (ResourceRequestBase):
+        * platform/network/ResourceResponseBase.cpp:
+        (WebCore):
+        (WebCore::ResourceResponseBase::reportMemoryUsage):
+        * platform/network/ResourceResponseBase.h:
+        (WebCore):
+        (ResourceResponseBase):
+
 2012-08-16  Adam Barth  <abarth@webkit.org>
 
         Delete DOMWindow::securityOrigin()
index 8a01753..a9fefca 100644 (file)
@@ -58,4 +58,9 @@ void MemoryInstrumentation::addObject(const KURL& url, ObjectType objectType)
         addObject(url.innerURL(), objectType);
 }
 
+void MemoryInstrumentation::addInstrumentedObjectImpl(const AtomicString* const& string, ObjectType objectType, OwningType)
+{
+    addObject(static_cast<const String&>(*string), objectType);
+}
+
 } // namespace WebCore
index 33f2e6e..ebb36ce 100644 (file)
@@ -137,6 +137,10 @@ private:
         static void addObject(MemoryInstrumentation* instrumentation, const T* const& t, ObjectType ownerObjectType) { instrumentation->addObjectImpl(t, ownerObjectType, byPointer); }
     };
 
+    // FIXME: get rid of addObject(String)
+    void addInstrumentedObjectImpl(const String* const& string, ObjectType objectType, OwningType) { addObject(*string, objectType); }
+    void addInstrumentedObjectImpl(const StringImpl* const& string, ObjectType objectType, OwningType) { addObject(string, objectType); }
+    void addInstrumentedObjectImpl(const AtomicString* const&, ObjectType, OwningType);
     template <typename T> void addInstrumentedObjectImpl(const T* const&, ObjectType, OwningType);
     template <typename T> void addInstrumentedObjectImpl(const DataRef<T>* const&, ObjectType, OwningType);
     template <typename T> void addInstrumentedObjectImpl(const OwnPtr<T>* const&, ObjectType, OwningType);
index bc74440..57198ef 100644 (file)
@@ -363,11 +363,18 @@ void DocumentLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     info.addInstrumentedHashSet(m_subresourceLoaders);
     info.addInstrumentedHashSet(m_multipartSubresourceLoaders);
     info.addInstrumentedHashSet(m_plugInStreamLoaders);
+    info.addInstrumentedMember(m_substituteData);
     info.addMember(m_pageTitle.string());
     info.addMember(m_overrideEncoding);
     info.addVector(m_responses);
+    info.addInstrumentedMember(m_originalRequest);
+    info.addInstrumentedMember(m_originalRequestCopy);
+    info.addInstrumentedMember(m_request);
+    info.addInstrumentedMember(m_response);
+    info.addInstrumentedMember(m_lastCheckedRequest);
+    info.addInstrumentedVector(m_responses);
     info.addHashMap(m_pendingSubstituteResources);
-    info.addHashSet(m_resourcesClientKnowsAbout);
+    info.addInstrumentedHashSet(m_resourcesClientKnowsAbout);
     info.addVector(m_resourcesLoadedFromMemoryCacheForClientNotification);
     info.addMember(m_clientRedirectSourceForHistory);
     info.addInstrumentedMember(m_mainResourceData);
index 781fa7a..9c3c8c3 100644 (file)
@@ -32,6 +32,7 @@
 #include "FormDataBuilder.h"
 #include "FormDataList.h"
 #include "MIMETypeRegistry.h"
+#include "MemoryInstrumentation.h"
 #include "Page.h"
 #include "TextEncoding.h"
 #include <wtf/Decoder.h>
@@ -356,6 +357,12 @@ void FormData::removeGeneratedFilesIfNeeded()
     m_hasGeneratedFiles = false;
 }
 
+void FormData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::Loader);
+    info.addVector(m_boundary);
+}
+
 static void encode(Encoder& encoder, const FormDataElement& element)
 {
     encoder.encodeUInt32(element.m_type);
index 48dca92..63cadc6 100644 (file)
@@ -30,6 +30,7 @@ namespace WebCore {
 
 class Document;
 class FormDataList;
+class MemoryObjectInfo;
 class TextEncoding;
 
 class FormDataElement {
@@ -152,6 +153,8 @@ public:
     bool containsPasswordData() const { return m_containsPasswordData; }
     void setContainsPasswordData(bool containsPasswordData) { m_containsPasswordData = containsPasswordData; }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
     static EncodingType parseEncodingType(const String& type)
     {
         if (equalIgnoringCase(type, "text/plain"))
index 3509792..a829078 100644 (file)
@@ -24,8 +24,9 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 #include "config.h"
-
 #include "ResourceRequestBase.h"
+
+#include "MemoryInstrumentation.h"
 #include "ResourceRequest.h"
 
 using namespace std;
@@ -443,6 +444,18 @@ bool ResourceRequestBase::isConditional() const
             m_httpHeaderFields.contains("If-Unmodified-Since"));
 }
 
+void ResourceRequestBase::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::Loader);
+    info.addMember(m_url);
+    info.addMember(m_firstPartyForCookies);
+    info.addInstrumentedMember(m_httpMethod);
+    info.addHashMap(m_httpHeaderFields);
+    info.addInstrumentedMapEntries(m_httpHeaderFields);
+    info.addInstrumentedVector(m_responseContentDispositionEncodingFallbackArray);
+    info.addInstrumentedMember(m_httpBody);
+}
+
 double ResourceRequestBase::defaultTimeoutInterval()
 {
     return s_defaultTimeoutInterval;
index 86dd62e..3b700a7 100644 (file)
@@ -44,6 +44,7 @@ namespace WebCore {
         ReturnCacheDataDontLoad  // results of a post - allow stale data and only use cache
     };
 
+    class MemoryObjectInfo;
     class ResourceRequest;
     struct CrossThreadResourceRequestData;
 
@@ -132,6 +133,8 @@ namespace WebCore {
         bool reportRawHeaders() const { return m_reportRawHeaders; }
         void setReportRawHeaders(bool reportRawHeaders) { m_reportRawHeaders = reportRawHeaders; }
 
+        void reportMemoryUsage(MemoryObjectInfo*) const;
+
         static double defaultTimeoutInterval(); // May return 0 when using platform default.
         static void setDefaultTimeoutInterval(double);
 
index 111c6dc..fa05381 100644 (file)
@@ -28,6 +28,7 @@
 #include "ResourceResponseBase.h"
 
 #include "HTTPParsers.h"
+#include "MemoryInstrumentation.h"
 #include "ResourceResponse.h"
 #include <wtf/CurrentTime.h>
 #include <wtf/MathExtras.h>
@@ -566,6 +567,20 @@ void ResourceResponseBase::lazyInit(InitLevel initLevel) const
 {
     const_cast<ResourceResponse*>(static_cast<const ResourceResponse*>(this))->platformLazyInit(initLevel);
 }
+
+void ResourceResponseBase::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::Loader);
+    info.addMember(m_url);
+    info.addInstrumentedMember(m_mimeType);
+    info.addInstrumentedMember(m_textEncodingName);
+    info.addInstrumentedMember(m_suggestedFilename);
+    info.addInstrumentedMember(m_httpStatusText);
+    info.addHashMap(m_httpHeaderFields);
+    info.addInstrumentedMapEntries(m_httpHeaderFields);
+    info.addMember(m_resourceLoadTiming);
+    info.addMember(m_resourceLoadInfo);
+}
     
 bool ResourceResponseBase::compare(const ResourceResponse& a, const ResourceResponse& b)
 {
index 3c61666..ea7ac6c 100644 (file)
@@ -41,6 +41,7 @@
 
 namespace WebCore {
 
+class MemoryObjectInfo;
 class ResourceResponse;
 struct CrossThreadResourceResponseData;
 
@@ -126,6 +127,8 @@ public:
         return 1280;
     }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
     static bool compare(const ResourceResponse&, const ResourceResponse&);
 
 protected: