PSON: http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Jun 2018 22:16:10 +0000 (22:16 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Jun 2018 22:16:10 +0000 (22:16 +0000)
commit929042f2f448e1fb1f1ce3198c4271354b618507
treeb5a27389238bc00f50ea6712d0b4279607eb9cde
parent157a4d48dcf9aea1605f32a064add3fa8265bc0f
PSON: http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html ASSERTS with process swap enabled
https://bugs.webkit.org/show_bug.cgi?id=186545

Reviewed by Brady Eidson.

Source/WebCore:

Move frame navigation logging for ITP purposes from the WebProcess to the UIProcess.
This information was previously logged in DocumentLoader::willSendRequest() and was getting
sync'd to the UIProcess at regular intervals or when the layout tests call testRunner's
statisticsNotifyObserver(). We now do the logging directly in the UIProcess, in
WebPageProxy::decidePolicyForNavigationAction (which was getting called via IPC from
DocumentLoader::willSendRequest()).

This is more efficient and will also be needed soon due to the way process swap on navigation
deals with cross-origin redirects. On cross-origin redirect of the main frame, PSON cancels
the load and started a new load to the redirected to URL in the new WebProcess. As a result,
the new WebProcess is not aware that the load is a redirect, which is information that ITP
requires. By moving the ITP logging to the UIProcess, we still have access to this
information.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::willSendRequest):
Stop logging the navigation now that it is logged in the UIProcess.

* loader/EmptyClients.cpp:
(WebCore::EmptyFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* loader/EmptyFrameLoaderClient.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadURL):
(WebCore::FrameLoader::loadWithDocumentLoader):
* loader/FrameLoaderClient.h:
* loader/PolicyChecker.cpp:
(WebCore::PolicyChecker::checkNavigationPolicy):
* loader/PolicyChecker.h:
We now pass the full redirect request to the decidePolicyForNavigationAction
delegate instead of a simple isRedirect boolean, so that we have the redirect
response URL in the UIProcess for ITP logging.

* loader/ResourceLoadObserver.cpp:
(WebCore::areDomainsAssociated):
(WebCore::ResourceLoadObserver::logSubresourceLoading):
(WebCore::ResourceLoadObserver::logWebSocketLoading):
(WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
* loader/ResourceLoadObserver.h:
* loader/ResourceLoadStatistics.cpp:
(WebCore::ResourceLoadStatistics::areDomainsAssociated):
(WebCore::ResourceLoadStatistics::reduceTimeResolution):
* loader/ResourceLoadStatistics.h:
- Remove ResourceLoadObserver::logFrameNavigation() now that it is on the WebResourceLoadStatisticsStore.
- Move some code from ResourceLoadObserver to ResourceLoadStatistics so that it can
  be called from the UIProcess and to avoid code duplication.

Source/WebKit:

Move frame navigation logging for ITP purposes from the WebProcess to the UIProcess.
This information was previously logged in DocumentLoader::willSendRequest() and was getting
sync'd to the UIProcess at regular intervals or when the layout tests call testRunner's
statisticsNotifyObserver(). We now do the logging directly in the UIProcess, in
WebPageProxy::decidePolicyForNavigationAction (which was getting called via IPC from
DocumentLoader::willSendRequest()).

This is more efficient and will also be needed soon due to the way process swap on navigation
deals with cross-origin redirects. On cross-origin redirect of the main frame, PSON cancels
the load and started a new load to the redirected to URL in the new WebProcess. As a result,
the new WebProcess is not aware that the load is a redirect, which is information that ITP
requires. By moving the ITP logging to the UIProcess, we still have access to this
information.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
(WebKit::WebPageProxy::decidePolicyForNavigationActionSync):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
- We now pass the full redirect response the the delegate method instead of a simple
isRedirect boolean.
- Log the navigation in the WebResourceLoadStatisticsStore for ITP purposes.

* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::areDomainsAssociated):
Equivalent of ResourceLoadObserver's areDomainsAssociated(). Most of the logic was moved
to ResourceLoadStatistics::areDomainsAssociated() to avoid code duplication.

(WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
This is called whenever a WebProcess sends new resource load statistics to the UIProcess.
Whenever this happens, we call processStatisticsAndDataRecords() right away, which is
sometimes the tests currently rely on. As a result, we can cancels any pending statistics
processing request that was scheduled by logFrameNavigation().

(WebKit::WebResourceLoadStatisticsStore::scheduleStatisticsProcessingRequestIfNecessary):
(WebKit::WebResourceLoadStatisticsStore::cancelPendingStatisticsProcessingRequest):
Whenever a navigation is logged and statistics have been updated, we need to make sure we
schedule a "timer" to process the new data. We do this at most every 5 seconds for performance
reasons. This 5 second interval matches what the ResourceLoadObserver is using in the WebProcess
to notify the UIProcess of new data.

(WebKit::WebResourceLoadStatisticsStore::logFrameNavigation):
This code was moved from ResourceLoadObserver to WebResourceLoadStatisticsStore now that we
do this logging in the UIProcess instead of the WebProcess. One difference with WebCore is
that we use WebPageProxy::pageLoadState().url() as mainFrameURL instead of
WebPageProxy::mainFrame().url(). The reason for that is that WebPageProxy::mainFrame().url()
becomes empty in case of process swap but ITP still needs the actual main frame URL when the
navigation was triggered. WebPageProxy::pageLoadState().url() gives us this information.

* UIProcess/WebResourceLoadStatisticsStore.h:

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
We now pass the full redirect response the the delegate method instead of a simple
isRedirect boolean.

Source/WebKitLegacy/mac:

Update client delegate now that parameter type has changed.

* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):

Source/WebKitLegacy/win:

Update client delegate now that parameter type has changed.

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* WebCoreSupport/WebFrameLoaderClient.h:

LayoutTests:

Attempt to mark the test as non-flaky now that it no longer relies on sync'ing from the WebProcess
to the UIProcess.

* platform/wk2/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232814 268f45cc-cd09-0410-ab3c-d52691b4dbfc
29 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/loader/EmptyFrameLoaderClient.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoaderClient.h
Source/WebCore/loader/PolicyChecker.cpp
Source/WebCore/loader/PolicyChecker.h
Source/WebCore/loader/ResourceLoadObserver.cpp
Source/WebCore/loader/ResourceLoadObserver.h
Source/WebCore/loader/ResourceLoadStatistics.cpp
Source/WebCore/loader/ResourceLoadStatistics.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h