Backing out mardak's Bug 251337 checkin to fix Thunderbird & Sunbird tinderbox bustage.

This commit is contained in:
dholbert%cs.stanford.edu 2008-04-21 23:01:00 +00:00
Родитель 59c6360b6d
Коммит f9694e29a5
6 изменённых файлов: 6 добавлений и 258 удалений

Просмотреть файл

@ -82,7 +82,6 @@ REQUIRES = \
feeds \
storage \
pipnss \
places \
$(NULL)
ifdef ALERTS_SERVICE

Просмотреть файл

@ -68,7 +68,6 @@ REQUIRES = xpcom \
exthandler \
docshell \
toolkitcomps \
places \
$(NULL)
CPPSRCS = \

Просмотреть файл

@ -61,7 +61,6 @@
#include "nsIPromptService.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsTArray.h"
#include "nsVoidArray.h"
#include "nsEnumeratorUtils.h"
#include "nsIFileURL.h"
@ -110,12 +109,7 @@ static const PRInt64 gUpdateInterval = 400 * PR_USEC_PER_MSEC;
////////////////////////////////////////////////////////////////////////////////
//// nsDownloadManager
NS_IMPL_ISUPPORTS3(
nsDownloadManager
, nsIDownloadManager
, nsINavHistoryObserver
, nsIObserver
)
NS_IMPL_ISUPPORTS2(nsDownloadManager, nsIDownloadManager, nsIObserver)
nsDownloadManager *nsDownloadManager::gDownloadManagerService = nsnull;
@ -237,37 +231,6 @@ nsDownloadManager::RemoveAllDownloads()
return rv;
}
nsresult
nsDownloadManager::RemoveDownloadsForURI(nsIURI *aURI)
{
mozStorageStatementScoper scope(mGetIdsForURIStatement);
nsCAutoString source;
nsresult rv = aURI->GetSpec(source);
NS_ENSURE_SUCCESS(rv, rv);
rv = mGetIdsForURIStatement->BindUTF8StringParameter(0, source);
NS_ENSURE_SUCCESS(rv, rv);
PRBool hasMore = PR_FALSE;
nsAutoTArray<PRInt64, 4> downloads;
// Get all the downloads that match the provided URI
while (NS_SUCCEEDED(mGetIdsForURIStatement->ExecuteStep(&hasMore)) &&
hasMore) {
PRInt64 downloadId;
rv = mGetIdsForURIStatement->GetInt64(0, &downloadId);
NS_ENSURE_SUCCESS(rv, rv);
downloads.AppendElement(downloadId);
}
// Remove each download ignoring any failure so we reach other downloads
for (PRInt32 i = downloads.Length(); --i >= 0; )
(void)RemoveDownload(downloads[i]);
return NS_OK;
}
void // static
nsDownloadManager::ResumeOnWakeCallback(nsITimer *aTimer, void *aClosure)
{
@ -928,12 +891,6 @@ nsDownloadManager::Init()
"WHERE id = ?10"), getter_AddRefs(mUpdateDownloadStatement));
NS_ENSURE_SUCCESS(rv, rv);
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
"SELECT id "
"FROM moz_downloads "
"WHERE source = ?1"), getter_AddRefs(mGetIdsForURIStatement));
NS_ENSURE_SUCCESS(rv, rv);
// Do things *after* initializing various download manager properties such as
// restoring downloads to a consistent state
rv = RestoreDatabaseState();
@ -942,10 +899,6 @@ nsDownloadManager::Init()
rv = RestoreActiveDownloads();
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to restore all active downloads");
nsCOMPtr<nsINavHistoryService> history =
do_GetService(NS_NAVHISTORYSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
// The following three AddObserver calls must be the last lines in this function,
// because otherwise, this function may fail (and thus, this object would be not
// completely initialized), but the observerservice would still keep a reference
@ -961,8 +914,6 @@ nsDownloadManager::Init()
mObserverService->AddObserver(this, "sleep_notification", PR_FALSE);
mObserverService->AddObserver(this, "wake_notification", PR_FALSE);
(void)history->AddObserver(this, PR_FALSE);
return NS_OK;
}
@ -1783,78 +1734,6 @@ nsDownloadManager::NotifyListenersOnStateChange(nsIWebProgress *aProgress,
aDownload);
}
////////////////////////////////////////////////////////////////////////////////
//// nsINavHistoryObserver
NS_IMETHODIMP
nsDownloadManager::OnBeginUpdateBatch()
{
// We already have a transaction, so don't make another
if (mHistoryTransaction)
return NS_OK;
// Start a transaction that commits when deleted
mHistoryTransaction = new mozStorageTransaction(mDBConn, PR_TRUE);
return NS_OK;
}
NS_IMETHODIMP
nsDownloadManager::OnEndUpdateBatch()
{
if (mHistoryTransaction) {
// Delete the transaction and cause it to commit
delete mHistoryTransaction;
mHistoryTransaction = nsnull;
}
return NS_OK;
}
NS_IMETHODIMP
nsDownloadManager::OnVisit(nsIURI *aURI, PRInt64 aVisitID, PRTime aTime,
PRInt64 aSessionID, PRInt64 aReferringID,
PRUint32 aTransitionType, PRUint32 *aAdded)
{
return NS_OK;
}
NS_IMETHODIMP
nsDownloadManager::OnTitleChanged(nsIURI *aURI, const nsAString &aPageTitle)
{
return NS_OK;
}
NS_IMETHODIMP
nsDownloadManager::OnDeleteURI(nsIURI *aURI)
{
return RemoveDownloadsForURI(aURI);
}
NS_IMETHODIMP
nsDownloadManager::OnClearHistory()
{
return CleanUp();
}
NS_IMETHODIMP
nsDownloadManager::OnPageChanged(nsIURI *aURI, PRUint32 aWhat,
const nsAString &aValue)
{
return NS_OK;
}
NS_IMETHODIMP
nsDownloadManager::OnPageExpired(nsIURI *aURI, PRTime aVisitTime,
PRBool aWholeEntry)
{
// Don't bother removing downloads if there are still recent visits
if (!aWholeEntry)
return NS_OK;
return RemoveDownloadsForURI(aURI);
}
////////////////////////////////////////////////////////////////////////////////
//// nsIObserver

Просмотреть файл

@ -61,11 +61,9 @@
#include "nsIMIMEInfo.h"
#include "mozIStorageConnection.h"
#include "mozIStorageStatement.h"
#include "mozStorageHelper.h"
#include "nsCOMArray.h"
#include "nsArrayEnumerator.h"
#include "nsAutoPtr.h"
#include "nsINavHistoryService.h"
#include "nsIObserverService.h"
#include "nsITimer.h"
@ -79,13 +77,11 @@ class nsDownloadScanner;
#endif
class nsDownloadManager : public nsIDownloadManager,
public nsINavHistoryObserver,
public nsIObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOWNLOADMANAGER
NS_DECL_NSINAVHISTORYOBSERVER
NS_DECL_NSIOBSERVER
nsresult Init();
@ -193,14 +189,6 @@ protected:
*/
nsresult RemoveAllDownloads();
/**
* Find all downloads from a source URI and delete them.
*
* @param aURI
* The source URI to remove downloads
*/
nsresult RemoveDownloadsForURI(nsIURI *aURI);
/**
* Callback used for resuming downloads after getting a wake notification.
*
@ -249,8 +237,6 @@ private:
nsCOMArray<nsDownload> mCurrentDownloads;
nsCOMPtr<nsIObserverService> mObserverService;
nsCOMPtr<mozIStorageStatement> mUpdateDownloadStatement;
nsCOMPtr<mozIStorageStatement> mGetIdsForURIStatement;
mozStorageTransaction *mHistoryTransaction;
static nsDownloadManager *gDownloadManagerService;

Просмотреть файл

@ -1,117 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Download Manager UI Test Code.
*
* The Initial Developer of the Original Code is
* Edward Lee <edward.lee@engineering.uiuc.edu>.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* Test bug 251337 to make sure old downloads are expired and removed.
*/
function run_test()
{
let dm = Cc["@mozilla.org/download-manager;1"].
getService(Ci.nsIDownloadManager);
let db = dm.DBConnection;
// Empty any old downloads
db.executeSimpleSQL("DELETE FROM moz_downloads");
let stmt = db.createStatement(
"INSERT INTO moz_downloads (id, source, target, state) " +
"VALUES (?1, ?2, ?3, ?4)");
let iosvc = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
let theId = 1337;
let theURI = iosvc.newURI("http://expireme/please", null, null);
try {
// Add a download from the URI
stmt.bindInt32Parameter(0, theId);
stmt.bindStringParameter(1, theURI.spec);
// Give a dummy file name
let file = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
file.append("expireTest");
stmt.bindStringParameter(2, Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService).newFileURI(file).spec);
// Give it some state
stmt.bindInt32Parameter(3, dm.DOWNLOAD_FINISHED);
// Add it!
stmt.execute();
}
finally {
stmt.reset();
stmt.finalize();
}
let histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
// Add the download to places
histsvc.addVisit(theURI, Date.now() * 1000, null,
histsvc.TRANSITION_DOWNLOAD, false, 0);
// Look for the removed download notification
let obs = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
const kRemoveTopic = "download-manager-remove-download";
let testObs = {
observe: function(aSubject, aTopic, aData) {
if (aTopic != kRemoveTopic)
return;
// Make sure the removed/expired download was the one we added
let id = aSubject.QueryInterface(Ci.nsISupportsPRUint32);
do_check_eq(id.data, theId);
// We're done!
obs.removeObserver(testObs, kRemoveTopic);
do_test_finished();
}
};
obs.addObserver(testObs, kRemoveTopic, false);
// Set expiration stuff to 0 to make the download expire
let prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
prefs.setIntPref("browser.history_expire_sites", 0);
prefs.setIntPref("browser.history_expire_days_min", 0);
prefs.setIntPref("browser.history_expire_days", 0);
// Expiration happens on a timeout after we set the pref
do_test_pending();
}

Просмотреть файл

@ -2503,7 +2503,8 @@ nsNavHistory::AddVisit(nsIURI* aURI, PRTime aTime, nsIURI* aReferringURI,
// the history UI (sidebar, history menu, url bar autocomplete, etc)
hidden = oldHiddenState;
if (hidden && (!aIsRedirect || aTransitionType == TRANSITION_TYPED) &&
aTransitionType != TRANSITION_EMBED)
aTransitionType != TRANSITION_EMBED &&
aTransitionType != TRANSITION_DOWNLOAD)
hidden = PR_FALSE; // unhide
typed = oldTypedState || (aTransitionType == TRANSITION_TYPED);
@ -2533,9 +2534,10 @@ nsNavHistory::AddVisit(nsIURI* aURI, PRTime aTime, nsIURI* aReferringURI,
mDBGetPageVisitStats->Reset();
scoper.Abandon();
// Hide only embedded links and redirects
// Hide only embedded links, redirects, and downloads
// See the hidden computation code above for a little more explanation.
hidden = (aTransitionType == TRANSITION_EMBED || aIsRedirect);
hidden = (aTransitionType == TRANSITION_EMBED || aIsRedirect ||
aTransitionType == TRANSITION_DOWNLOAD);
typed = (aTransitionType == TRANSITION_TYPED);