From 93ae3fe3a8e415635387bc301d1ee319f6530d86 Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Tue, 16 Jun 2015 17:39:05 -0700 Subject: [PATCH] Bug 1173439 P3 Use url query field for database matching and Request creation. r=ehsan --- dom/cache/DBSchema.cpp | 22 ++++++++++++---------- dom/cache/TypeUtils.cpp | 6 +++++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/dom/cache/DBSchema.cpp b/dom/cache/DBSchema.cpp index 1f176fe51f4..5fbffa0fee7 100644 --- a/dom/cache/DBSchema.cpp +++ b/dom/cache/DBSchema.cpp @@ -937,19 +937,14 @@ QueryCache(mozIStorageConnection* aConn, CacheId aCacheId, "LEFT OUTER JOIN response_headers ON entries.id=response_headers.entry_id " "AND response_headers.name='vary' " "WHERE entries.cache_id=:cache_id " - "AND entries." + "AND entries.request_url_no_query=:url_no_query " ); - nsAutoCString urlToMatch; - if (aParams.ignoreSearch()) { - urlToMatch = aRequest.urlWithoutQuery(); - query.AppendLiteral("request_url_no_query"); - } else { - urlToMatch = aRequest.url(); - query.AppendLiteral("request_url"); + if (!aParams.ignoreSearch()) { + query.AppendLiteral("AND entries.request_url_query=:url_query "); } - query.AppendLiteral("=:url GROUP BY entries.id ORDER BY entries.id;"); + query.AppendLiteral("GROUP BY entries.id ORDER BY entries.id;"); nsCOMPtr state; nsresult rv = aConn->CreateStatement(query, getter_AddRefs(state)); @@ -958,9 +953,16 @@ QueryCache(mozIStorageConnection* aConn, CacheId aCacheId, rv = state->BindInt64ByName(NS_LITERAL_CSTRING("cache_id"), aCacheId); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } - rv = state->BindUTF8StringByName(NS_LITERAL_CSTRING("url"), urlToMatch); + rv = state->BindUTF8StringByName(NS_LITERAL_CSTRING("url_no_query"), + aRequest.urlWithoutQuery()); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } + if (!aParams.ignoreSearch()) { + rv = state->BindUTF8StringByName(NS_LITERAL_CSTRING("url_query"), + aRequest.urlQuery()); + if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } + } + bool hasMoreData = false; while (NS_SUCCEEDED(state->ExecuteStep(&hasMoreData)) && hasMoreData) { // no invalid EntryId, init to least likely real value diff --git a/dom/cache/TypeUtils.cpp b/dom/cache/TypeUtils.cpp index 50c924c0723..b1863d3ee32 100644 --- a/dom/cache/TypeUtils.cpp +++ b/dom/cache/TypeUtils.cpp @@ -321,7 +321,11 @@ TypeUtils::ToInternalRequest(const CacheRequest& aIn) nsRefPtr internalRequest = new InternalRequest(); internalRequest->SetMethod(aIn.method()); - internalRequest->SetURL(aIn.url()); + + nsAutoCString url(aIn.urlWithoutQuery()); + url.Append(aIn.urlQuery()); + internalRequest->SetURL(url); + internalRequest->SetReferrer(aIn.referrer()); internalRequest->SetMode(aIn.mode()); internalRequest->SetCredentialsMode(aIn.credentials());