Bug 1173439 P3 Use url query field for database matching and Request creation. r=ehsan
authorBen Kelly <ben@wanderview.com>
Tue, 16 Jun 2015 17:39:05 -0700
changeset 280056 619c2a4e7ce2d82cb8e4bd6b0bfa7871ecb53b29
parent 280055 818edd204d7b0cd9f1293ab5de0522a8a022a05c
child 280057 12ccbd45dcb5d403481fa5f9441eb6e4f2a41361
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1173439
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1173439 P3 Use url query field for database matching and Request creation. r=ehsan
dom/cache/DBSchema.cpp
dom/cache/TypeUtils.cpp
--- a/dom/cache/DBSchema.cpp
+++ b/dom/cache/DBSchema.cpp
@@ -932,40 +932,42 @@ QueryCache(mozIStorageConnection* aConn,
   }
 
   nsAutoCString query(
     "SELECT id, COUNT(response_headers.name) AS vary_count "
     "FROM entries "
     "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<mozIStorageStatement> state;
   nsresult rv = aConn->CreateStatement(query, getter_AddRefs(state));
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
   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
     EntryId entryId = INT32_MAX;
     rv = state->GetInt32(0, &entryId);
     if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
     int32_t varyCount;
--- a/dom/cache/TypeUtils.cpp
+++ b/dom/cache/TypeUtils.cpp
@@ -316,17 +316,21 @@ TypeUtils::ToResponse(const CacheRespons
 }
 
 already_AddRefed<InternalRequest>
 TypeUtils::ToInternalRequest(const CacheRequest& aIn)
 {
   nsRefPtr<InternalRequest> 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());
   internalRequest->SetContentPolicyType(aIn.contentPolicyType());
   internalRequest->SetCacheMode(aIn.requestCache());
 
   nsRefPtr<InternalHeaders> internalHeaders =
     ToInternalHeaders(aIn.headers(), aIn.headersGuard());