mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 571619 Drop support for aggregation with nsSimpleURI so that we can inherit nsSimpleNestedURI from it correctly r=biesi
This commit is contained in:
parent
a835a85bb1
commit
78d1d301e8
@ -41,14 +41,10 @@
|
||||
#include "nsIObjectOutputStream.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
// nsSimpleURI uses aggregation, so use the non-logging addref/release macros.
|
||||
NS_IMPL_QUERY_INTERFACE_INHERITED1(nsSimpleNestedURI, nsSimpleURI, nsINestedURI)
|
||||
NS_IMPL_NONLOGGING_ADDREF_INHERITED(nsSimpleNestedURI, nsSimpleURI)
|
||||
NS_IMPL_NONLOGGING_RELEASE_INHERITED(nsSimpleNestedURI, nsSimpleURI)
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsSimpleNestedURI, nsSimpleURI, nsINestedURI)
|
||||
|
||||
nsSimpleNestedURI::nsSimpleNestedURI(nsIURI* innerURI)
|
||||
: nsSimpleURI(nsnull),
|
||||
mInnerURI(innerURI)
|
||||
: mInnerURI(innerURI)
|
||||
{
|
||||
NS_ASSERTION(innerURI, "Must have inner URI");
|
||||
NS_TryToSetImmutable(innerURI);
|
||||
|
@ -60,7 +60,6 @@ public:
|
||||
// To be used by deserialization only. Leaves this object in an
|
||||
// uninitialized state that will throw on most accesses.
|
||||
nsSimpleNestedURI()
|
||||
: nsSimpleURI(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -60,41 +60,24 @@ static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsSimpleURI methods:
|
||||
|
||||
nsSimpleURI::nsSimpleURI(nsISupports* outer)
|
||||
nsSimpleURI::nsSimpleURI()
|
||||
: mMutable(PR_TRUE)
|
||||
{
|
||||
NS_INIT_AGGREGATED(outer);
|
||||
}
|
||||
|
||||
nsSimpleURI::~nsSimpleURI()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_AGGREGATED(nsSimpleURI)
|
||||
|
||||
nsresult
|
||||
nsSimpleURI::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aInstancePtr = InnerObject();
|
||||
} else if (aIID.Equals(kThisSimpleURIImplementationCID) || // used by Equals
|
||||
aIID.Equals(NS_GET_IID(nsIURI))) {
|
||||
*aInstancePtr = static_cast<nsIURI*>(this);
|
||||
} else if (aIID.Equals(NS_GET_IID(nsISerializable))) {
|
||||
*aInstancePtr = static_cast<nsISerializable*>(this);
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
|
||||
*aInstancePtr = static_cast<nsIClassInfo*>(this);
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIMutable))) {
|
||||
*aInstancePtr = static_cast<nsIMutable*>(this);
|
||||
} else {
|
||||
*aInstancePtr = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
NS_ADDREF((nsISupports*)*aInstancePtr);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMPL_ADDREF(nsSimpleURI)
|
||||
NS_IMPL_RELEASE(nsSimpleURI)
|
||||
NS_INTERFACE_TABLE_HEAD(nsSimpleURI)
|
||||
NS_INTERFACE_TABLE4(nsSimpleURI, nsIURI, nsISerializable, nsIClassInfo, nsIMutable)
|
||||
NS_INTERFACE_TABLE_TO_MAP_SEGUE
|
||||
if (aIID.Equals(kThisSimpleURIImplementationCID))
|
||||
foundInterface = static_cast<nsIURI*>(this);
|
||||
else
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsISerializable methods:
|
||||
@ -358,7 +341,7 @@ nsSimpleURI::SchemeIs(const char *i_Scheme, PRBool *o_Equals)
|
||||
/* virtual */ nsSimpleURI*
|
||||
nsSimpleURI::StartClone()
|
||||
{
|
||||
return new nsSimpleURI(nsnull); // XXX outer?
|
||||
return new nsSimpleURI();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -59,7 +59,7 @@ class nsSimpleURI : public nsIURI,
|
||||
public nsIMutable
|
||||
{
|
||||
public:
|
||||
NS_DECL_AGGREGATED
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIURI
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
NS_DECL_NSICLASSINFO
|
||||
@ -67,7 +67,7 @@ public:
|
||||
|
||||
// nsSimpleURI methods:
|
||||
|
||||
nsSimpleURI(nsISupports* outer);
|
||||
nsSimpleURI();
|
||||
virtual ~nsSimpleURI();
|
||||
|
||||
protected:
|
||||
|
@ -279,7 +279,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsStdURLParser)
|
||||
#include "nsStandardURL.h"
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsStandardURL)
|
||||
|
||||
NS_GENERIC_AGGREGATED_CONSTRUCTOR(nsSimpleURI)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimpleURI)
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimpleNestedURI)
|
||||
|
||||
|
29
netwerk/test/unit/test_URIs.js
Normal file
29
netwerk/test/unit/test_URIs.js
Normal file
@ -0,0 +1,29 @@
|
||||
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
function do_info(text, stack) {
|
||||
if (!stack)
|
||||
stack = Components.stack.caller;
|
||||
|
||||
dump("TEST-INFO | " + stack.filename + " | [" + stack.name + " : " +
|
||||
stack.lineNumber + "] " + text + "\n");
|
||||
}
|
||||
|
||||
function run_test()
|
||||
{
|
||||
var tests = [
|
||||
{ spec: "x-external:", nsIURL: false, nsINestedURI: false },
|
||||
{ spec: "http://www.example.com/", nsIURL: true, nsINestedURI: false },
|
||||
{ spec: "view-source:about:blank", nsIURL: false, nsINestedURI: true },
|
||||
{ spec: "jar:resource://gre/chrome.toolkit.jar!/", nsIURL: true, nsINestedURI: true }
|
||||
];
|
||||
|
||||
tests.forEach(function(aTest) {
|
||||
var URI = NetUtil.newURI(aTest.spec);
|
||||
do_info("testing " + aTest.spec + " equals " + aTest.spec);
|
||||
do_check_true(URI.equals(URI.clone()));
|
||||
do_info("testing " + aTest.spec + " instanceof nsIURL");
|
||||
do_check_eq(URI instanceof Components.interfaces.nsIURL, aTest.nsIURL);
|
||||
do_info("testing " + aTest.spec + " instanceof nsINestedURI");
|
||||
do_check_eq(URI instanceof Components.interfaces.nsINestedURI, aTest.nsINestedURI);
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user