Title: [147260] trunk
Revision
147260
Author
[email protected]
Date
2013-03-29 16:30:44 -0700 (Fri, 29 Mar 2013)

Log Message

        Expose FeatureObserver data to WebKit clients
        https://bugs.webkit.org/show_bug.cgi?id=113613

        Reviewed by Sam Weinig.

        FeatureObserver used to depend on chromium-only HistogramSupport, which is not
        really usable on Mac at least.

        Instead of adding parallel feature reporting machinery, I'm adding a way to
        generically relay the data from FeatureObserver to port code.

        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::loadWithDocumentLoader):
        (WebCore::FrameLoader::commitProvisionalLoad):
        (WebCore::FrameLoader::reportMemoryUsage):
        * loader/FrameLoader.h:
        (WebCore::FrameLoader::previousURL):
        Exposed m_previousURL, renaming it to follow WebKit style.

        * page/FeatureObserver.cpp:
        (WebCore::FeatureObserver::~FeatureObserver):
        (WebCore::FeatureObserver::updateMeasurements):
        * page/FeatureObserver.h:
        (WebCore::FeatureObserver::accumulatedFeatureBits):
        Exposed the data to clients, and made reporting through HistogramSupport
        chromium only for clarity.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (147259 => 147260)


--- trunk/Source/WebCore/ChangeLog	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Source/WebCore/ChangeLog	2013-03-29 23:30:44 UTC (rev 147260)
@@ -1,3 +1,32 @@
+2013-03-29  Alexey Proskuryakov  <[email protected]>
+
+        Expose FeatureObserver data to WebKit clients
+        https://bugs.webkit.org/show_bug.cgi?id=113613
+
+        Reviewed by Sam Weinig.
+
+        FeatureObserver used to depend on chromium-only HistogramSupport, which is not
+        really usable on Mac at least.
+
+        Instead of adding parallel feature reporting machinery, I'm adding a way to
+        generically relay the data from FeatureObserver to port code.
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadWithDocumentLoader):
+        (WebCore::FrameLoader::commitProvisionalLoad):
+        (WebCore::FrameLoader::reportMemoryUsage):
+        * loader/FrameLoader.h:
+        (WebCore::FrameLoader::previousURL):
+        Exposed m_previousURL, renaming it to follow WebKit style.
+
+        * page/FeatureObserver.cpp:
+        (WebCore::FeatureObserver::~FeatureObserver):
+        (WebCore::FeatureObserver::updateMeasurements):
+        * page/FeatureObserver.h:
+        (WebCore::FeatureObserver::accumulatedFeatureBits):
+        Exposed the data to clients, and made reporting through HistogramSupport
+        chromium only for clarity.
+
 2013-03-29  Bem Jones-Bey  <[email protected]>
 
         [CSS Exclusions] shape outside segments not properly calculated for ellipses

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (147259 => 147260)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2013-03-29 23:30:44 UTC (rev 147260)
@@ -1355,7 +1355,7 @@
         return;
 
     if (m_frame->document())
-        m_previousUrl = m_frame->document()->url();
+        m_previousURL = m_frame->document()->url();
 
     policyChecker()->setLoadType(type);
     RefPtr<FormState> formState = prpFormState;
@@ -1718,7 +1718,7 @@
     if (pdl && m_documentLoader) {
         // Check if the destination page is allowed to access the previous page's timing information.
         RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->request().url());
-        m_documentLoader->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canRequest(m_previousUrl));
+        m_documentLoader->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canRequest(m_previousURL));
     }
 
     // Call clientRedirectCancelledOrFinished() here so that the frame load delegate is notified that the redirect's
@@ -3353,7 +3353,7 @@
     info.addMember(m_openedFrames, "openedFrames");
     info.addMember(m_outgoingReferrer, "outgoingReferrer");
     info.addMember(m_networkingContext, "networkingContext");
-    info.addMember(m_previousUrl, "previousUrl");
+    info.addMember(m_previousURL, "previousURL");
     info.addMember(m_requestedHistoryItem, "requestedHistoryItem");
 }
 

Modified: trunk/Source/WebCore/loader/FrameLoader.h (147259 => 147260)


--- trunk/Source/WebCore/loader/FrameLoader.h	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Source/WebCore/loader/FrameLoader.h	2013-03-29 23:30:44 UTC (rev 147260)
@@ -286,6 +286,8 @@
 
     NetworkingContext* networkingContext() const;
 
+    const KURL& previousURL() const { return m_previousURL; }
+
     void reportMemoryUsage(MemoryObjectInfo*) const;
 
 private:
@@ -447,7 +449,7 @@
 
     RefPtr<FrameNetworkingContext> m_networkingContext;
 
-    KURL m_previousUrl;
+    KURL m_previousURL;
     RefPtr<HistoryItem> m_requestedHistoryItem;
 };
 

Modified: trunk/Source/WebCore/page/FeatureObserver.cpp (147259 => 147260)


--- trunk/Source/WebCore/page/FeatureObserver.cpp	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Source/WebCore/page/FeatureObserver.cpp	2013-03-29 23:30:44 UTC (rev 147260)
@@ -39,23 +39,32 @@
 
 FeatureObserver::~FeatureObserver()
 {
+#if PLATFORM(CHROMUM)
     // We always log PageDestruction so that we have a scale for the rest of the features.
     HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", PageDestruction, NumberOfFeatures);
+#endif
 
     updateMeasurements();
 }
 
 void FeatureObserver::updateMeasurements()
 {
+#if PLATFORM(CHROMUM)
     HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", PageVisits, NumberOfFeatures);
+#endif
+
     if (!m_featureBits)
         return;
 
+#if PLATFORM(CHROMUM)
     for (unsigned i = 0; i < NumberOfFeatures; ++i) {
         if (m_featureBits->quickGet(i))
             HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", i, NumberOfFeatures);
     }
+#endif
 
+    // Clearing feature bits is timing sensitive. Ports other than chromium do not use HistogramSupport,
+    // and pull the results on certain navigation events instead.
     m_featureBits->clearAll();
 }
 

Modified: trunk/Source/WebCore/page/FeatureObserver.h (147259 => 147260)


--- trunk/Source/WebCore/page/FeatureObserver.h	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Source/WebCore/page/FeatureObserver.h	2013-03-29 23:30:44 UTC (rev 147260)
@@ -115,6 +115,8 @@
     static void observe(DOMWindow*, Feature);
     void didCommitLoad();
 
+    const BitVector* accumulatedFeatureBits() const { return m_featureBits.get(); }
+
 private:
     void didObserve(Feature feature)
     {

Modified: trunk/Source/WebKit2/ChangeLog (147259 => 147260)


--- trunk/Source/WebKit2/ChangeLog	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Source/WebKit2/ChangeLog	2013-03-29 23:30:44 UTC (rev 147260)
@@ -1,3 +1,25 @@
+2013-03-29  Alexey Proskuryakov  <[email protected]>
+
+        Expose FeatureObserver data to WebKit clients
+        https://bugs.webkit.org/show_bug.cgi?id=113613
+
+        Reviewed by Sam Weinig.
+
+        * Shared/APIClientTraits.cpp:
+        * Shared/APIClientTraits.h:
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
+        * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
+        (WebKit::InjectedBundlePageLoaderClient::featuresUsedInPage):
+        * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
+        Added a new injected bundle client call, featuresUsedInPage.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::close):
+        (WebKit::WebPage::didCommitLoad):
+        (WebKit::WebPage::reportUsedFeatures):
+        * WebProcess/WebPage/WebPage.h:
+        Report features used in a page when navigating away, or when closing.
+
 2013-03-29  Brady Eidson  <[email protected]>
 
         Crash when "willSendRequest" causes the ResourceLoader to be cancelled.

Modified: trunk/Source/WebKit2/Shared/APIClientTraits.cpp (147259 => 147260)


--- trunk/Source/WebKit2/Shared/APIClientTraits.cpp	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Source/WebKit2/Shared/APIClientTraits.cpp	2013-03-29 23:30:44 UTC (rev 147260)
@@ -41,6 +41,7 @@
     offsetof(WKBundlePageLoaderClient, didFinishProgress),
     offsetof(WKBundlePageLoaderClient, didReceiveIntentForFrame_unavailable),
     offsetof(WKBundlePageLoaderClient, registerIntentServiceForFrame_unavailable),
+    offsetof(WKBundlePageLoaderClient, didLayout),
     sizeof(WKBundlePageLoaderClient)
 };
 

Modified: trunk/Source/WebKit2/Shared/APIClientTraits.h (147259 => 147260)


--- trunk/Source/WebKit2/Shared/APIClientTraits.h	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Source/WebKit2/Shared/APIClientTraits.h	2013-03-29 23:30:44 UTC (rev 147260)
@@ -44,7 +44,7 @@
 };
 
 template<> struct APIClientTraits<WKBundlePageLoaderClient> {
-    static const size_t interfaceSizesByVersion[5];
+    static const size_t interfaceSizesByVersion[6];
 };
 
 template<> struct APIClientTraits<WKBundlePageResourceLoadClient> {

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h (147259 => 147260)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h	2013-03-29 23:30:44 UTC (rev 147260)
@@ -110,6 +110,7 @@
 typedef void (*WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo);
 typedef bool (*WKBundlePageShouldForceUniversalAccessFromLocalURLCallback)(WKBundlePageRef, WKStringRef url, const void* clientInfo);
 typedef void (*WKBundlePageDidLayoutCallback)(WKBundlePageRef page, WKLayoutMilestones milestones, WKTypeRef* userData, const void *clientInfo);
+typedef void (*WKBundlePageFeaturesUsedInPageCallback)(WKBundlePageRef page, WKArrayRef featureStrings, const void *clientInfo);
 
 struct WKBundlePageLoaderClient {
     int                                                                     version;
@@ -155,10 +156,13 @@
 
     // Version 4
     WKBundlePageDidLayoutCallback                                           didLayout;
+
+    // Version 5
+    WKBundlePageFeaturesUsedInPageCallback                                  featuresUsedInPage;
 };
 typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient;
 
-enum { kWKBundlePageLoaderClientCurrentVersion = 4 };
+enum { kWKBundlePageLoaderClientCurrentVersion = 5 };
 
 enum {
     WKBundlePagePolicyActionPassThrough,

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp (147259 => 147260)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp	2013-03-29 23:30:44 UTC (rev 147260)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "InjectedBundlePageLoaderClient.h"
 
+#include "ImmutableArray.h"
 #include "InjectedBundleDOMWindowExtension.h"
 #include "InjectedBundleScriptWorld.h"
 #include "WKAPICast.h"
@@ -314,4 +315,20 @@
     return m_client.shouldForceUniversalAccessFromLocalURL(toAPI(page), toAPI(url.impl()), m_client.clientInfo);
 }
 
+void InjectedBundlePageLoaderClient::featuresUsedInPage(WebPage* page, const Vector<String>& features)
+{
+    if (!m_client.featuresUsedInPage)
+        return;
+
+    Vector<RefPtr<APIObject> > featureStringObjectsVector;
+
+    Vector<String>::const_iterator end = features.end();
+    for (Vector<String>::const_iterator it = features.begin(); it != end; ++it)
+        featureStringObjectsVector.append(WebString::create((*it)));
+
+    RefPtr<ImmutableArray> featureStringObjectsArray = ImmutableArray::adopt(featureStringObjectsVector);
+
+    return m_client.featuresUsedInPage(toAPI(page), toAPI(featureStringObjectsArray.get()), m_client.clientInfo);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h (147259 => 147260)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h	2013-03-29 23:30:44 UTC (rev 147260)
@@ -32,6 +32,7 @@
 #include <_javascript_Core/JSBase.h>
 #include <WebCore/LayoutMilestones.h>
 #include <wtf/Forward.h>
+#include <wtf/Vector.h>
 
 namespace WebCore {
 class DOMWindowExtension;
@@ -83,6 +84,8 @@
     void willDestroyGlobalObjectForDOMWindowExtension(WebPage*, WebCore::DOMWindowExtension*);
 
     bool shouldForceUniversalAccessFromLocalURL(WebPage*, const String& url);
+
+    void featuresUsedInPage(WebPage*, const Vector<String>&);
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (147259 => 147260)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-03-29 23:30:44 UTC (rev 147260)
@@ -791,6 +791,10 @@
 
     m_isClosed = true;
 
+    // If there is still no URL, then we never loaded anything in this page, so nothing to report.
+    if (!mainWebFrame()->url().isEmpty())
+        reportUsedFeatures();
+
     if (pageGroup()->isVisibleToInjectedBundle() && WebProcess::shared().injectedBundle())
         WebProcess::shared().injectedBundle()->willDestroyPage(this);
 
@@ -3865,6 +3869,11 @@
 
 void WebPage::didCommitLoad(WebFrame* frame)
 {
+    // If previous URL is invalid, then it's not a real page that's being navigated away from.
+    // Most likely, this is actually the first load to be committed in this page.
+    if (frame->isMainFrame() && frame->coreFrame()->loader()->previousURL().isValid())
+        reportUsedFeatures();
+
     // Only restore the scale factor for standard frame loads (of the main frame).
     if (frame->isMainFrame() && frame->coreFrame()->loader()->loadType() == FrameLoadTypeStandard) {
         Page* page = frame->coreFrame()->page();
@@ -3993,4 +4002,15 @@
     return frame->selection()->toNormalizedRange();
 }
 
+void WebPage::reportUsedFeatures()
+{
+    // FIXME: Feature names should not be hardcoded.
+    const BitVector* features = m_page->featureObserver()->accumulatedFeatureBits();
+    Vector<String> namedFeatures;
+    if (features && features->quickGet(FeatureObserver::SharedWorkerStart))
+        namedFeatures.append("SharedWorker");
+
+    m_loaderClient.featuresUsedInPage(this, namedFeatures);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (147259 => 147260)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2013-03-29 23:30:44 UTC (rev 147260)
@@ -830,6 +830,8 @@
     static PluginView* focusedPluginViewForFrame(WebCore::Frame*);
     static PluginView* pluginViewForFrame(WebCore::Frame*);
 
+    void reportUsedFeatures();
+
     OwnPtr<WebCore::Page> m_page;
     RefPtr<WebFrame> m_mainFrame;
     RefPtr<InjectedBundleBackForwardList> m_backForwardList;

Modified: trunk/Tools/ChangeLog (147259 => 147260)


--- trunk/Tools/ChangeLog	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Tools/ChangeLog	2013-03-29 23:30:44 UTC (rev 147260)
@@ -1,3 +1,13 @@
+2013-03-29  Alexey Proskuryakov  <[email protected]>
+
+        Expose FeatureObserver data to WebKit clients
+        https://bugs.webkit.org/show_bug.cgi?id=113613
+
+        Reviewed by Sam Weinig.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::InjectedBundlePage): Added an initializer for featuresUsedInPage.
+
 2013-03-29  Greg Hughes  <[email protected]>
 
         Allow multiple searchKeys to be passed to AXUIElementCopyParameterizedAttributeValue

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (147259 => 147260)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2013-03-29 23:28:34 UTC (rev 147259)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2013-03-29 23:30:44 UTC (rev 147260)
@@ -322,6 +322,7 @@
         0, // didReceiveIntentForFrame
         0, // registerIntentServiceForFrame
         0, // didLayout
+        0, // featuresUsedInPage
     };
     WKBundlePageSetPageLoaderClient(m_page, &loaderClient);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to