Backed out changeset 50220dbf59ed (bug 1064258) for xpcshell failures; CLOSED TREE
authorEd Morley <emorley@mozilla.com>
Mon, 29 Sep 2014 17:43:10 +0100
changeset 230930 da12cd0ebe40db3492857c4067b77c662ac0bf0c
parent 230929 8d578891aa895100ab0f5cf312b13a9313ff5860
child 230931 ce9a0b34225e2864695d827634c28196db8d8855
child 230991 abf96b7fa9631134005b1283c2c7e8c91731fa84
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1064258
milestone35.0a1
backs out50220dbf59ed0e5d2acaa4345f677fc2d80b60cf
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
Backed out changeset 50220dbf59ed (bug 1064258) for xpcshell failures; CLOSED TREE
netwerk/base/public/nsICachingChannel.idl
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsHttpChannel.h
netwerk/test/unit/test_bug1064258.js
netwerk/test/unit/xpcshell.ini
--- a/netwerk/base/public/nsICachingChannel.idl
+++ b/netwerk/base/public/nsICachingChannel.idl
@@ -12,17 +12,17 @@ interface nsIFile;
  * to affect its behavior with respect to how it uses the cache service.
  *
  * This interface provides:
  *   1) Support for "stream as file" semantics (for JAR and plugins).
  *   2) Support for "pinning" cached data in the cache (for printing and save-as).
  *   3) Support for uniquely identifying cached data in cases when the URL
  *      is insufficient (e.g., HTTP form submission).
  */
-[scriptable, uuid(3d46b469-7405-416e-ba42-84899963b403)]
+[scriptable, uuid(a77b664e-e707-4017-9c03-47bcedcb5b05)]
 interface nsICachingChannel : nsICacheInfoChannel
 {
     /**
      * Set/get the cache token... uniquely identifies the data in the cache.
      * Holding a reference to this token prevents the cached data from being
      * removed.
      * 
      * A cache token retrieved from a particular instance of nsICachingChannel
@@ -59,24 +59,16 @@ interface nsICachingChannel : nsICacheIn
      * the cache entry may be validated, overwritten, or simply read.
      *
      * The cache key may be NULL indicating that the URI of the channel is
      * sufficient to locate the same cache entry.  Setting a NULL cache key
      * is likewise valid.
      */
     attribute nsISupports cacheKey;
 
-    /**
-     * Instructs the channel to only store the metadata of the entry, and not
-     * the content. When reading an existing entry, this automatically sets
-     * LOAD_ONLY_IF_MODIFIED flag.
-     * Must be called before asyncOpen().
-     */
-    attribute boolean cacheOnlyMetadata;
-
     /**************************************************************************
      * Caching channel specific load flags:
      */
 
     /**
      * This load flag inhibits fetching from the net.  An error of
      * NS_ERROR_DOCUMENT_NOT_CACHED will be sent to the listener's
      * onStopRequest if network IO is necessary to complete the request.
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -203,17 +203,16 @@ AutoRedirectVetoNotifier::ReportRedirect
 nsHttpChannel::nsHttpChannel()
     : HttpAsyncAborter<nsHttpChannel>(MOZ_THIS_IN_INITIALIZER_LIST())
     , mLogicalOffset(0)
     , mPostID(0)
     , mRequestTime(0)
     , mOfflineCacheLastModifiedTime(0)
     , mCachedContentIsValid(false)
     , mCachedContentIsPartial(false)
-    , mCacheOnlyMetadata(false)
     , mTransactionReplaced(false)
     , mAuthRetryPending(false)
     , mProxyAuthPending(false)
     , mResuming(false)
     , mInitedCacheEntry(false)
     , mFallbackChannel(false)
     , mCustomConditionalRequest(false)
     , mFallingBack(false)
@@ -2796,25 +2795,18 @@ nsHttpChannel::OnCacheEntryCheck(nsICach
             LOG(("Cached data size does not match the Content-Length header "
                  "[content-length=%lld size=%lld]\n", contentLength, size));
 
             rv = MaybeSetupByteRangeRequest(size, contentLength);
             mCachedContentIsPartial = NS_SUCCEEDED(rv) && mIsPartialRequest;
             if (mCachedContentIsPartial) {
                 rv = OpenCacheInputStream(entry, false, !!appCache);
                 *aResult = ENTRY_NEEDS_REVALIDATION;
-            } else if (size == 0 && mCacheOnlyMetadata) {
-                // Don't break cache entry load when the entry's data size
-                // is 0 and mCacheOnlyMetadata flag is set. In that case we
-                // want to proceed since the LOAD_ONLY_IF_MODIFIED flag is
-                // also set.
-                MOZ_ASSERT(mLoadFlags & LOAD_ONLY_IF_MODIFIED);
-            } else {
-                return rv;
             }
+            return rv;
         }
     }
 
     bool usingSSL = false;
     rv = mURI->SchemeIs("https", &usingSSL);
     NS_ENSURE_SUCCESS(rv,rv);
 
     bool doValidation = false;
@@ -3980,34 +3972,24 @@ nsHttpChannel::InstallCacheListener(int6
     // We must close the input stream first because cache entries do not
     // correctly handle having an output stream and input streams open at
     // the same time.
     mCacheInputStream.CloseAndRelease();
 
     nsCOMPtr<nsIOutputStream> out;
     rv = mCacheEntry->OpenOutputStream(offset, getter_AddRefs(out));
     if (rv == NS_ERROR_NOT_AVAILABLE) {
-        LOG(("  entry doomed, not writing it [channel=%p]", this));
-        // Entry is already doomed.
-        // This may happen when expiration time is set to past and the entry
-        // has been removed by the background eviction logic.
-        return NS_OK;
+      LOG(("  entry doomed, not writing it [channel=%p]", this));
+      // Entry is already doomed.
+      // This may happen when expiration time is set to past and the entry
+      // has been removed by the background eviction logic.
+      return NS_OK;
     }
     if (NS_FAILED(rv)) return rv;
 
-    if (mCacheOnlyMetadata) {
-        LOG(("Not storing content, cacheOnlyMetadata set"));
-        // We must open and then close the output stream of the cache entry.
-        // This way we indicate the content has been written (despite with zero
-        // length) and the entry is now in the ready state with "having data".
-
-        out->Close();
-        return NS_OK;
-    }
-
     // XXX disk cache does not support overlapped i/o yet
 #if 0
     // Mark entry valid inorder to allow simultaneous reading...
     rv = mCacheEntry->MarkValid();
     if (NS_FAILED(rv)) return rv;
 #endif
 
     nsCOMPtr<nsIStreamListenerTee> tee =
@@ -5703,40 +5685,16 @@ nsHttpChannel::SetCacheKey(nsISupports *
         if (NS_FAILED(rv)) return rv;
 
         rv = container->GetData(&mPostID);
         if (NS_FAILED(rv)) return rv;
     }
     return NS_OK;
 }
 
-NS_IMETHODIMP
-nsHttpChannel::GetCacheOnlyMetadata(bool *aOnlyMetadata)
-{
-    NS_ENSURE_ARG(aOnlyMetadata);
-    *aOnlyMetadata = mCacheOnlyMetadata;
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsHttpChannel::SetCacheOnlyMetadata(bool aOnlyMetadata)
-{
-    LOG(("nsHttpChannel::SetCacheOnlyMetadata [this=%p only-metadata=%d]\n",
-        this, aOnlyMetadata));
-
-    ENSURE_CALLED_BEFORE_ASYNC_OPEN();
-
-    mCacheOnlyMetadata = aOnlyMetadata;
-    if (aOnlyMetadata) {
-        mLoadFlags |= LOAD_ONLY_IF_MODIFIED;
-    }
-
-    return NS_OK;
-}
-
 //-----------------------------------------------------------------------------
 // nsHttpChannel::nsIResumableChannel
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsHttpChannel::ResumeAt(uint64_t aStartPos,
                         const nsACString& aEntityID)
 {
--- a/netwerk/protocol/http/nsHttpChannel.h
+++ b/netwerk/protocol/http/nsHttpChannel.h
@@ -370,17 +370,16 @@ private:
     uint32_t                          mRedirectType;
 
     static const uint32_t WAIT_FOR_CACHE_ENTRY = 1;
     static const uint32_t WAIT_FOR_OFFLINE_CACHE_ENTRY = 2;
 
     // state flags
     uint32_t                          mCachedContentIsValid     : 1;
     uint32_t                          mCachedContentIsPartial   : 1;
-    uint32_t                          mCacheOnlyMetadata        : 1;
     uint32_t                          mTransactionReplaced      : 1;
     uint32_t                          mAuthRetryPending         : 1;
     uint32_t                          mProxyAuthPending         : 1;
     uint32_t                          mResuming                 : 1;
     uint32_t                          mInitedCacheEntry         : 1;
     // True if we are loading a fallback cache entry from the
     // application cache.
     uint32_t                          mFallbackChannel          : 1;
deleted file mode 100644
--- a/netwerk/test/unit/test_bug1064258.js
+++ /dev/null
@@ -1,154 +0,0 @@
-/**
- * Check how nsICachingChannel.cacheOnlyMetadata works.
- * - all channels involved in this test are set cacheOnlyMetadata = true
- * - do a previously uncached request for a long living content
- * - check we have downloaded the content from the server (channel provides it)
- * - check the entry has metadata, but zero-length content
- * - load the same URL again, now cached
- * - check the channel is giving no content (no call to OnDataAvailable) but succeeds
- * - repeat again, but for a different URL that is not cached (immediately expires)
- * - only difference is that we get a newer version of the content from the server during the second request
- */
-
-Cu.import("resource://testing-common/httpd.js");
-
-XPCOMUtils.defineLazyGetter(this, "URL", function() {
-  return "http://localhost:" + httpServer.identity.primaryPort;
-});
-
-var httpServer = null;
-
-function make_channel(url, callback, ctx) {
-  var ios = Cc["@mozilla.org/network/io-service;1"].
-            getService(Ci.nsIIOService);
-  return ios.newChannel(url, "", null);
-}
-
-const responseBody1 = "response body 1";
-const responseBody2a = "response body 2a";
-const responseBody2b = "response body 2b";
-
-function contentHandler1(metadata, response)
-{
-  response.setHeader("Content-Type", "text/plain");
-  response.setHeader("Cache-control", "max-age=999999");
-  response.bodyOutputStream.write(responseBody1, responseBody1.length);
-}
-
-var content2passCount = 0;
-
-function contentHandler2(metadata, response)
-{
-  response.setHeader("Content-Type", "text/plain");
-  response.setHeader("Cache-control", "no-cache");
-  switch (content2passCount++) {
-    case 0:
-      response.setHeader("ETag", "testetag");
-      response.bodyOutputStream.write(responseBody2a, responseBody2a.length);
-      break;
-    case 1:
-      do_check_true(metadata.hasHeader("If-None-Match"));
-      do_check_eq(metadata.getHeader("If-None-Match"), "testetag");
-      response.bodyOutputStream.write(responseBody2b, responseBody2b.length);
-      break;
-    default:
-      throw "Unexpected request in the test";
-  }
-}
-
-
-function run_test()
-{
-  httpServer = new HttpServer();
-  httpServer.registerPathHandler("/content1", contentHandler1);
-  httpServer.registerPathHandler("/content2", contentHandler2);
-  httpServer.start(-1);
-
-  run_test_content1a();
-  do_test_pending();
-}
-
-function run_test_content1a()
-{
-  var chan = make_channel(URL + "/content1");
-  caching = chan.QueryInterface(Ci.nsICachingChannel);
-  caching.cacheOnlyMetadata = true;
-  chan.asyncOpen(new ChannelListener(contentListener1a, null), null);
-}
-
-function contentListener1a(request, buffer)
-{
-  do_check_eq(buffer, responseBody1);
-
-  asyncOpenCacheEntry(URL + "/content1", "disk", 0, null, cacheCheck1)
-}
-
-function cacheCheck1(status, entry)
-{
-  do_check_eq(status, 0);
-  do_check_eq(entry.dataSize, 0);
-  try {
-    do_check_neq(entry.getMetaDataElement("response-head"), null);
-  }
-  catch (ex) {
-    do_throw("Missing response head");
-  }
-
-  var chan = make_channel(URL + "/content1");
-  caching = chan.QueryInterface(Ci.nsICachingChannel);
-  caching.cacheOnlyMetadata = true;
-  chan.asyncOpen(new ChannelListener(contentListener1b, null, CL_IGNORE_CL), null);
-}
-
-function contentListener1b(request, buffer)
-{
-  request.QueryInterface(Ci.nsIHttpChannel);
-  do_check_eq(request.requestMethod, "GET");
-  do_check_eq(request.responseStatus, 200);
-  do_check_eq(request.getResponseHeader("Cache-control"), "max-age=999999");
-
-  do_check_eq(buffer, "");
-  run_test_content2a();
-}
-
-// Now same set of steps but this time for an immediately expiring content.
-
-function run_test_content2a()
-{
-  var chan = make_channel(URL + "/content2");
-  caching = chan.QueryInterface(Ci.nsICachingChannel);
-  caching.cacheOnlyMetadata = true;
-  chan.asyncOpen(new ChannelListener(contentListener2a, null), null);
-}
-
-function contentListener2a(request, buffer)
-{
-  do_check_eq(buffer, responseBody2a);
-
-  asyncOpenCacheEntry(URL + "/content2", "disk", 0, null, cacheCheck2)
-}
-
-function cacheCheck2(status, entry)
-{
-  do_check_eq(status, 0);
-  do_check_eq(entry.dataSize, 0);
-  try {
-    do_check_neq(entry.getMetaDataElement("response-head"), null);
-    do_check_true(entry.getMetaDataElement("response-head").match('Etag: testetag'));
-  }
-  catch (ex) {
-    do_throw("Missing response head");
-  }
-
-  var chan = make_channel(URL + "/content2");
-  caching = chan.QueryInterface(Ci.nsICachingChannel);
-  caching.cacheOnlyMetadata = true;
-  chan.asyncOpen(new ChannelListener(contentListener2b, null), null);
-}
-
-function contentListener2b(request, buffer)
-{
-  do_check_eq(buffer, responseBody2b);
-
-  httpServer.stop(do_test_finished);
-}
--- a/netwerk/test/unit/xpcshell.ini
+++ b/netwerk/test/unit/xpcshell.ini
@@ -153,17 +153,16 @@ skip-if = os == "android"
 [test_bug667818.js]
 [test_bug669001.js]
 [test_bug712914_secinfo_validation.js]
 [test_bug770243.js]
 [test_bug894586.js]
 # Allocating 4GB might actually succeed on 64 bit machines
 skip-if = bits != 32
 [test_bug935499.js]
-[test_bug1064258.js]
 [test_udpsocket.js]
 [test_doomentry.js]
 [test_cacheflags.js]
 [test_cache_jar.js]
 [test_channel_close.js]
 [test_compareURIs.js]
 [test_compressappend.js]
 [test_content_encoding_gzip.js]