Commit ad9c8788 authored by Kris Maglione's avatar Kris Maglione
Browse files

Bug 1724509: Part 2 - Don't load preloader caches when startup cache is being ignored. r=mccr8

parent 18ef3e62
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/Document.h"
#include "mozilla/scache/StartupCache.h"

#include "js/CompileOptions.h"  // JS::ReadOnlyCompileOptions
#include "js/experimental/JSStencil.h"
@@ -65,6 +66,9 @@ using mozilla::dom::AutoJSAPI;
using mozilla::dom::ContentChild;
using mozilla::dom::ContentParent;
using namespace mozilla::loader;
using mozilla::scache::StartupCache;

using namespace JS;

ProcessType ScriptPreloader::sProcessType;

@@ -392,6 +396,10 @@ Result<nsCOMPtr<nsIFile>, nsresult> ScriptPreloader::GetCacheFile(
static const uint8_t MAGIC[] = "mozXDRcachev002";

Result<Ok, nsresult> ScriptPreloader::OpenCache() {
  if (StartupCache::GetIgnoreDiskCache()) {
    return Err(NS_ERROR_ABORT);
  }

  MOZ_TRY(NS_GetSpecialDirectory("ProfLDS", getter_AddRefs(mProfD)));

  nsCOMPtr<nsIFile> cacheFile;
+6 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include "mozilla/Services.h"
#include "mozilla/Unused.h"
#include "mozilla/Vector.h"
#include "mozilla/scache/StartupCache.h"

#include "MainThreadUtils.h"
#include "nsPrintfCString.h"
@@ -44,6 +45,7 @@ bool StartsWith(const T& haystack, const T& needle) {
}  // anonymous namespace

using namespace mozilla::loader;
using mozilla::scache::StartupCache;

nsresult URLPreloader::CollectReports(nsIHandleReportCallback* aHandleReport,
                                      nsISupports* aData, bool aAnonymize) {
@@ -168,6 +170,10 @@ Result<nsCOMPtr<nsIFile>, nsresult> URLPreloader::GetCacheFile(
static const uint8_t URL_MAGIC[] = "mozURLcachev002";

Result<nsCOMPtr<nsIFile>, nsresult> URLPreloader::FindCacheFile() {
  if (StartupCache::GetIgnoreDiskCache()) {
    return Err(NS_ERROR_ABORT);
  }

  nsCOMPtr<nsIFile> cacheFile;
  MOZ_TRY_VAR(cacheFile, GetCacheFile(u".bin"_ns));

+4 −0
Original line number Diff line number Diff line
@@ -695,6 +695,10 @@ void StartupCache::IgnoreDiskCache() {
  if (gStartupCache) gStartupCache->InvalidateCache();
}

bool StartupCache::GetIgnoreDiskCache() {
  return gIgnoreDiskCache;
}

void StartupCache::WaitOnPrefetchThread() {
  if (!mPrefetchThread || mPrefetchThread == PR_GetCurrentThread()) return;

+2 −0
Original line number Diff line number Diff line
@@ -165,6 +165,8 @@ class StartupCache : public nsIMemoryReporter {
  // Signal that data should not be loaded from the cache file
  static void IgnoreDiskCache();

  static bool GetIgnoreDiskCache();

  // In DEBUG builds, returns a stream that will attempt to check for
  // and disallow multiple writes of the same object.
  nsresult GetDebugObjectOutputStream(nsIObjectOutputStream* aStream,