зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1312144 - Part 1: Stop using nsISupportsArray in nsDirectoryViewer. r=froydnj
This swaps out nsIMutableArray for nsISupportsArray. MozReview-Commit-ID: 9iZynpMcq6A
This commit is contained in:
Родитель
3bb810e812
Коммит
125365b7da
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
|
||||
#include "nsDirectoryViewer.h"
|
||||
#include "nsArray.h"
|
||||
#include "nsArrayUtils.h"
|
||||
#include "nsIDirIndex.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "jsapi.h"
|
||||
|
@ -26,7 +28,6 @@
|
|||
#include "nsRDFCID.h"
|
||||
#include "rdf.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsString.h"
|
||||
|
@ -590,8 +591,7 @@ nsHTTPIndex::CommonInit()
|
|||
rv = mDirRDF->GetLiteral(u"false", getter_AddRefs(kFalseLiteral));
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(mConnectionList));
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
mConnectionList = nsArray::Create();
|
||||
|
||||
// note: don't register DS here
|
||||
return rv;
|
||||
|
@ -848,11 +848,12 @@ nsHTTPIndex::GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, bool
|
|||
// by using a global connection list and an immediately-firing timer
|
||||
if (doNetworkRequest && mConnectionList)
|
||||
{
|
||||
int32_t connectionIndex = mConnectionList->IndexOf(aSource);
|
||||
if (connectionIndex < 0)
|
||||
uint32_t connectionIndex;
|
||||
nsresult idx_rv = mConnectionList->IndexOf(0, aSource, &connectionIndex);
|
||||
if (NS_FAILED(idx_rv))
|
||||
{
|
||||
// add aSource into list of connections to make
|
||||
mConnectionList->AppendElement(aSource);
|
||||
mConnectionList->AppendElement(aSource, /*weak =*/ false);
|
||||
|
||||
// if we don't have a timer about to fire, create one
|
||||
// which should fire as soon as possible (out-of-band)
|
||||
|
@ -883,14 +884,13 @@ nsHTTPIndex::AddElement(nsIRDFResource *parent, nsIRDFResource *prop, nsIRDFNode
|
|||
|
||||
if (!mNodeList)
|
||||
{
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(mNodeList));
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
mNodeList = nsArray::Create();
|
||||
}
|
||||
|
||||
// order required: parent, prop, then child
|
||||
mNodeList->AppendElement(parent);
|
||||
mNodeList->AppendElement(prop);
|
||||
mNodeList->AppendElement(child);
|
||||
mNodeList->AppendElement(parent, /*weak =*/ false);
|
||||
mNodeList->AppendElement(prop, /*weak =*/ false);
|
||||
mNodeList->AppendElement(child, /*weak = */ false);
|
||||
|
||||
if (!mTimer)
|
||||
{
|
||||
|
@ -918,20 +918,16 @@ nsHTTPIndex::FireTimer(nsITimer* aTimer, void* aClosure)
|
|||
uint32_t numItems = 0;
|
||||
if (httpIndex->mConnectionList)
|
||||
{
|
||||
httpIndex->mConnectionList->Count(&numItems);
|
||||
httpIndex->mConnectionList->GetLength(&numItems);
|
||||
if (numItems > 0)
|
||||
{
|
||||
nsCOMPtr<nsISupports> isupports;
|
||||
httpIndex->mConnectionList->GetElementAt((uint32_t)0, getter_AddRefs(isupports));
|
||||
httpIndex->mConnectionList->RemoveElementAt((uint32_t)0);
|
||||
|
||||
nsCOMPtr<nsIRDFResource> source;
|
||||
if (isupports)
|
||||
aSource = do_QueryInterface(isupports);
|
||||
nsCOMPtr<nsIRDFResource> source =
|
||||
do_QueryElementAt(httpIndex->mConnectionList, 0);
|
||||
httpIndex->mConnectionList->RemoveElementAt(0);
|
||||
|
||||
nsXPIDLCString uri;
|
||||
if (aSource) {
|
||||
httpIndex->GetDestination(aSource, uri);
|
||||
if (source) {
|
||||
httpIndex->GetDestination(source, uri);
|
||||
}
|
||||
|
||||
if (!uri) {
|
||||
|
@ -960,7 +956,7 @@ nsHTTPIndex::FireTimer(nsITimer* aTimer, void* aClosure)
|
|||
|
||||
if (httpIndex->mNodeList)
|
||||
{
|
||||
httpIndex->mNodeList->Count(&numItems);
|
||||
httpIndex->mNodeList->GetLength(&numItems);
|
||||
if (numItems > 0)
|
||||
{
|
||||
// account for order required: src, prop, then target
|
||||
|
@ -971,23 +967,14 @@ nsHTTPIndex::FireTimer(nsITimer* aTimer, void* aClosure)
|
|||
int32_t loop;
|
||||
for (loop=0; loop<(int32_t)numItems; loop++)
|
||||
{
|
||||
nsCOMPtr<nsISupports> isupports;
|
||||
httpIndex->mNodeList->GetElementAt((uint32_t)0, getter_AddRefs(isupports));
|
||||
httpIndex->mNodeList->RemoveElementAt((uint32_t)0);
|
||||
nsCOMPtr<nsIRDFResource> src;
|
||||
if (isupports)
|
||||
src = do_QueryInterface(isupports);
|
||||
httpIndex->mNodeList->GetElementAt((uint32_t)0, getter_AddRefs(isupports));
|
||||
httpIndex->mNodeList->RemoveElementAt((uint32_t)0);
|
||||
nsCOMPtr<nsIRDFResource> prop;
|
||||
if (isupports)
|
||||
prop = do_QueryInterface(isupports);
|
||||
nsCOMPtr<nsIRDFResource> src = do_QueryElementAt(httpIndex->mNodeList, 0);
|
||||
httpIndex->mNodeList->RemoveElementAt(0);
|
||||
|
||||
httpIndex->mNodeList->GetElementAt((uint32_t)0, getter_AddRefs(isupports));
|
||||
httpIndex->mNodeList->RemoveElementAt((uint32_t)0);
|
||||
nsCOMPtr<nsIRDFNode> target;
|
||||
if (isupports)
|
||||
target = do_QueryInterface(isupports);
|
||||
nsCOMPtr<nsIRDFResource> prop = do_QueryElementAt(httpIndex->mNodeList, 0);
|
||||
httpIndex->mNodeList->RemoveElementAt(0);
|
||||
|
||||
nsCOMPtr<nsIRDFNode> target = do_QueryElementAt(httpIndex->mNodeList, 0);
|
||||
httpIndex->mNodeList->RemoveElementAt(0);
|
||||
|
||||
if (src && prop && target)
|
||||
{
|
||||
|
@ -1008,7 +995,7 @@ nsHTTPIndex::FireTimer(nsITimer* aTimer, void* aClosure)
|
|||
// check both lists to see if the timer needs to continue firing
|
||||
if (httpIndex->mConnectionList)
|
||||
{
|
||||
httpIndex->mConnectionList->Count(&numItems);
|
||||
httpIndex->mConnectionList->GetLength(&numItems);
|
||||
if (numItems > 0)
|
||||
{
|
||||
refireTimer = true;
|
||||
|
@ -1018,9 +1005,10 @@ nsHTTPIndex::FireTimer(nsITimer* aTimer, void* aClosure)
|
|||
httpIndex->mConnectionList->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (httpIndex->mNodeList)
|
||||
{
|
||||
httpIndex->mNodeList->Count(&numItems);
|
||||
httpIndex->mNodeList->GetLength(&numItems);
|
||||
if (numItems > 0)
|
||||
{
|
||||
refireTimer = true;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#ifndef nsdirectoryviewer__h____
|
||||
#define nsdirectoryviewer__h____
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIHTTPIndex.h"
|
||||
|
@ -14,7 +15,6 @@
|
|||
#include "nsIRDFLiteral.h"
|
||||
#include "nsIDocumentLoaderFactory.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIDirIndexListener.h"
|
||||
#include "nsIFTPChannel.h"
|
||||
|
@ -22,6 +22,8 @@
|
|||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
class nsIMutableArray;
|
||||
|
||||
class nsDirectoryViewerFactory : public nsIDocumentLoaderFactory
|
||||
{
|
||||
public:
|
||||
|
@ -70,8 +72,8 @@ protected:
|
|||
// an OnStartRequest() notification
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> mInner;
|
||||
nsCOMPtr<nsISupportsArray> mConnectionList;
|
||||
nsCOMPtr<nsISupportsArray> mNodeList;
|
||||
nsCOMPtr<nsIMutableArray> mConnectionList;
|
||||
nsCOMPtr<nsIMutableArray> mNodeList;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
nsCOMPtr<nsIDirIndexParser> mParser;
|
||||
nsCString mBaseURL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче