зеркало из https://github.com/mozilla/pjs.git
Changed file transport to facilitate jar: protocol -- parameterized by nsIFileSystem. Bug#12579 r=gagan,gayatrib
This commit is contained in:
Родитель
683fc55f15
Коммит
dce1fc7e3b
|
@ -22,12 +22,13 @@
|
||||||
%}
|
%}
|
||||||
|
|
||||||
interface nsIChannel;
|
interface nsIChannel;
|
||||||
|
interface nsIFileSystem;
|
||||||
interface nsIEventSinkGetter;
|
interface nsIEventSinkGetter;
|
||||||
interface nsIInputStream;
|
interface nsIInputStream;
|
||||||
interface nsIRunnable;
|
interface nsIRunnable;
|
||||||
native nsFileSpec(nsFileSpec&);
|
native nsFileSpec(nsFileSpec&);
|
||||||
|
|
||||||
[scriptable, uuid(d4ced500-6882-11d3-9382-00104ba0fd40)]
|
[scriptable, uuid(57211a60-8c45-11d3-93ac-00104ba0fd40)]
|
||||||
interface nsIFileTransportService : nsISupports
|
interface nsIFileTransportService : nsISupports
|
||||||
{
|
{
|
||||||
[noscript] nsIChannel createTransport(in nsFileSpec spec, // XXX change to nsIFile later
|
[noscript] nsIChannel createTransport(in nsFileSpec spec, // XXX change to nsIFile later
|
||||||
|
@ -42,6 +43,10 @@ interface nsIFileTransportService : nsISupports
|
||||||
in string command,
|
in string command,
|
||||||
in nsIEventSinkGetter getter);
|
in nsIEventSinkGetter getter);
|
||||||
|
|
||||||
|
nsIChannel createTransportFromFileSystem(in nsIFileSystem fsObj,
|
||||||
|
in string command,
|
||||||
|
in nsIEventSinkGetter getter);
|
||||||
|
|
||||||
void dispatchRequest(in nsIRunnable runnable);
|
void dispatchRequest(in nsIRunnable runnable);
|
||||||
void suspend(in nsIRunnable trans);
|
void suspend(in nsIRunnable trans);
|
||||||
void resume(in nsIRunnable trans);
|
void resume(in nsIRunnable trans);
|
||||||
|
|
|
@ -285,55 +285,55 @@ nsresult
|
||||||
nsFileTransport::Init(nsFileSpec& spec, const char* command, nsIEventSinkGetter* getter)
|
nsFileTransport::Init(nsFileSpec& spec, const char* command, nsIEventSinkGetter* getter)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
if (mMonitor == nsnull) {
|
|
||||||
mMonitor = nsAutoMonitor::NewMonitor("nsFileTransport");
|
|
||||||
if (mMonitor == nsnull)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
mSpec = spec;
|
mSpec = spec;
|
||||||
rv = nsLocalFileSystem::Create(spec, getter_AddRefs(mFileObject));
|
nsCOMPtr<nsIFileSystem> fsObj;
|
||||||
if (NS_FAILED(rv))
|
rv = nsLocalFileSystem::Create(spec, getter_AddRefs(fsObj));
|
||||||
return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
if (getter) {
|
return Init(fsObj, command, getter);
|
||||||
nsCOMPtr<nsISupports> sink;
|
|
||||||
(void)getter->GetEventSink(command,
|
|
||||||
nsIProgressEventSink::GetIID(), getter_AddRefs(sink));
|
|
||||||
if (sink)
|
|
||||||
{
|
|
||||||
// Now generate a proxied event sink-
|
|
||||||
NS_WITH_SERVICE(nsIProxyObjectManager,
|
|
||||||
proxyMgr, kProxyObjectManagerCID, &rv);
|
|
||||||
if (NS_SUCCEEDED(rv))
|
|
||||||
{
|
|
||||||
rv = proxyMgr->GetProxyObject(
|
|
||||||
nsnull, // primordial thread - should change?
|
|
||||||
NS_GET_IID(nsIProgressEventSink),
|
|
||||||
sink,
|
|
||||||
PROXY_ASYNC | PROXY_ALWAYS,
|
|
||||||
getter_AddRefs(mProgress));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsFileTransport::Init(nsIInputStream* fromStream, const char* contentType,
|
nsFileTransport::Init(nsIInputStream* fromStream, const char* contentType,
|
||||||
PRInt32 contentLength, const char* command, nsIEventSinkGetter* getter)
|
PRInt32 contentLength, const char* command, nsIEventSinkGetter* getter)
|
||||||
{
|
{
|
||||||
|
nsresult rv;
|
||||||
|
nsCOMPtr<nsIFileSystem> fsObj;
|
||||||
|
rv = nsInputStreamFileSystem::Create(fromStream, contentType, contentLength,
|
||||||
|
getter_AddRefs(fsObj));
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
return Init(fsObj, command, getter);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsFileTransport::Init(nsIFileSystem* fsObj,
|
||||||
|
const char* command,
|
||||||
|
nsIEventSinkGetter* getter)
|
||||||
|
{
|
||||||
|
nsresult rv = NS_OK;
|
||||||
if (mMonitor == nsnull) {
|
if (mMonitor == nsnull) {
|
||||||
mMonitor = nsAutoMonitor::NewMonitor("nsFileTransport");
|
mMonitor = nsAutoMonitor::NewMonitor("nsFileTransport");
|
||||||
if (mMonitor == nsnull)
|
if (mMonitor == nsnull)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
nsInputStreamFileSystem::Create(fromStream, contentType, contentLength,
|
mFileObject = fsObj;
|
||||||
getter_AddRefs(mFileObject));
|
|
||||||
if (getter) {
|
if (getter) {
|
||||||
nsCOMPtr<nsISupports> sink;
|
nsCOMPtr<nsISupports> sink;
|
||||||
(void)getter->GetEventSink(command, nsIProgressEventSink::GetIID(), getter_AddRefs(sink));
|
rv = getter->GetEventSink(command,
|
||||||
mProgress = (nsIProgressEventSink*)sink.get();
|
nsIProgressEventSink::GetIID(), getter_AddRefs(sink));
|
||||||
|
if (NS_FAILED(rv)) return NS_OK; // don't need a progress event sink
|
||||||
|
|
||||||
|
// Now generate a proxied event sink
|
||||||
|
NS_WITH_SERVICE(nsIProxyObjectManager,
|
||||||
|
proxyMgr, kProxyObjectManagerCID, &rv);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
|
rv = proxyMgr->GetProxyObject(nsnull, // primordial thread - should change?
|
||||||
|
NS_GET_IID(nsIProgressEventSink),
|
||||||
|
sink,
|
||||||
|
PROXY_ASYNC | PROXY_ALWAYS,
|
||||||
|
getter_AddRefs(mProgress));
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsFileTransport::~nsFileTransport()
|
nsFileTransport::~nsFileTransport()
|
||||||
|
|
|
@ -62,6 +62,9 @@ public:
|
||||||
PRInt32 contentLength,
|
PRInt32 contentLength,
|
||||||
const char* command,
|
const char* command,
|
||||||
nsIEventSinkGetter* getter);
|
nsIEventSinkGetter* getter);
|
||||||
|
nsresult Init(nsIFileSystem* fsObj,
|
||||||
|
const char* command,
|
||||||
|
nsIEventSinkGetter* getter);
|
||||||
|
|
||||||
void Process(void);
|
void Process(void);
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,26 @@ nsFileTransportService::CreateTransportFromStream(nsIInputStream *fromStream,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsFileTransportService::CreateTransportFromFileSystem(nsIFileSystem *fsObj,
|
||||||
|
const char *command,
|
||||||
|
nsIEventSinkGetter *getter,
|
||||||
|
nsIChannel **result)
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
nsFileTransport* trans = new nsFileTransport();
|
||||||
|
if (trans == nsnull)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
NS_ADDREF(trans);
|
||||||
|
rv = trans->Init(fsObj, command, getter);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
NS_RELEASE(trans);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
*result = trans;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsFileTransportService::ProcessPendingRequests(void)
|
nsFileTransportService::ProcessPendingRequests(void)
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче