Modified: trunk/Source/WebKit2/ChangeLog (210560 => 210561)
--- trunk/Source/WebKit2/ChangeLog 2017-01-10 22:26:56 UTC (rev 210560)
+++ trunk/Source/WebKit2/ChangeLog 2017-01-10 22:31:06 UTC (rev 210561)
@@ -1,3 +1,31 @@
+2017-01-10 Keith Rollin <[email protected]>
+
+ Record/replay: fix range used for fuzzy matching
+ https://bugs.webkit.org/show_bug.cgi?id=166041
+
+ Reviewed by Darin Adler and Alex Christensen.
+
+ Because of two bugs, the attempt to determine the range of URLs to
+ check as part of the process of fuzzy matching was failing. The intent
+ was to find the range of URLs that started with the same
+ <scheme://host:port> as a given URL. However, because of a reversed
+ test, the upper end of the range ended up being the "end()" iterator
+ of the entire collection of URLs. With that fixed, there was another
+ bug due to one URL being given as <scheme://host:port> and the other
+ given as <scheme://host:port/> (note the trailing slash). Both of
+ these issues are now fixed.
+
+ * NetworkProcess/capture/NetworkCaptureManager.cpp:
+ (WebKit::NetworkCapture::Manager::initialize):
+ (WebKit::NetworkCapture::Manager::findBestFuzzyMatch):
+ (WebKit::NetworkCapture::Manager::urlIdentifyingCommonDomain):
+ * NetworkProcess/capture/NetworkCaptureManager.h:
+ * NetworkProcess/capture/NetworkCaptureResource.cpp:
+ (WebKit::NetworkCapture::Resource::url):
+ (WebKit::NetworkCapture::Resource::urlIdentifyingCommonDomain):
+ (WebKit::NetworkCapture::Resource::baseURL): Deleted.
+ * NetworkProcess/capture/NetworkCaptureResource.h:
+
2017-01-10 Wenson Hsieh <[email protected]>
Implement "proximity" scroll snapping
Modified: trunk/Source/WebKit2/NetworkProcess/capture/NetworkCaptureManager.cpp (210560 => 210561)
--- trunk/Source/WebKit2/NetworkProcess/capture/NetworkCaptureManager.cpp 2017-01-10 22:26:56 UTC (rev 210560)
+++ trunk/Source/WebKit2/NetworkProcess/capture/NetworkCaptureManager.cpp 2017-01-10 22:31:06 UTC (rev 210561)
@@ -62,16 +62,19 @@
void Manager::initialize(const String& recordReplayMode, const String& recordReplayCacheLocation)
{
- DEBUG_LOG("Initializing");
-
- if (equalIgnoringASCIICase(recordReplayMode, "record"))
+ if (equalIgnoringASCIICase(recordReplayMode, "record")) {
+ DEBUG_LOG("Initializing: recording mode");
m_recordReplayMode = Record;
- else if (equalIgnoringASCIICase(recordReplayMode, "replay"))
+ } else if (equalIgnoringASCIICase(recordReplayMode, "replay")) {
+ DEBUG_LOG("Initializing: replay mode");
m_recordReplayMode = Replay;
- else
+ } else {
+ DEBUG_LOG("Initializing: disabled");
m_recordReplayMode = Disabled;
+ }
m_recordReplayCacheLocation = WebCore::pathByAppendingComponent(recordReplayCacheLocation, kDirNameRecordReplay);
+ DEBUG_LOG("Cache location = " STRING_SPECIFIER, DEBUG_STR(m_recordReplayCacheLocation));
if (isRecording()) {
m_recordFileHandle = WebCore::FileHandle(reportRecordPath(), WebCore::OpenForWrite);
@@ -79,12 +82,8 @@
m_recordFileHandle = WebCore::FileHandle(reportRecordPath(), WebCore::OpenForRead);
m_loadFileHandle = WebCore::FileHandle(reportLoadPath(), WebCore::OpenForWrite);
m_replayFileHandle = WebCore::FileHandle(reportReplayPath(), WebCore::OpenForWrite);
+ loadResources();
}
-
- DEBUG_LOG("Cache location = " STRING_SPECIFIER, DEBUG_STR(m_recordReplayCacheLocation));
-
- if (isReplaying())
- loadResources();
}
void Manager::terminate()
@@ -134,17 +133,17 @@
Resource* Manager::findBestFuzzyMatch(const WebCore::ResourceRequest& request)
{
const auto& url = ""
- Resource* bestMatch = nullptr;
- int bestScore = kMinMatch;
- const auto& baseURL = url.string().left(url.pathStart());
+ const auto& urlIdentifyingCommonDomain = Manager::urlIdentifyingCommonDomain(url);
- const auto& lower = std::lower_bound(std::begin(m_cachedResources), std::end(m_cachedResources), baseURL, [](auto& resource, const auto& url) {
- return WTF::codePointCompareLessThan(resource.baseURL().string(), url);
+ const auto& lower = std::lower_bound(std::begin(m_cachedResources), std::end(m_cachedResources), urlIdentifyingCommonDomain, [](auto& resource, const auto& urlIdentifyingCommonDomain) {
+ return WTF::codePointCompareLessThan(resource.urlIdentifyingCommonDomain(), urlIdentifyingCommonDomain);
});
- const auto& upper = std::upper_bound(lower, std::end(m_cachedResources), baseURL, [](const auto& url, auto& resource) {
- return WTF::codePointCompareLessThan(resource.baseURL().string(), url);
+ const auto& upper = std::upper_bound(lower, std::end(m_cachedResources), urlIdentifyingCommonDomain, [](const auto& urlIdentifyingCommonDomain, auto& resource) {
+ return WTF::codePointCompareLessThan(urlIdentifyingCommonDomain, resource.urlIdentifyingCommonDomain());
});
+ Resource* bestMatch = nullptr;
+ int bestScore = kMinMatch;
const auto& requestParameters = WebCore::URLParser::parseURLEncodedForm(url.query());
for (auto iResource = lower; iResource != upper; ++iResource) {
int thisScore = fuzzyMatchURLs(url, requestParameters, iResource->url(), iResource->queryParameters());
@@ -419,6 +418,11 @@
return path;
}
+String Manager::urlIdentifyingCommonDomain(const WebCore::URL& url)
+{
+ return url.protocolHostAndPort();
+}
+
void Manager::logRecordedResource(const WebCore::ResourceRequest& request)
{
// Log network resources as they are cached to disk.
Modified: trunk/Source/WebKit2/NetworkProcess/capture/NetworkCaptureManager.h (210560 => 210561)
--- trunk/Source/WebKit2/NetworkProcess/capture/NetworkCaptureManager.h 2017-01-10 22:26:56 UTC (rev 210560)
+++ trunk/Source/WebKit2/NetworkProcess/capture/NetworkCaptureManager.h 2017-01-10 22:31:06 UTC (rev 210561)
@@ -83,6 +83,7 @@
WebCore::FileHandle openCacheFile(const String&, WebCore::FileOpenMode);
String requestToPath(const WebCore::ResourceRequest&);
+ static String urlIdentifyingCommonDomain(const WebCore::URL&);
private:
Manager() = default;
Modified: trunk/Source/WebKit2/NetworkProcess/capture/NetworkCaptureResource.cpp (210560 => 210561)
--- trunk/Source/WebKit2/NetworkProcess/capture/NetworkCaptureResource.cpp 2017-01-10 22:26:56 UTC (rev 210560)
+++ trunk/Source/WebKit2/NetworkProcess/capture/NetworkCaptureResource.cpp 2017-01-10 22:31:06 UTC (rev 210561)
@@ -30,6 +30,7 @@
#include "NetworkCaptureEvent.h"
#include "NetworkCaptureLogging.h"
+#include "NetworkCaptureManager.h"
#include "NetworkCaptureRecorder.h"
namespace WebKit {
@@ -42,7 +43,7 @@
const WebCore::URL& Resource::url()
{
- if (!m_url) {
+ if (!m_url.isValid()) {
auto events = eventStream();
auto event = events.nextEvent();
if (!event)
@@ -56,19 +57,15 @@
}
}
- return *m_url;
+ return m_url;
}
-const WebCore::URL& Resource::baseURL()
+const String& Resource::urlIdentifyingCommonDomain()
{
- if (!m_baseURL) {
- auto pathStart = url().pathStart();
- auto baseURLStr = url().string().left(pathStart);
- WebCore::URLParser parser(baseURLStr);
- m_baseURL = parser.result();
- }
+ if (m_urlIdentifyingCommonDomain.isNull())
+ m_urlIdentifyingCommonDomain = Manager::urlIdentifyingCommonDomain(url());
- return *m_baseURL;
+ return m_urlIdentifyingCommonDomain;
}
WebCore::URLParser::URLEncodedForm Resource::queryParameters()
Modified: trunk/Source/WebKit2/NetworkProcess/capture/NetworkCaptureResource.h (210560 => 210561)
--- trunk/Source/WebKit2/NetworkProcess/capture/NetworkCaptureResource.h 2017-01-10 22:26:56 UTC (rev 210560)
+++ trunk/Source/WebKit2/NetworkProcess/capture/NetworkCaptureResource.h 2017-01-10 22:31:06 UTC (rev 210561)
@@ -56,14 +56,14 @@
Resource(const String& eventFilePath);
const WebCore::URL& url();
- const WebCore::URL& baseURL();
+ const String& urlIdentifyingCommonDomain();
WebCore::URLParser::URLEncodedForm queryParameters();
EventStream eventStream();
private:
String m_eventFilePath;
- std::optional<WebCore::URL> m_url;
- std::optional<WebCore::URL> m_baseURL;
+ WebCore::URL m_url;
+ String m_urlIdentifyingCommonDomain;
std::optional<WebCore::URLParser::URLEncodedForm> m_queryParameters;
};