зеркало из https://github.com/mozilla/pjs.git
Backing out waterson to fix (78718), chrome restart blocker. Thanks to sspitzer for finding this. r=sspitzer,waterson
This commit is contained in:
Родитель
e931a790bc
Коммит
8293f50840
|
@ -73,10 +73,8 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "nsIFileStreams.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsIDTD.h"
|
||||
#include "nsIRDFPurgeableDataSource.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
@ -241,12 +239,7 @@ protected:
|
|||
NameSpaceMap* mNameSpaces;
|
||||
nsCOMPtr<nsIURI> mURL;
|
||||
nsCOMPtr<nsIStreamListener> mParser;
|
||||
|
||||
/**
|
||||
* Cached copy of the original URL spec, kept around because
|
||||
* opening the URL to read it may cause it to be re-written.
|
||||
*/
|
||||
nsCString mOriginalURLSpec;
|
||||
char* mURLSpec;
|
||||
|
||||
// pseudo-constants
|
||||
static PRInt32 gRefCnt;
|
||||
|
@ -491,7 +484,8 @@ RDFXMLDataSourceImpl::RDFXMLDataSourceImpl(void)
|
|||
mIsWritable(PR_TRUE),
|
||||
mIsDirty(PR_FALSE),
|
||||
mLoadState(eLoadState_Unloaded),
|
||||
mNameSpaces(nsnull)
|
||||
mNameSpaces(nsnull),
|
||||
mURLSpec(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
|
@ -565,6 +559,9 @@ RDFXMLDataSourceImpl::~RDFXMLDataSourceImpl(void)
|
|||
NS_RELEASE(obs);
|
||||
}
|
||||
|
||||
if (mURLSpec)
|
||||
PL_strfree(mURLSpec);
|
||||
|
||||
while (mNameSpaces) {
|
||||
NameSpaceMap* doomed = mNameSpaces;
|
||||
mNameSpaces = mNameSpaces->Next;
|
||||
|
@ -711,16 +708,20 @@ static const char kResourceURIPrefix[] = "resource:";
|
|||
|
||||
// XXX this is a hack: any "file:" URI is considered writable. All
|
||||
// others are considered read-only.
|
||||
nsXPIDLCString realURL;
|
||||
mURL->GetSpec(getter_Copies(realURL));
|
||||
if ((PL_strncmp(realURL.get(), kFileURIPrefix, sizeof(kFileURIPrefix) - 1) != 0) &&
|
||||
(PL_strncmp(realURL.get(), kResourceURIPrefix, sizeof(kResourceURIPrefix) - 1) != 0)) {
|
||||
char* realURL;
|
||||
mURL->GetSpec(&realURL);
|
||||
if ((PL_strncmp(realURL, kFileURIPrefix, sizeof(kFileURIPrefix) - 1) != 0) &&
|
||||
(PL_strncmp(realURL, kResourceURIPrefix, sizeof(kResourceURIPrefix) - 1) != 0)) {
|
||||
mIsWritable = PR_FALSE;
|
||||
}
|
||||
|
||||
// XXX Keep a 'cached' copy of the URL; opening it may cause the
|
||||
// spec to be re-written.
|
||||
mOriginalURLSpec = realURL.get();
|
||||
if (mURLSpec)
|
||||
PL_strfree(mURLSpec);
|
||||
|
||||
mURLSpec = PL_strdup(realURL);
|
||||
nsCRT::free(realURL);
|
||||
|
||||
rv = gRDFService->RegisterDataSource(this, PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -733,10 +734,10 @@ NS_IMETHODIMP
|
|||
RDFXMLDataSourceImpl::GetURI(char* *aURI)
|
||||
{
|
||||
*aURI = nsnull;
|
||||
if (mOriginalURLSpec.Length()) {
|
||||
if (mURLSpec) {
|
||||
// XXX We don't use the mURL, because it might get re-written
|
||||
// when it's actually opened.
|
||||
*aURI = nsXPIDLCString::Copy(mOriginalURLSpec.get());
|
||||
*aURI = nsXPIDLCString::Copy(mURLSpec);
|
||||
if (! *aURI)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -862,12 +863,12 @@ RDFXMLDataSourceImpl::Flush(void)
|
|||
if (!mIsWritable || !mIsDirty)
|
||||
return NS_OK;
|
||||
|
||||
NS_PRECONDITION(mOriginalURLSpec.Length(), "not initialized");
|
||||
if (! mOriginalURLSpec.Length())
|
||||
NS_PRECONDITION(mURLSpec != nsnull, "not initialized");
|
||||
if (! mURLSpec)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
("rdfxml[%p] flush(%s)", this, mOriginalURLSpec.get()));
|
||||
("rdfxml[%p] flush(%s)", this, mURLSpec));
|
||||
|
||||
nsresult rv;
|
||||
|
||||
|
@ -883,25 +884,21 @@ RDFXMLDataSourceImpl::Flush(void)
|
|||
}
|
||||
}
|
||||
|
||||
// Is it a file? If so, we can write to it. Some day, it'd be nice
|
||||
// if we didn't care what kind of stream this was...
|
||||
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mURL);
|
||||
if (fileURL) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
fileURL->GetFile(getter_AddRefs(file));
|
||||
// XXX Replace this with channels someday soon...
|
||||
nsFileURL url(mURLSpec, PR_TRUE);
|
||||
nsFileSpec path(url);
|
||||
|
||||
if (file) {
|
||||
nsCOMPtr<nsIOutputStream> out;
|
||||
NS_NewLocalFileOutputStream(getter_AddRefs(out), file);
|
||||
nsOutputFileStream out(path);
|
||||
if (! out.is_open())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (out) {
|
||||
rv = Serialize(out);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIOutputStream> outIStream = out.GetIStream();
|
||||
if (NS_FAILED(rv = Serialize(outIStream)))
|
||||
goto done;
|
||||
|
||||
mIsDirty = PR_FALSE;
|
||||
|
||||
done:
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -931,15 +928,13 @@ NS_IMETHODIMP
|
|||
RDFXMLDataSourceImpl::Refresh(PRBool aBlocking)
|
||||
{
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
("rdfxml[%p] refresh(%s) %sblocking", this,
|
||||
mOriginalURLSpec.get(), (aBlocking ? "" : "non")));
|
||||
("rdfxml[%p] refresh(%s) %sblocking", this, mURLSpec, (aBlocking ? "" : "non")));
|
||||
|
||||
// If an asynchronous load is already pending, then just let it do
|
||||
// the honors.
|
||||
if (IsLoading()) {
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
("rdfxml[%p] refresh(%s) a load was pending", this,
|
||||
mOriginalURLSpec.get()));
|
||||
("rdfxml[%p] refresh(%s) a load was pending", this, mURLSpec));
|
||||
|
||||
if (aBlocking) {
|
||||
NS_WARNING("blocking load requested when async load pending");
|
||||
|
@ -1007,7 +1002,7 @@ NS_IMETHODIMP
|
|||
RDFXMLDataSourceImpl::BeginLoad(void)
|
||||
{
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
("rdfxml[%p] begin-load(%s)", this, mOriginalURLSpec.get()));
|
||||
("rdfxml[%p] begin-load(%s)", this, mURLSpec));
|
||||
|
||||
mLoadState = eLoadState_Loading;
|
||||
for (PRInt32 i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
|
@ -1023,7 +1018,7 @@ NS_IMETHODIMP
|
|||
RDFXMLDataSourceImpl::Interrupt(void)
|
||||
{
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
("rdfxml[%p] interrupt(%s)", this, mOriginalURLSpec.get()));
|
||||
("rdfxml[%p] interrupt(%s)", this, mURLSpec));
|
||||
|
||||
for (PRInt32 i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFXMLSinkObserver* obs =
|
||||
|
@ -1038,7 +1033,7 @@ NS_IMETHODIMP
|
|||
RDFXMLDataSourceImpl::Resume(void)
|
||||
{
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
("rdfxml[%p] resume(%s)", this, mOriginalURLSpec.get()));
|
||||
("rdfxml[%p] resume(%s)", this, mURLSpec));
|
||||
|
||||
for (PRInt32 i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFXMLSinkObserver* obs =
|
||||
|
@ -1053,7 +1048,7 @@ NS_IMETHODIMP
|
|||
RDFXMLDataSourceImpl::EndLoad(void)
|
||||
{
|
||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||
("rdfxml[%p] end-load(%s)", this, mOriginalURLSpec.get()));
|
||||
("rdfxml[%p] end-load(%s)", this, mURLSpec));
|
||||
|
||||
mLoadState = eLoadState_Loaded;
|
||||
|
||||
|
@ -1380,7 +1375,7 @@ RDFXMLDataSourceImpl::SerializeAssertion(nsIOutputStream* aStream,
|
|||
nsXPIDLCString docURI;
|
||||
|
||||
nsAutoString uri = NS_ConvertUTF8toUCS2(s);
|
||||
rdf_MakeRelativeRef(NS_ConvertUTF8toUCS2(mOriginalURLSpec.get()), uri);
|
||||
rdf_MakeRelativeRef(NS_ConvertUTF8toUCS2(mURLSpec), uri);
|
||||
rdf_EscapeAttributeValue(uri);
|
||||
|
||||
static const char kRDFResource1[] = " resource=\"";
|
||||
|
@ -1471,7 +1466,7 @@ static const char kRDFDescription3[] = " </RDF:Description>\n";
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString uri = NS_ConvertUTF8toUCS2(s);
|
||||
rdf_MakeRelativeRef(NS_ConvertUTF8toUCS2(mOriginalURLSpec.get()), uri);
|
||||
rdf_MakeRelativeRef(NS_ConvertUTF8toUCS2(mURLSpec), uri);
|
||||
rdf_EscapeAttributeValue(uri);
|
||||
|
||||
if (uri[0] == PRUnichar('#')) {
|
||||
|
@ -1557,7 +1552,7 @@ static const char kRDFLIResource1[] = " <RDF:li resource=\"";
|
|||
static const char kRDFLIResource2[] = "\"/>\n";
|
||||
|
||||
nsAutoString uri = NS_ConvertUTF8toUCS2(s);
|
||||
rdf_MakeRelativeRef(NS_ConvertUTF8toUCS2(mOriginalURLSpec.get()), uri);
|
||||
rdf_MakeRelativeRef(NS_ConvertUTF8toUCS2(mURLSpec), uri);
|
||||
rdf_EscapeAttributeValue(uri);
|
||||
|
||||
rdf_BlockingWrite(aStream, kRDFLIResource1, sizeof(kRDFLIResource1) - 1);
|
||||
|
@ -1626,7 +1621,7 @@ RDFXMLDataSourceImpl::SerializeContainer(nsIOutputStream* aStream,
|
|||
nsXPIDLCString s;
|
||||
if (NS_SUCCEEDED(aContainer->GetValue( getter_Copies(s) ))) {
|
||||
nsAutoString uri = NS_ConvertUTF8toUCS2(s);
|
||||
rdf_MakeRelativeRef(NS_ConvertUTF8toUCS2(mOriginalURLSpec.get()), uri);
|
||||
rdf_MakeRelativeRef(NS_ConvertUTF8toUCS2(mURLSpec), uri);
|
||||
|
||||
rdf_EscapeAttributeValue(uri);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче