From bcd71def9f7fadb074abb68c82bae179b65b0e74 Mon Sep 17 00:00:00 2001
From: Mike Perry <mikeperry-git@torproject.org>
Date: Tue, 4 Dec 2012 16:05:55 -0800
Subject: [PATCH 12/41] Make Download manager memory only.

Solves https://trac.torproject.org/projects/tor/ticket/4017.

Yes, this is an ugly hack. We *could* send the observer notification from
Torbutton to tell the download manager to switch to memory, but then we have
to dance around and tell it again if the user switches in and out of private
browsing mode..

The right way to do this is with a pref. Maybe I'll get to that someday, if
this breaks enough times in conflict.
---
 toolkit/components/downloads/nsDownloadManager.cpp | 4 ++--
 toolkit/components/downloads/nsDownloadManager.h   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/toolkit/components/downloads/nsDownloadManager.cpp b/toolkit/components/downloads/nsDownloadManager.cpp
index 024686f..7845544 100644
--- a/toolkit/components/downloads/nsDownloadManager.cpp
+++ b/toolkit/components/downloads/nsDownloadManager.cpp
@@ -2002,7 +2002,7 @@ nsDownloadManager::Observe(nsISupports *aSubject,
     if (NS_LITERAL_STRING("memory").Equals(aData))
       return SwitchDatabaseTypeTo(DATABASE_MEMORY);
     else if (NS_LITERAL_STRING("disk").Equals(aData))
-      return SwitchDatabaseTypeTo(DATABASE_DISK);
+      return SwitchDatabaseTypeTo(DATABASE_MEMORY);
   }
   else if (strcmp(aTopic, "alertclickcallback") == 0) {
     nsCOMPtr<nsIDownloadManagerUI> dmui =
@@ -2079,7 +2079,7 @@ nsDownloadManager::OnLeavePrivateBrowsingMode()
   (void)ResumeAllDownloads(false);
 
   // Switch back to the on-disk DB again
-  (void)SwitchDatabaseTypeTo(DATABASE_DISK);
+  //(void)SwitchDatabaseTypeTo(DATABASE_DISK);
 
   mInPrivateBrowsing = false;
 }
diff --git a/toolkit/components/downloads/nsDownloadManager.h b/toolkit/components/downloads/nsDownloadManager.h
index bbe7f39..6bdad89 100644
--- a/toolkit/components/downloads/nsDownloadManager.h
+++ b/toolkit/components/downloads/nsDownloadManager.h
@@ -54,7 +54,7 @@ public:
 
   virtual ~nsDownloadManager();
   nsDownloadManager() :
-      mDBType(DATABASE_DISK)
+      mDBType(DATABASE_MEMORY)
     , mInPrivateBrowsing(false)
 #ifdef DOWNLOAD_SCANNER
     , mScanner(nullptr)
-- 
1.8.1.2

