Bug 1398043 - P2: Temporary fix for updating the existing response_padding_size to 0 when it's an opaque response with null padding size. r?bkelly draft
authorTom Tung <shes050117@gmail.com>
Fri, 08 Sep 2017 17:23:52 +0800
changeset 661479 c1329049e5af6f56a7994b60931c33814883876c
parent 661310 8374783aa42d7e55710b1558dbe872bda1392aac
child 661480 9e2f2c6c90a7c6367983633e484bc964ff653f5e
push id78771
push userttung@mozilla.com
push dateFri, 08 Sep 2017 14:30:55 +0000
reviewersbkelly
bugs1398043
milestone57.0a1
Bug 1398043 - P2: Temporary fix for updating the existing response_padding_size to 0 when it's an opaque response with null padding size. r?bkelly MozReview-Commit-ID: EKcUwqfTWvj
dom/cache/DBSchema.cpp
--- a/dom/cache/DBSchema.cpp
+++ b/dom/cache/DBSchema.cpp
@@ -2079,17 +2079,27 @@ ReadResponse(mozIStorageConnection* aCon
     aSavedResponseOut->mValue.principalInfo() =
       mozilla::ipc::ContentPrincipalInfo(attrs, void_t(), specNoSuffix);
   }
 
   bool nullPadding = false;
   rv = state->GetIsNull(6, &nullPadding);
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
+#ifdef NIGHTLY_BUILD
+  bool shouldUpdateTo26 = false;
+  if (nullPadding && aSavedResponseOut->mValue.type() == ResponseType::Opaque) {
+    // XXXtt: This should be removed in the future (e.g. Nightly 58) by
+    // bug 1398167.
+    shouldUpdateTo26 = true;
+    aSavedResponseOut->mValue.paddingSize() = 0;
+  } else if (nullPadding) {
+#else
   if (nullPadding) {
+#endif // NIGHTLY_BUILD
     MOZ_DIAGNOSTIC_ASSERT(aSavedResponseOut->mValue.type() !=
                           ResponseType::Opaque);
     aSavedResponseOut->mValue.paddingSize() =
       InternalResponse::UNKNOWN_PADDING_SIZE;
   } else {
     MOZ_DIAGNOSTIC_ASSERT(aSavedResponseOut->mValue.type() ==
                           ResponseType::Opaque);
     int64_t paddingSize = 0;
@@ -2098,16 +2108,30 @@ ReadResponse(mozIStorageConnection* aCon
 
     MOZ_DIAGNOSTIC_ASSERT(paddingSize >= 0);
     aSavedResponseOut->mValue.paddingSize() = paddingSize;
   }
 
   rv = state->GetBlobAsUTF8String(7, aSavedResponseOut->mValue.channelInfo().securityInfo());
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
 
+#ifdef NIGHTLY_BUILD
+  if (shouldUpdateTo26) {
+    // XXXtt: This is a quick fix for not updating properly in Nightly 57.
+    // Note: This should be removed in the future (e.g. Nightly 58) by
+    // bug 1398167.
+    rv = aConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
+      "UPDATE entries SET response_padding_size = 0 "
+        "WHERE response_type = 4 " // opaque response
+          "AND response_padding_size IS NULL"
+    ));
+    if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
+  }
+#endif // NIGHTLY_BUILD
+
   rv = aConn->CreateStatement(NS_LITERAL_CSTRING(
     "SELECT "
       "name, "
       "value "
     "FROM response_headers "
     "WHERE entry_id=:entry_id;"
   ), getter_AddRefs(state));
   if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }