mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 17:24:29 +00:00
Port over fixes from the trunk.
This commit is contained in:
parent
7ab1a0db41
commit
b04e2592d5
@ -71,18 +71,19 @@ static PRBool gQuitting = PR_FALSE;
|
||||
#define DOWNLOAD_MANAGER_BUNDLE "chrome://browser/locale/downloadmanager/downloadmanager.properties"
|
||||
#define INTERVAL 500
|
||||
|
||||
nsIRDFResource* gNC_DownloadsRoot;
|
||||
nsIRDFResource* gNC_File;
|
||||
nsIRDFResource* gNC_URL;
|
||||
nsIRDFResource* gNC_Name;
|
||||
nsIRDFResource* gNC_ProgressMode;
|
||||
nsIRDFResource* gNC_ProgressPercent;
|
||||
nsIRDFResource* gNC_Transferred;
|
||||
nsIRDFResource* gNC_DownloadState;
|
||||
nsIRDFResource* gNC_StatusText;
|
||||
static nsIRDFResource* gNC_DownloadsRoot = nsnull;
|
||||
static nsIRDFResource* gNC_File = nsnull;
|
||||
static nsIRDFResource* gNC_URL = nsnull;
|
||||
static nsIRDFResource* gNC_Name = nsnull;
|
||||
static nsIRDFResource* gNC_ProgressMode = nsnull;
|
||||
static nsIRDFResource* gNC_ProgressPercent = nsnull;
|
||||
static nsIRDFResource* gNC_Transferred = nsnull;
|
||||
static nsIRDFResource* gNC_DownloadState = nsnull;
|
||||
static nsIRDFResource* gNC_StatusText = nsnull;
|
||||
|
||||
nsIRDFService* gRDFService;
|
||||
nsIObserverService* gObserverService;
|
||||
static nsIRDFService* gRDFService = nsnull;
|
||||
static nsIObserverService* gObserverService = nsnull;
|
||||
static PRInt32 gRefCnt = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsDownloadManager
|
||||
@ -96,6 +97,12 @@ nsDownloadManager::nsDownloadManager() : mBatches(0)
|
||||
|
||||
nsDownloadManager::~nsDownloadManager()
|
||||
{
|
||||
if (--gRefCnt != 0 || !gRDFService)
|
||||
// Either somebody tried to use |CreateInstance| instead of
|
||||
// |GetService| or |Init| failed very early, so there's nothing to
|
||||
// do here.
|
||||
return;
|
||||
|
||||
gRDFService->UnregisterDataSource(mDataSource);
|
||||
|
||||
NS_IF_RELEASE(gNC_DownloadsRoot);
|
||||
@ -108,12 +115,8 @@ nsDownloadManager::~nsDownloadManager()
|
||||
NS_IF_RELEASE(gNC_DownloadState);
|
||||
NS_IF_RELEASE(gNC_StatusText);
|
||||
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
|
||||
gRDFService = nsnull;
|
||||
|
||||
nsServiceManager::ReleaseService("@mozilla.org/observer-service;1", gObserverService);
|
||||
gObserverService = nsnull;
|
||||
|
||||
NS_RELEASE(gRDFService);
|
||||
NS_RELEASE(gObserverService);
|
||||
}
|
||||
|
||||
PRInt32 PR_CALLBACK nsDownloadManager::CancelAllDownloads(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
@ -137,18 +140,21 @@ PRInt32 PR_CALLBACK nsDownloadManager::CancelAllDownloads(nsHashKey* aKey, void*
|
||||
nsresult
|
||||
nsDownloadManager::Init()
|
||||
{
|
||||
if (gRefCnt++ != 0) {
|
||||
NS_NOTREACHED("download manager should be used as a service");
|
||||
return NS_ERROR_UNEXPECTED; // This will make the |CreateInstance| fail.
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
mRDFContainerUtils = do_GetService("@mozilla.org/rdf/container-utils;1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = nsServiceManager::GetService("@mozilla.org/observer-service;1", NS_GET_IID(nsIObserverService),
|
||||
(nsISupports**) &gObserverService);
|
||||
rv = CallGetService("@mozilla.org/observer-service;1", &gObserverService);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
gObserverService->AddObserver(this, "about-to-quit-application", PR_FALSE);
|
||||
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID, NS_GET_IID(nsIRDFService),
|
||||
(nsISupports**) &gRDFService);
|
||||
rv = CallGetService(kRDFServiceCID, &gRDFService);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
gRDFService->GetResource("NC:DownloadsRoot", &gNC_DownloadsRoot);
|
||||
|
Loading…
x
Reference in New Issue
Block a user