mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-05-13 08:57:27 +00:00
landing patch for bug 326273 "Implement nsIThreadManager" (Mac portions by Mark Mentovai) with reviews from bienvenu, bsmedberg, bzbarsky, josh, roc, and ssieb
This commit is contained in:
parent
11b93b7d57
commit
0318b8c707
@ -47,12 +47,10 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentCID.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIFastLoadService.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIFileURL.h"
|
||||
@ -117,16 +115,12 @@ protected:
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
nsresult mStatus;
|
||||
|
||||
static NS_HIDDEN_(nsresult)
|
||||
PostLoadEvent(nsCachedChromeChannel* aChannel, PLHandleEventProc aHandler);
|
||||
|
||||
static void* PR_CALLBACK HandleLoadEvent(PLEvent* aEvent);
|
||||
static void PR_CALLBACK DestroyLoadEvent(PLEvent* aEvent);
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
static PRLogModuleInfo* gLog;
|
||||
#endif
|
||||
|
||||
void HandleLoadEvent();
|
||||
|
||||
public:
|
||||
nsCachedChromeChannel(nsIURI* aURI);
|
||||
|
||||
@ -144,18 +138,15 @@ public:
|
||||
NS_IMETHOD GetLoadFlags(nsLoadFlags *);
|
||||
NS_IMETHOD SetLoadFlags(nsLoadFlags);
|
||||
|
||||
// nsIChannel
|
||||
// nsIChannel
|
||||
NS_DECL_NSICHANNEL
|
||||
|
||||
};
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
PRLogModuleInfo* nsCachedChromeChannel::gLog;
|
||||
#endif
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsCachedChromeChannel,
|
||||
nsIChannel,
|
||||
nsIRequest)
|
||||
NS_IMPL_ISUPPORTS2(nsCachedChromeChannel, nsIChannel, nsIRequest)
|
||||
|
||||
nsCachedChromeChannel::nsCachedChromeChannel(nsIURI* aURI)
|
||||
: mURI(aURI)
|
||||
@ -220,10 +211,13 @@ nsCachedChromeChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt)
|
||||
LOG(("nsCachedChromeChannel[%p]: posting load event for %p",
|
||||
this, listener));
|
||||
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NS_NewRunnableMethod(this, &nsCachedChromeChannel::HandleLoadEvent);
|
||||
|
||||
// Queue an event to ourselves to let the stack unwind before
|
||||
// calling OnStartRequest(). This allows embedding to occur
|
||||
// before we fire OnStopRequest().
|
||||
rv = PostLoadEvent(this, HandleLoadEvent);
|
||||
rv = NS_DispatchToCurrentThread(event);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -347,78 +341,42 @@ nsCachedChromeChannel::SetContentLength(PRInt32 aContentLength)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCachedChromeChannel::PostLoadEvent(nsCachedChromeChannel* aChannel,
|
||||
PLHandleEventProc aHandler)
|
||||
{
|
||||
nsCOMPtr<nsIEventQueue> queue;
|
||||
nsresult rv = NS_GetCurrentEventQ(getter_AddRefs(queue));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PLEvent* event = new PLEvent;
|
||||
if (! event)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PL_InitEvent(event,
|
||||
aChannel,
|
||||
aHandler,
|
||||
DestroyLoadEvent);
|
||||
NS_ADDREF(aChannel);
|
||||
|
||||
rv = queue->PostEvent(event);
|
||||
if (NS_FAILED(rv))
|
||||
PL_DestroyEvent(event);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void* PR_CALLBACK
|
||||
nsCachedChromeChannel::HandleLoadEvent(PLEvent* aEvent)
|
||||
void
|
||||
nsCachedChromeChannel::HandleLoadEvent()
|
||||
{
|
||||
// Fire the OnStartRequest() for the cached chrome channel, then
|
||||
// queue another event to trigger the OnStopRequest()...
|
||||
nsCachedChromeChannel* channel = (nsCachedChromeChannel*) aEvent->owner;
|
||||
// trigger the OnStopRequest()...
|
||||
|
||||
// If the load has been cancelled, then just bail now. We won't
|
||||
// send On[Start|Stop]Request().
|
||||
if (NS_FAILED(channel->mStatus))
|
||||
return nsnull;
|
||||
if (NS_FAILED(mStatus))
|
||||
return;
|
||||
|
||||
LOG(("nsCachedChromeChannel[%p]: firing OnStartRequest for %p",
|
||||
channel, channel->mListener.get()));
|
||||
this, mListener.get()));
|
||||
|
||||
(void) channel->mListener->OnStartRequest(channel, channel->mContext);
|
||||
mListener->OnStartRequest(this, mContext);
|
||||
|
||||
LOG(("nsCachedChromeChannel[%p]: firing OnStopRequest for %p",
|
||||
channel, channel->mListener.get()));
|
||||
this, mListener.get()));
|
||||
|
||||
(void) channel->mListener->OnStopRequest(channel, channel->mContext,
|
||||
channel->mStatus);
|
||||
mListener->OnStopRequest(this, mContext, mStatus);
|
||||
|
||||
if (channel->mLoadGroup) {
|
||||
if (mLoadGroup) {
|
||||
LOG(("nsCachedChromeChannel[%p]: removing self from load group %p",
|
||||
channel, channel->mLoadGroup.get()));
|
||||
|
||||
(void) channel->mLoadGroup->RemoveRequest(channel, nsnull, channel->mStatus);
|
||||
this, mLoadGroup.get()));
|
||||
mLoadGroup->RemoveRequest(this, nsnull, mStatus);
|
||||
}
|
||||
|
||||
channel->mListener = nsnull;
|
||||
channel->mContext = nsnull;
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void PR_CALLBACK
|
||||
nsCachedChromeChannel::DestroyLoadEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsCachedChromeChannel* channel = (nsCachedChromeChannel*) aEvent->owner;
|
||||
NS_RELEASE(channel);
|
||||
delete aEvent;
|
||||
mListener = nsnull;
|
||||
mContext = nsnull;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsChromeProtocolHandler, nsIProtocolHandler, nsISupportsWeakReference)
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsChromeProtocolHandler,
|
||||
nsIProtocolHandler,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIProtocolHandler methods:
|
||||
|
@ -7135,6 +7135,14 @@ if test "$MOZ_PROFILESHARING"; then
|
||||
AC_DEFINE(MOZ_PROFILESHARING)
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl enable ipc/ipcd
|
||||
dnl ========================================================
|
||||
MOZ_ARG_ENABLE_BOOL(ipcd,
|
||||
[ --enable-ipcd Enable IPC daemon],
|
||||
MOZ_IPCD=1,
|
||||
MOZ_IPCD= )
|
||||
|
||||
dnl ========================================================
|
||||
dnl disable profile locking
|
||||
dnl do no use this in applications that can have more than
|
||||
|
@ -79,7 +79,6 @@ class nsIStringBundle;
|
||||
class nsIContentPolicy;
|
||||
class nsILineBreaker;
|
||||
class nsIWordBreaker;
|
||||
class nsIEventQueueService;
|
||||
class nsIJSRuntimeService;
|
||||
class nsIEventListenerManager;
|
||||
class nsIScriptContext;
|
||||
@ -664,14 +663,6 @@ public:
|
||||
*/
|
||||
static nsIContentPolicy *GetContentPolicy();
|
||||
|
||||
/**
|
||||
* Return the event queue service
|
||||
*/
|
||||
static nsIEventQueueService* EventQueueService()
|
||||
{
|
||||
return sEventQueueService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that whatever value *aPtr contains at any given moment is
|
||||
* protected from JS GC until we remove the GC root. A call to this that
|
||||
@ -863,8 +854,6 @@ private:
|
||||
static nsILineBreaker* sLineBreaker;
|
||||
static nsIWordBreaker* sWordBreaker;
|
||||
|
||||
static nsIEventQueueService* sEventQueueService;
|
||||
|
||||
// Holds pointers to nsISupports* that should be released at shutdown
|
||||
static nsVoidArray* sPtrsToPtrsToRelease;
|
||||
|
||||
|
@ -117,7 +117,6 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
||||
#include "nsLWBrkCIID.h"
|
||||
#include "nsILineBreaker.h"
|
||||
#include "nsIWordBreaker.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include "nsIJSRuntimeService.h"
|
||||
#include "nsIDOMDocumentXBL.h"
|
||||
@ -159,7 +158,6 @@ nsIContentPolicy *nsContentUtils::sContentPolicyService;
|
||||
PRBool nsContentUtils::sTriedToGetContentPolicy = PR_FALSE;
|
||||
nsILineBreaker *nsContentUtils::sLineBreaker;
|
||||
nsIWordBreaker *nsContentUtils::sWordBreaker;
|
||||
nsIEventQueueService *nsContentUtils::sEventQueueService;
|
||||
nsVoidArray *nsContentUtils::sPtrsToPtrsToRelease;
|
||||
nsIJSRuntimeService *nsContentUtils::sJSRuntimeService;
|
||||
JSRuntime *nsContentUtils::sScriptRuntime;
|
||||
@ -300,9 +298,6 @@ nsContentUtils::Init()
|
||||
rv = CallGetService(NS_WBRK_CONTRACTID, &sWordBreaker);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = CallGetService(NS_EVENTQUEUESERVICE_CONTRACTID, &sEventQueueService);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Ignore failure and just don't load images
|
||||
rv = CallGetService("@mozilla.org/image/loader;1", &sImgLoader);
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -593,7 +588,6 @@ nsContentUtils::Shutdown()
|
||||
NS_IF_RELEASE(sIOService);
|
||||
NS_IF_RELEASE(sLineBreaker);
|
||||
NS_IF_RELEASE(sWordBreaker);
|
||||
NS_IF_RELEASE(sEventQueueService);
|
||||
#ifdef MOZ_XTF
|
||||
NS_IF_RELEASE(sXTFService);
|
||||
#endif
|
||||
|
@ -62,11 +62,10 @@
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsLoadListenerProxy.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
static const char* kLoadAsData = "loadAsData";
|
||||
|
||||
static NS_DEFINE_CID(kIDOMDOMImplementationCID, NS_DOM_IMPLEMENTATION_CID);
|
||||
@ -118,7 +117,6 @@ nsDOMParser::Error(nsIDOMEvent* aEvent)
|
||||
nsDOMParser::nsDOMParser()
|
||||
: mLoopingForSyncLoad(PR_FALSE)
|
||||
{
|
||||
mEventQService = do_GetService(kEventQueueServiceCID);
|
||||
}
|
||||
|
||||
nsDOMParser::~nsDOMParser()
|
||||
@ -320,19 +318,8 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
|
||||
nsCOMPtr<nsIDocument> document(do_QueryInterface(domDocument));
|
||||
if (!document) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIEventQueue> modalEventQueue;
|
||||
|
||||
if(!mEventQService) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mLoopingForSyncLoad = PR_TRUE;
|
||||
|
||||
rv = mEventQService->PushThreadEventQueue(getter_AddRefs(modalEventQueue));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Have to pass PR_FALSE for reset here, else the reset will remove
|
||||
// our event listener. Should that listener addition move to later
|
||||
// than this call?
|
||||
@ -347,9 +334,6 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) || !listener) {
|
||||
if (modalEventQueue) {
|
||||
mEventQService->PopThreadEventQueue(modalEventQueue);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -374,17 +358,17 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
|
||||
// the channel, so we do not need to call Cancel(rv) as we do above.
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
if (modalEventQueue) {
|
||||
mEventQService->PopThreadEventQueue(modalEventQueue);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
while (mLoopingForSyncLoad) {
|
||||
modalEventQueue->ProcessPendingEvents();
|
||||
}
|
||||
// Process events until we receive a load, abort, or error event for the
|
||||
// document object. That event may have already fired.
|
||||
|
||||
mEventQService->PopThreadEventQueue(modalEventQueue);
|
||||
nsIThread *thread = NS_GetCurrentThread();
|
||||
while (mLoopingForSyncLoad) {
|
||||
if (!NS_ProcessNextEvent(thread))
|
||||
break;
|
||||
}
|
||||
|
||||
domDocument.swap(*aResult);
|
||||
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "nsIDOMParser.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIDOMLoadListener.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
@ -70,7 +69,6 @@ public:
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
nsCOMPtr<nsIEventQueueService> mEventQService;
|
||||
PRBool mLoopingForSyncLoad;
|
||||
};
|
||||
|
||||
|
@ -88,6 +88,7 @@
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsIXBLService.h"
|
||||
#include "nsIXPointer.h"
|
||||
@ -132,9 +133,6 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIRequest.h"
|
||||
#include "nsILink.h"
|
||||
#include "plevent.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIEventQueue.h"
|
||||
|
||||
#include "nsICharsetAlias.h"
|
||||
#include "nsIParser.h"
|
||||
@ -5079,55 +5077,30 @@ nsDocument::UnblockOnload(PRBool aFireSync)
|
||||
}
|
||||
}
|
||||
|
||||
class nsUnblockOnloadEvent : public nsRunnable {
|
||||
public:
|
||||
nsUnblockOnloadEvent(nsDocument *doc) : mDoc(doc) {}
|
||||
NS_IMETHOD Run() {
|
||||
mDoc->DoUnblockOnload();
|
||||
return NS_OK;
|
||||
}
|
||||
private:
|
||||
nsRefPtr<nsDocument> mDoc;
|
||||
};
|
||||
|
||||
void
|
||||
nsDocument::PostUnblockOnloadEvent()
|
||||
{
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
nsContentUtils::EventQueueService()->
|
||||
GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
|
||||
getter_AddRefs(eventQ));
|
||||
if (!eventQ) {
|
||||
return;
|
||||
}
|
||||
|
||||
PLEvent* evt = new PLEvent();
|
||||
if (!evt) {
|
||||
return;
|
||||
}
|
||||
|
||||
PL_InitEvent(evt, this, nsDocument::HandleOnloadBlockerEvent,
|
||||
nsDocument::DestroyOnloadBlockerEvent);
|
||||
|
||||
// After this point, event destruction will release |this|
|
||||
NS_ADDREF_THIS();
|
||||
|
||||
nsresult rv = eventQ->PostEvent(evt);
|
||||
if (NS_FAILED(rv)) {
|
||||
PL_DestroyEvent(evt);
|
||||
} else {
|
||||
nsCOMPtr<nsIRunnable> evt = new nsUnblockOnloadEvent(this);
|
||||
nsresult rv = NS_DispatchToCurrentThread(evt);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Stabilize block count so we don't post more events while this one is up
|
||||
++mOnloadBlockCount;
|
||||
} else {
|
||||
NS_WARNING("failed to dispatch nsUnblockOnloadEvent");
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void* PR_CALLBACK
|
||||
nsDocument::HandleOnloadBlockerEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsDocument* doc = NS_STATIC_CAST(nsDocument*, aEvent->owner);
|
||||
doc->DoUnblockOnload();
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// static
|
||||
void PR_CALLBACK
|
||||
nsDocument::DestroyOnloadBlockerEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsDocument* doc = NS_STATIC_CAST(nsDocument*, aEvent->owner);
|
||||
NS_RELEASE(doc);
|
||||
delete aEvent;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::DoUnblockOnload()
|
||||
{
|
||||
|
@ -114,6 +114,7 @@ class nsIRadioVisitor;
|
||||
class nsIFormControl;
|
||||
struct nsRadioGroupStruct;
|
||||
class nsOnloadBlocker;
|
||||
class nsUnblockOnloadEvent;
|
||||
struct PLEvent;
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
@ -802,9 +803,9 @@ protected:
|
||||
nsString mBaseTarget;
|
||||
|
||||
private:
|
||||
friend class nsUnblockOnloadEvent;
|
||||
|
||||
void PostUnblockOnloadEvent();
|
||||
static EventHandlerFunc HandleOnloadBlockerEvent;
|
||||
static EventDestructorFunc DestroyOnloadBlockerEvent;
|
||||
void DoUnblockOnload();
|
||||
|
||||
// These are not implemented and not supported.
|
||||
|
@ -56,9 +56,7 @@
|
||||
#include "imgIContainer.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "imgILoader.h"
|
||||
#include "plevent.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#include "nsPresContext.h"
|
||||
@ -715,10 +713,10 @@ nsImageLoadingContent::StringToURI(const nsAString& aSpec,
|
||||
|
||||
|
||||
/**
|
||||
* Struct used to dispatch events
|
||||
* Class used to dispatch events
|
||||
*/
|
||||
|
||||
class ImageEvent : public PLEvent
|
||||
class ImageEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
ImageEvent(nsPresContext* aPresContext, nsIContent* aContent,
|
||||
@ -728,12 +726,13 @@ public:
|
||||
mMessage(aMessage),
|
||||
mDocument(aDocument)
|
||||
{
|
||||
MOZ_COUNT_CTOR(ImageEvent);
|
||||
}
|
||||
~ImageEvent()
|
||||
{
|
||||
MOZ_COUNT_DTOR(ImageEvent);
|
||||
mDocument->UnblockOnload(PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHOD Run();
|
||||
|
||||
nsCOMPtr<nsPresContext> mPresContext;
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
@ -744,13 +743,12 @@ public:
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(void*)
|
||||
HandleImagePLEvent(PLEvent* aEvent)
|
||||
NS_IMETHODIMP
|
||||
ImageEvent::Run()
|
||||
{
|
||||
ImageEvent* evt = NS_STATIC_CAST(ImageEvent*, aEvent);
|
||||
PRUint32 eventMsg;
|
||||
|
||||
if (evt->mMessage.EqualsLiteral("load")) {
|
||||
if (mMessage.EqualsLiteral("load")) {
|
||||
eventMsg = NS_IMAGE_LOAD;
|
||||
} else {
|
||||
eventMsg = NS_IMAGE_ERROR;
|
||||
@ -758,18 +756,9 @@ HandleImagePLEvent(PLEvent* aEvent)
|
||||
|
||||
nsEvent event(PR_TRUE, eventMsg);
|
||||
event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
|
||||
nsEventDispatcher::Dispatch(evt->mContent, evt->mPresContext, &event);
|
||||
nsEventDispatcher::Dispatch(mContent, mPresContext, &event);
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
DestroyImagePLEvent(PLEvent* aEvent)
|
||||
{
|
||||
ImageEvent* evt = NS_STATIC_CAST(ImageEvent*, aEvent);
|
||||
evt->mDocument->UnblockOnload(PR_TRUE);
|
||||
|
||||
delete evt;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -784,13 +773,9 @@ nsImageLoadingContent::FireEvent(const nsAString& aEventType)
|
||||
// no use to fire events if there is no document....
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
// Use the UI thread event queue (though we should not be getting called from
|
||||
// off the UI thread in any case....)
|
||||
nsresult rv = nsContentUtils::EventQueueService()->
|
||||
GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
|
||||
getter_AddRefs(eventQ));
|
||||
NS_ENSURE_TRUE(eventQ, rv);
|
||||
|
||||
// We should not be getting called from off the UI thread...
|
||||
NS_ASSERTION(NS_IsMainThread(), "should be on the main thread");
|
||||
|
||||
nsIPresShell *shell = document->GetShellAt(0);
|
||||
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
|
||||
@ -800,21 +785,13 @@ nsImageLoadingContent::FireEvent(const nsAString& aEventType)
|
||||
|
||||
nsCOMPtr<nsIContent> ourContent = do_QueryInterface(this);
|
||||
|
||||
ImageEvent* evt = new ImageEvent(presContext, ourContent, aEventType, document);
|
||||
|
||||
nsCOMPtr<nsIRunnable> evt =
|
||||
new ImageEvent(presContext, ourContent, aEventType, document);
|
||||
NS_ENSURE_TRUE(evt, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
PL_InitEvent(evt, this, ::HandleImagePLEvent, ::DestroyImagePLEvent);
|
||||
|
||||
// Block onload for our event. Since we unblock in the event destructor, we
|
||||
// want to block now, even if posting will fail.
|
||||
document->BlockOnload();
|
||||
|
||||
rv = eventQ->PostEvent(evt);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
PL_DestroyEvent(evt);
|
||||
}
|
||||
|
||||
return rv;
|
||||
return NS_DispatchToCurrentThread(evt);
|
||||
}
|
||||
|
@ -61,7 +61,6 @@
|
||||
#include "nsIWebNavigationInfo.h"
|
||||
|
||||
// Util headers
|
||||
#include "plevent.h"
|
||||
#include "prlog.h"
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
@ -69,9 +68,9 @@
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDocShellCID.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
// Concrete classes
|
||||
@ -88,20 +87,11 @@ static PRLogModuleInfo* gObjectLog = PR_NewLogModule("objlc");
|
||||
#define LOG(args) PR_LOG(gObjectLog, PR_LOG_DEBUG, args)
|
||||
#define LOG_ENABLED() PR_LOG_TEST(gObjectLog, PR_LOG_DEBUG)
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
/* Note that these typedefs declare functions, not pointer to
|
||||
functions. That's the only way in which they differ from
|
||||
PLHandleEventProc and PLDestroyEventProc. */
|
||||
typedef void*
|
||||
(PR_CALLBACK EventHandlerFunc)(PLEvent* self);
|
||||
typedef void
|
||||
(PR_CALLBACK EventDestructorFunc)(PLEvent* self);
|
||||
PR_END_EXTERN_C
|
||||
|
||||
struct nsAsyncInstantiateEvent : public PLEvent {
|
||||
class nsAsyncInstantiateEvent : public nsRunnable {
|
||||
public:
|
||||
// This stores both the content and the frame so that Instantiate calls can be
|
||||
// avoided if the frame changed in the meantime.
|
||||
// (the content is stored implicitly as the owner)
|
||||
nsObjectLoadingContent *mContent;
|
||||
nsIObjectFrame* mFrame;
|
||||
nsCString mContentType;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
@ -110,107 +100,81 @@ struct nsAsyncInstantiateEvent : public PLEvent {
|
||||
nsIObjectFrame* aFrame,
|
||||
const nsCString& aType,
|
||||
nsIURI* aURI)
|
||||
: mFrame(aFrame), mContentType(aType), mURI(aURI)
|
||||
: mContent(aContent), mFrame(aFrame), mContentType(aType), mURI(aURI)
|
||||
{
|
||||
NS_ADDREF(NS_STATIC_CAST(nsIObjectLoadingContent*, aContent));
|
||||
PL_InitEvent(this, aContent, nsAsyncInstantiateEvent::HandleEvent,
|
||||
nsAsyncInstantiateEvent::CleanupEvent);
|
||||
NS_STATIC_CAST(nsIObjectLoadingContent *, mContent)->AddRef();
|
||||
}
|
||||
|
||||
~nsAsyncInstantiateEvent()
|
||||
{
|
||||
nsIObjectLoadingContent* con = NS_STATIC_CAST(nsIObjectLoadingContent*,
|
||||
PL_GetEventOwner(this));
|
||||
NS_RELEASE(con);
|
||||
NS_STATIC_CAST(nsIObjectLoadingContent *, mContent)->Release();
|
||||
}
|
||||
|
||||
static EventHandlerFunc HandleEvent;
|
||||
static EventDestructorFunc CleanupEvent;
|
||||
NS_IMETHOD Run();
|
||||
};
|
||||
|
||||
/* static */ void* PR_CALLBACK
|
||||
nsAsyncInstantiateEvent::HandleEvent(PLEvent* event)
|
||||
NS_IMETHODIMP
|
||||
nsAsyncInstantiateEvent::Run()
|
||||
{
|
||||
nsAsyncInstantiateEvent* ev = NS_STATIC_CAST(nsAsyncInstantiateEvent*,
|
||||
event);
|
||||
nsObjectLoadingContent* con = NS_STATIC_CAST(nsObjectLoadingContent*,
|
||||
PL_GetEventOwner(event));
|
||||
// Check if we've been "revoked"
|
||||
if (mContent->mPendingInstantiateEvent != this)
|
||||
return NS_OK;
|
||||
mContent->mPendingInstantiateEvent = nsnull;
|
||||
|
||||
// Make sure that we still have the right frame (NOTE: we don't need to check
|
||||
// the type here - GetFrame() only returns object frames, and that means we're
|
||||
// a plugin)
|
||||
// Also make sure that we still refer to the same data.
|
||||
if (con->GetFrame() == ev->mFrame &&
|
||||
con->mURI == ev->mURI &&
|
||||
con->mContentType.Equals(ev->mContentType)) {
|
||||
if (mContent->GetFrame() == mFrame &&
|
||||
mContent->mURI == mURI &&
|
||||
mContent->mContentType.Equals(mContentType)) {
|
||||
if (LOG_ENABLED()) {
|
||||
nsCAutoString spec;
|
||||
if (ev->mURI) {
|
||||
ev->mURI->GetSpec(spec);
|
||||
if (mURI) {
|
||||
mURI->GetSpec(spec);
|
||||
}
|
||||
LOG(("OBJLC [%p]: Handling Instantiate event: Type=<%s> URI=%p<%s>\n",
|
||||
con, ev->mContentType.get(), ev->mURI.get(), spec.get()));
|
||||
mContent, mContentType.get(), mURI.get(), spec.get()));
|
||||
}
|
||||
|
||||
nsresult rv = con->Instantiate(ev->mContentType, ev->mURI);
|
||||
nsresult rv = mContent->Instantiate(mContentType, mURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
con->Fallback(PR_TRUE);
|
||||
mContent->Fallback(PR_TRUE);
|
||||
}
|
||||
} else {
|
||||
LOG(("OBJLC [%p]: Discarding event, data changed\n", con));
|
||||
LOG(("OBJLC [%p]: Discarding event, data changed\n", mContent));
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
/* static */ void PR_CALLBACK
|
||||
nsAsyncInstantiateEvent::CleanupEvent(PLEvent* event)
|
||||
{
|
||||
nsAsyncInstantiateEvent* ev = NS_STATIC_CAST(nsAsyncInstantiateEvent*,
|
||||
event);
|
||||
delete ev;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* A PLEvent for firing PluginNotFound DOM Events.
|
||||
* A task for firing PluginNotFound DOM Events.
|
||||
*/
|
||||
struct nsPluginNotFoundEvent : public PLEvent {
|
||||
class nsPluginNotFoundEvent : public nsRunnable {
|
||||
public:
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
|
||||
nsPluginNotFoundEvent(nsIContent* aContent)
|
||||
{
|
||||
NS_ADDREF(aContent);
|
||||
PL_InitEvent(this, aContent, nsPluginNotFoundEvent::HandleEvent,
|
||||
nsPluginNotFoundEvent::CleanupEvent);
|
||||
}
|
||||
: mContent(aContent)
|
||||
{}
|
||||
|
||||
~nsPluginNotFoundEvent()
|
||||
{
|
||||
nsIContent* con = NS_STATIC_CAST(nsIContent*, PL_GetEventOwner(this));
|
||||
NS_RELEASE(con);
|
||||
}
|
||||
~nsPluginNotFoundEvent() {}
|
||||
|
||||
static EventHandlerFunc HandleEvent;
|
||||
static EventDestructorFunc CleanupEvent;
|
||||
NS_IMETHOD Run();
|
||||
};
|
||||
|
||||
/* static */ void* PR_CALLBACK
|
||||
nsPluginNotFoundEvent::HandleEvent(PLEvent* event)
|
||||
NS_IMETHODIMP
|
||||
nsPluginNotFoundEvent::Run()
|
||||
{
|
||||
nsIContent* con = NS_STATIC_CAST(nsIContent*, PL_GetEventOwner(event));
|
||||
|
||||
LOG(("OBJLC []: Firing plugin not found event for content %p\n", con));
|
||||
nsContentUtils::DispatchTrustedEvent(con->GetDocument(), con,
|
||||
LOG(("OBJLC []: Firing plugin not found event for content %p\n",
|
||||
mContent.get()));
|
||||
nsContentUtils::DispatchTrustedEvent(mContent->GetDocument(), mContent,
|
||||
NS_LITERAL_STRING("PluginNotFound"),
|
||||
PR_TRUE, PR_TRUE);
|
||||
return nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */ void PR_CALLBACK
|
||||
nsPluginNotFoundEvent::CleanupEvent(PLEvent* event)
|
||||
{
|
||||
nsPluginNotFoundEvent* ev = NS_STATIC_CAST(nsPluginNotFoundEvent*,
|
||||
event);
|
||||
delete ev;
|
||||
}
|
||||
|
||||
|
||||
class AutoNotifier {
|
||||
public:
|
||||
AutoNotifier(nsObjectLoadingContent* aContent, PRBool aNotify) :
|
||||
@ -548,11 +512,9 @@ nsObjectLoadingContent::EnsureInstantiation(nsIPluginInstance** aInstance)
|
||||
if (frame) {
|
||||
// If we have a frame, we may have pending instantiate events; revoke
|
||||
// them.
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
NS_GetCurrentEventQ(getter_AddRefs(eventQ));
|
||||
if (eventQ) {
|
||||
LOG(("OBJLC [%p]: Revoking events\n", this));
|
||||
eventQ->RevokeEvents(this);
|
||||
if (mPendingInstantiateEvent) {
|
||||
LOG(("OBJLC [%p]: Revoking pending instantiate event\n", this));
|
||||
mPendingInstantiateEvent = nsnull;
|
||||
}
|
||||
} else {
|
||||
// mInstantiating is true if we're in LoadObject; we shouldn't
|
||||
@ -612,6 +574,9 @@ nsObjectLoadingContent::HasNewFrame(nsIObjectFrame* aFrame)
|
||||
// This must be done asynchronously to ensure that the frame is correctly
|
||||
// initialized (has a view etc)
|
||||
|
||||
// "revoke" any existing instantiate event.
|
||||
mPendingInstantiateEvent = nsnull;
|
||||
|
||||
// When in a plugin document, the document will take care of calling
|
||||
// instantiate
|
||||
nsCOMPtr<nsIPluginDocument> pDoc (do_QueryInterface(GetOurDocument()));
|
||||
@ -619,23 +584,20 @@ nsObjectLoadingContent::HasNewFrame(nsIObjectFrame* aFrame)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
NS_GetCurrentEventQ(getter_AddRefs(eventQ));
|
||||
if (!eventQ) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsAsyncInstantiateEvent* ev = new nsAsyncInstantiateEvent(this, aFrame,
|
||||
mContentType,
|
||||
mURI);
|
||||
if (!ev) {
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
new nsAsyncInstantiateEvent(this, aFrame, mContentType, mURI);
|
||||
if (!event) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
LOG((" posting event\n"));
|
||||
nsresult rv = eventQ->PostEvent(ev);
|
||||
LOG((" dispatching event\n"));
|
||||
nsresult rv = NS_DispatchToCurrentThread(event);
|
||||
if (NS_FAILED(rv)) {
|
||||
PL_DestroyEvent(ev);
|
||||
NS_ERROR("failed to dispatch nsAsyncInstantiateEvent");
|
||||
} else {
|
||||
// Remember this event. This is a weak reference that will be cleared
|
||||
// when the event runs.
|
||||
mPendingInstantiateEvent = event;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
@ -765,13 +727,9 @@ nsObjectLoadingContent::LoadObject(nsIURI* aURI,
|
||||
}
|
||||
|
||||
// Need to revoke any potentially pending instantiate events
|
||||
if (mType == eType_Plugin) {
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
NS_GetCurrentEventQ(getter_AddRefs(eventQ));
|
||||
if (eventQ) {
|
||||
LOG(("OBJLC [%p]: Revoking events\n", this));
|
||||
eventQ->RevokeEvents(this);
|
||||
}
|
||||
if (mType == eType_Plugin && mPendingInstantiateEvent) {
|
||||
LOG(("OBJLC [%p]: Revoking pending instantiate event\n", this));
|
||||
mPendingInstantiateEvent = nsnull;
|
||||
}
|
||||
|
||||
AutoNotifier notifier(this, aNotify);
|
||||
@ -1208,22 +1166,13 @@ nsObjectLoadingContent::NotifyStateChanged(ObjectType aOldType,
|
||||
/* static */ void
|
||||
nsObjectLoadingContent::FirePluginNotFound(nsIContent* thisContent)
|
||||
{
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
NS_GetCurrentEventQ(getter_AddRefs(eventQ));
|
||||
if (!eventQ) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsPluginNotFoundEvent* ev = new nsPluginNotFoundEvent(thisContent);
|
||||
if (!ev) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(("OBJLC []: Posting PluginNotFound event for content %p\n",
|
||||
LOG(("OBJLC []: Dispatching PluginNotFound event for content %p\n",
|
||||
thisContent));
|
||||
nsresult rv = eventQ->PostEvent(ev);
|
||||
|
||||
nsCOMPtr<nsIRunnable> ev = new nsPluginNotFoundEvent(thisContent);
|
||||
nsresult rv = NS_DispatchToCurrentThread(ev);
|
||||
if (NS_FAILED(rv)) {
|
||||
PL_DestroyEvent(ev);
|
||||
NS_WARNING("failed to dispatch nsPluginNotFoundEvent");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1236,8 +1185,8 @@ nsObjectLoadingContent::GetTypeOfContent(const nsCString& aMIMEType)
|
||||
return eType_Image;
|
||||
}
|
||||
|
||||
PRBool isSVG = aMIMEType.LowerCaseEqualsLiteral("image/svg+xml");
|
||||
#ifdef MOZ_SVG
|
||||
PRBool isSVG = aMIMEType.LowerCaseEqualsLiteral("image/svg+xml");
|
||||
PRBool supportedSVG = isSVG && (caps & eSupportSVG);
|
||||
#else
|
||||
PRBool supportedSVG = PR_FALSE;
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIObjectLoadingContent.h"
|
||||
#include "nsIRunnable.h"
|
||||
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
@ -306,6 +307,11 @@ class nsObjectLoadingContent : public nsImageLoadingContent
|
||||
*/
|
||||
nsCOMPtr<nsIFrameLoader> mFrameLoader;
|
||||
|
||||
/**
|
||||
* A pending nsAsyncInstantiateEvent (may be null). This is a weak ref.
|
||||
*/
|
||||
nsIRunnable *mPendingInstantiateEvent;
|
||||
|
||||
/**
|
||||
* The content type of the resource we were last asked to load.
|
||||
*/
|
||||
|
@ -55,13 +55,13 @@
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMDOMImplementation.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIPrivateDOMImplementation.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsContentCID.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIScriptLoader.h"
|
||||
@ -311,42 +311,26 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel,
|
||||
nsresult
|
||||
nsSyncLoader::PushAsyncStream(nsIStreamListener* aListener)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Set up a new eventqueue
|
||||
nsCOMPtr<nsIEventQueueService> service =
|
||||
do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIEventQueue> currentThreadQ;
|
||||
rv = service->PushThreadEventQueue(getter_AddRefs(currentThreadQ));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Hook us up to listen to redirects and the like
|
||||
mChannel->SetNotificationCallbacks(this);
|
||||
|
||||
// Start reading from the channel
|
||||
rv = mChannel->AsyncOpen(aListener, nsnull);
|
||||
nsresult rv = mChannel->AsyncOpen(aListener, nsnull);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mLoading = PR_TRUE;
|
||||
|
||||
// process events until we're finished.
|
||||
PLEvent *event;
|
||||
mLoading = PR_TRUE;
|
||||
nsIThread *thread = NS_GetCurrentThread();
|
||||
while (mLoading && NS_SUCCEEDED(rv)) {
|
||||
rv = currentThreadQ->WaitForEvent(&event);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), ": currentThreadQ->WaitForEvent failed...\n");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = currentThreadQ->HandleEvent(event);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), ": currentThreadQ->HandleEvent failed...\n");
|
||||
}
|
||||
PRBool processedEvent;
|
||||
rv = thread->ProcessNextEvent(PR_TRUE, &processedEvent);
|
||||
if (NS_SUCCEEDED(rv) && !processedEvent)
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
|
||||
// Note that if AsyncOpen failed that's ok -- the only caller of
|
||||
// this method nulls out mChannel immediately after we return.
|
||||
|
||||
service->PopThreadEventQueue(currentThreadQ);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "nsIURI.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIUploadChannel.h"
|
||||
#include "nsIDOMSerializer.h"
|
||||
#include "nsXPCOM.h"
|
||||
@ -90,7 +91,6 @@ static const char* kLoadAsData = "loadAsData";
|
||||
// CIDs
|
||||
static NS_DEFINE_CID(kIDOMDOMImplementationCID, NS_DOM_IMPLEMENTATION_CID);
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
// State
|
||||
#define XML_HTTP_REQUEST_UNINITIALIZED (1 << 0) // 0
|
||||
@ -1602,20 +1602,8 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
|
||||
// Reset responseXML
|
||||
mDocument = nsnull;
|
||||
|
||||
nsCOMPtr<nsIEventQueue> modalEventQueue;
|
||||
|
||||
if (!(mState & XML_HTTP_REQUEST_ASYNC)) {
|
||||
if(!mEventQService) {
|
||||
mEventQService = do_GetService(kEventQueueServiceCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
mState |= XML_HTTP_REQUEST_SYNCLOOPING;
|
||||
|
||||
rv = mEventQService->PushThreadEventQueue(getter_AddRefs(modalEventQueue));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mScriptContext) {
|
||||
@ -1665,10 +1653,6 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
|
||||
rv = mChannel->AsyncOpen(listener, nsnull);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
if (modalEventQueue) {
|
||||
mEventQService->PopThreadEventQueue(modalEventQueue);
|
||||
}
|
||||
|
||||
// Drop our ref to the channel to avoid cycles
|
||||
mChannel = nsnull;
|
||||
return rv;
|
||||
@ -1676,22 +1660,20 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
|
||||
|
||||
// If we're synchronous, spin an event loop here and wait
|
||||
if (!(mState & XML_HTTP_REQUEST_ASYNC)) {
|
||||
nsIThread *thread = NS_GetCurrentThread();
|
||||
while (mState & XML_HTTP_REQUEST_SYNCLOOPING) {
|
||||
modalEventQueue->ProcessPendingEvents();
|
||||
|
||||
// Be sure not to busy wait! (see bug 273578)
|
||||
if (mState & XML_HTTP_REQUEST_SYNCLOOPING)
|
||||
PR_Sleep(PR_MillisecondsToInterval(10));
|
||||
if (!NS_ProcessNextEvent(thread)) {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mEventQService->PopThreadEventQueue(modalEventQueue);
|
||||
}
|
||||
|
||||
if (!mChannel) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void setRequestHeader (in AUTF8String header, in AUTF8String value); */
|
||||
|
@ -49,7 +49,6 @@
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsIScriptContext.h"
|
||||
@ -171,7 +170,6 @@ protected:
|
||||
nsCOMPtr<nsIDOMEventListener> mOnReadystatechangeListener;
|
||||
|
||||
nsCOMPtr<nsIStreamListener> mXMLParserStreamListener;
|
||||
nsCOMPtr<nsIEventQueueService> mEventQService;
|
||||
|
||||
// used to implement getAllResponseHeaders()
|
||||
class nsHeaderVisitor : public nsIHttpHeaderVisitor {
|
||||
|
@ -39,29 +39,32 @@
|
||||
#define nsPLDOMEvent_h___
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "plevent.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsString.h"
|
||||
|
||||
/**
|
||||
* Use nsPLDOMEvent to fire a DOM event that requires safe a stable DOM.
|
||||
* For example, you may need to fire an event from within layout, but
|
||||
* want to ensure that the event handler doesn't mutate the DOM at
|
||||
* the wrong time, in order to avoid resulting instability.
|
||||
*
|
||||
* TODO: This should be renamed nsAsyncDOMEvent or something that does
|
||||
* not include the substring "PL" that refers to the old PLEvent
|
||||
* structure used with the old eventing system. See bug 334573.
|
||||
*/
|
||||
|
||||
struct nsPLDOMEvent : public PLEvent {
|
||||
class nsPLDOMEvent : public nsRunnable {
|
||||
public:
|
||||
nsPLDOMEvent (nsIDOMNode *aEventNode, const nsAString& aEventType)
|
||||
: mEventNode(aEventNode), mEventType(aEventType)
|
||||
{ }
|
||||
|
||||
void HandleEvent();
|
||||
NS_IMETHOD Run();
|
||||
nsresult PostDOMEvent();
|
||||
|
||||
nsCOMPtr<nsIDOMNode> mEventNode;
|
||||
nsString mEventType;
|
||||
};
|
||||
|
||||
static void* PR_CALLBACK HandlePLDOMEvent(PLEvent* aEvent);
|
||||
static void PR_CALLBACK DestroyPLDOMEvent(PLEvent* aEvent);
|
||||
|
||||
#endif
|
||||
|
@ -36,17 +36,16 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsPLDOMEvent.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
|
||||
void nsPLDOMEvent::HandleEvent()
|
||||
NS_IMETHODIMP nsPLDOMEvent::Run()
|
||||
{
|
||||
if (!mEventNode) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
@ -66,29 +65,11 @@ void nsPLDOMEvent::HandleEvent()
|
||||
target->DispatchEvent(domEvent, &defaultActionEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPLDOMEvent::PostDOMEvent()
|
||||
{
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
nsresult rv = NS_GetCurrentEventQ(getter_AddRefs(eventQueue));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PL_InitEvent(this, nsnull, ::HandlePLDOMEvent, ::DestroyPLDOMEvent);
|
||||
rv = eventQueue->PostEvent(this);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void* PR_CALLBACK HandlePLDOMEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsPLDOMEvent* event = NS_STATIC_CAST(nsPLDOMEvent*, aEvent);
|
||||
event->HandleEvent();
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
static void PR_CALLBACK DestroyPLDOMEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsPLDOMEvent* event = NS_STATIC_CAST(nsPLDOMEvent*, aEvent);
|
||||
delete event;
|
||||
return NS_DispatchToCurrentThread(this);
|
||||
}
|
||||
|
@ -58,6 +58,8 @@
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prtime.h"
|
||||
#include "prlog.h"
|
||||
@ -118,7 +120,6 @@
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "plevent.h"
|
||||
|
||||
#include "nsEscape.h"
|
||||
#include "nsIElementObserver.h"
|
||||
@ -127,6 +128,17 @@
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
FavorPerformanceHint(PRBool perfOverStarvation, PRUint32 starvationDelay)
|
||||
{
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
nsCOMPtr<nsIAppShell> appShell = do_GetService(kAppShellCID);
|
||||
if (appShell)
|
||||
appShell->FavorPerformanceHint(perfOverStarvation, starvationDelay);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
static PRLogModuleInfo* gSinkLogModuleInfo;
|
||||
|
||||
@ -2312,7 +2324,7 @@ HTMLContentSink::DidBuildModel(void)
|
||||
if (mFlags & NS_SINK_FLAG_DYNAMIC_LOWER_VALUE) {
|
||||
// Reset the performance hint which was set to FALSE
|
||||
// when NS_SINK_FLAG_DYNAMIC_LOWER_VALUE was set.
|
||||
PL_FavorPerformanceHint(PR_TRUE , 0);
|
||||
FavorPerformanceHint(PR_TRUE , 0);
|
||||
}
|
||||
|
||||
if (mFlags & NS_SINK_FLAG_CAN_INTERRUPT_PARSER) {
|
||||
@ -3430,7 +3442,7 @@ HTMLContentSink::DidProcessAToken(void)
|
||||
// Set the performance hint to prevent event starvation when
|
||||
// dispatching PLEvents. This improves application responsiveness
|
||||
// during page loads.
|
||||
PL_FavorPerformanceHint(PR_FALSE, 0);
|
||||
FavorPerformanceHint(PR_FALSE, 0);
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -3440,7 +3452,7 @@ HTMLContentSink::DidProcessAToken(void)
|
||||
// to favor overall page load speed over responsiveness.
|
||||
mFlags &= ~NS_SINK_FLAG_DYNAMIC_LOWER_VALUE;
|
||||
// Reset the hint that to favoring performance for PLEvent dispatch.
|
||||
PL_FavorPerformanceHint(PR_TRUE, 0);
|
||||
FavorPerformanceHint(PR_TRUE, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -81,6 +81,7 @@
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
@ -96,8 +97,6 @@
|
||||
|
||||
static const char kLoadAsData[] = "loadAsData";
|
||||
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
|
||||
// ==================================================================
|
||||
// =
|
||||
@ -217,8 +216,6 @@ nsXMLDocument::Init()
|
||||
nsresult rv = nsDocument::Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mEventQService = do_GetService(kEventQueueServiceCID, &rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -499,17 +496,6 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn)
|
||||
|
||||
SetPrincipal(principal);
|
||||
|
||||
nsCOMPtr<nsIEventQueue> modalEventQueue;
|
||||
|
||||
if(!mAsync) {
|
||||
NS_ENSURE_TRUE(mEventQService, NS_ERROR_FAILURE);
|
||||
|
||||
rv = mEventQService->PushThreadEventQueue(getter_AddRefs(modalEventQueue));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare for loading the XML document "into oneself"
|
||||
nsCOMPtr<nsIStreamListener> listener;
|
||||
if (NS_FAILED(rv = StartDocumentLoad(kLoadAsData, channel,
|
||||
@ -517,9 +503,6 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn)
|
||||
getter_AddRefs(listener),
|
||||
PR_FALSE))) {
|
||||
NS_ERROR("nsXMLDocument::Load: Failed to start the document load.");
|
||||
if (modalEventQueue) {
|
||||
mEventQService->PopThreadEventQueue(modalEventQueue);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -530,21 +513,18 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn)
|
||||
rv = channel->AsyncOpen(listener, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
mChannelIsPending = PR_FALSE;
|
||||
if (modalEventQueue) {
|
||||
mEventQService->PopThreadEventQueue(modalEventQueue);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!mAsync) {
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
|
||||
mLoopingForSyncLoad = PR_TRUE;
|
||||
|
||||
while (mLoopingForSyncLoad) {
|
||||
modalEventQueue->ProcessPendingEvents();
|
||||
if (!NS_ProcessNextEvent(thread))
|
||||
break;
|
||||
}
|
||||
|
||||
mEventQService->PopThreadEventQueue(modalEventQueue);
|
||||
|
||||
// We set return to true unless there was a parsing error
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(mRootContent);
|
||||
if (node) {
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsHTMLStyleSheet.h"
|
||||
#include "nsIHTMLCSSStyleSheet.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
|
||||
class nsIParser;
|
||||
class nsIDOMNode;
|
||||
@ -98,8 +97,6 @@ public:
|
||||
protected:
|
||||
virtual nsresult GetLoadGroup(nsILoadGroup **aLoadGroup);
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> mEventQService;
|
||||
|
||||
nsCOMPtr<nsIScriptContext> mScriptContext;
|
||||
|
||||
// mChannelIsPending indicates whether we're currently asynchronously loading
|
||||
|
@ -63,8 +63,8 @@
|
||||
#include "txUnknownHandler.h"
|
||||
#include "txXSLTProcessor.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
|
||||
static NS_DEFINE_CID(kXMLDocumentCID, NS_XMLDOCUMENT_CID);
|
||||
|
||||
@ -364,30 +364,27 @@ txMozillaXSLTProcessor::SetSourceContentModel(nsIDOMNode* aSourceDOM)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
void* PR_CALLBACK
|
||||
HandleTransformBlockerEvent(PLEvent *aEvent)
|
||||
{
|
||||
txMozillaXSLTProcessor *processor =
|
||||
NS_STATIC_CAST(txMozillaXSLTProcessor*, aEvent->owner);
|
||||
processor->TransformToDoc(nsnull, nsnull);
|
||||
class nsTransformBlockerEvent : public nsRunnable {
|
||||
public:
|
||||
nsRefPtr<txMozillaXSLTProcessor> mProcessor;
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
nsTransformBlockerEvent(txMozillaXSLTProcessor *processor)
|
||||
: mProcessor(processor)
|
||||
{}
|
||||
|
||||
void PR_CALLBACK
|
||||
DestroyTransformBlockerEvent(PLEvent *aEvent)
|
||||
{
|
||||
txMozillaXSLTProcessor *processor =
|
||||
NS_STATIC_CAST(txMozillaXSLTProcessor*, aEvent->owner);
|
||||
~nsTransformBlockerEvent()
|
||||
{
|
||||
nsCOMPtr<nsIDocument> document =
|
||||
do_QueryInterface(processor->GetSourceContentModel());
|
||||
do_QueryInterface(mProcessor->GetSourceContentModel());
|
||||
document->UnblockOnload(PR_TRUE);
|
||||
}
|
||||
|
||||
NS_RELEASE(processor);
|
||||
delete aEvent;
|
||||
}
|
||||
PR_END_EXTERN_C
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
mProcessor->TransformToDoc(nsnull, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
nsresult
|
||||
txMozillaXSLTProcessor::DoTransform()
|
||||
@ -395,39 +392,24 @@ txMozillaXSLTProcessor::DoTransform()
|
||||
NS_ENSURE_TRUE(mSource, NS_ERROR_UNEXPECTED);
|
||||
NS_ENSURE_TRUE(mStylesheet, NS_ERROR_UNEXPECTED);
|
||||
NS_ASSERTION(mObserver, "no observer");
|
||||
NS_ASSERTION(NS_IsMainThread(), "should only be on main thread");
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDocument> document = do_QueryInterface(mSource, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> service =
|
||||
do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
rv = service->GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
|
||||
getter_AddRefs(eventQ));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PLEvent* event = new PLEvent();
|
||||
nsCOMPtr<nsIRunnable> event = new nsTransformBlockerEvent(this);
|
||||
if (!event) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
PL_InitEvent(event, this, HandleTransformBlockerEvent,
|
||||
DestroyTransformBlockerEvent);
|
||||
|
||||
document->BlockOnload();
|
||||
|
||||
// After this point, event destruction will release |this| (in
|
||||
// DestroyTransformBlockerEvent)
|
||||
NS_ADDREF_THIS();
|
||||
|
||||
rv = eventQ->PostEvent(event);
|
||||
rv = NS_DispatchToCurrentThread(event);
|
||||
if (NS_FAILED(rv)) {
|
||||
// XXX Maybe we should just display the source document in this case?
|
||||
// Also, set up context information, see bug 204655.
|
||||
reportError(rv, nsnull, nsnull);
|
||||
PL_DestroyEvent(event);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -49,13 +49,12 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsLDAPConnection.h"
|
||||
#include "nsLDAPMessage.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIDNSService.h"
|
||||
#include "nsIDNSRecord.h"
|
||||
#include "nsIRequestObserver.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsNetError.h"
|
||||
#include "nsLDAPOperation.h"
|
||||
#include "nsILDAPErrors.h"
|
||||
@ -194,11 +193,10 @@ nsLDAPConnection::Init(const char *aHost, PRInt32 aPort, PRBool aSSL,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEventQueue> curEventQ;
|
||||
rv = NS_GetCurrentEventQ(getter_AddRefs(curEventQ));
|
||||
if (NS_FAILED(rv)) {
|
||||
nsCOMPtr<nsIThread> curThread = do_GetCurrentThread();
|
||||
if (!curThread) {
|
||||
NS_ERROR("nsLDAPConnection::Init(): couldn't "
|
||||
"get current event queue");
|
||||
"get current thread");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// Do the pre-resolve of the hostname, using the DNS service. This
|
||||
@ -230,7 +228,7 @@ nsLDAPConnection::Init(const char *aHost, PRInt32 aPort, PRBool aSSL,
|
||||
if (spacePos != kNotFound)
|
||||
mDNSHost.Truncate(spacePos);
|
||||
|
||||
rv = pDNSService->AsyncResolve(mDNSHost, 0, this, curEventQ,
|
||||
rv = pDNSService->AsyncResolve(mDNSHost, 0, this, curThread,
|
||||
getter_AddRefs(mDNSRequest));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -1023,13 +1021,13 @@ nsLDAPConnection::OnLookupComplete(nsICancelable *aRequest,
|
||||
mRunnable->mWeakConn = do_GetWeakReference(conn);
|
||||
|
||||
// kick off a thread for result listening and marshalling
|
||||
// XXXdmose - should this be JOINABLE?
|
||||
//
|
||||
rv = NS_NewThread(getter_AddRefs(mThread), mRunnable, 0,
|
||||
PR_UNJOINABLE_THREAD);
|
||||
rv = NS_NewThread(getter_AddRefs(mThread), mRunnable);
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
// XXX(darin): We need to shutdown this thread at some point.
|
||||
// Otherwise, it will stick around until shutdown.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,8 @@
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefBranch2.h"
|
||||
#include "nsIWritablePropertyBag2.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
// we want to explore making the document own the load group
|
||||
// so we can associate the document URI with the load group.
|
||||
@ -175,15 +177,13 @@ static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
|
||||
static NS_DEFINE_CID(kDocumentCharsetInfoCID, NS_DOCUMENTCHARSETINFO_CID);
|
||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
|
||||
NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
|
||||
#if defined(DEBUG_bryner) || defined(DEBUG_chb)
|
||||
//#define DEBUG_DOCSHELL_FOCUS
|
||||
#define DEBUG_PAGE_CACHE
|
||||
#endif
|
||||
|
||||
#include "plevent.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsContentErrors.h"
|
||||
|
||||
// Number of documents currently loading
|
||||
@ -200,7 +200,7 @@ nsIURIFixup *nsDocShell::sURIFixup = 0;
|
||||
// the pref on the creation of the first docshell.
|
||||
static PRBool gValidateOrigin = (PRBool)0xffffffff;
|
||||
|
||||
// Hint for native dispatch of plevents on how long to delay after
|
||||
// Hint for native dispatch of events on how long to delay after
|
||||
// all documents have loaded in milliseconds before favoring normal
|
||||
// native event dispatch priorites over performance
|
||||
#define NS_EVENT_STARVATION_DELAY_HINT 2000
|
||||
@ -218,6 +218,14 @@ static PRLogModuleInfo* gDocShellLog;
|
||||
static PRLogModuleInfo* gDocShellLeakLog;
|
||||
#endif
|
||||
|
||||
static void
|
||||
FavorPerformanceHint(PRBool perfOverStarvation, PRUint32 starvationDelay)
|
||||
{
|
||||
nsCOMPtr<nsIAppShell> appShell = do_GetService(kAppShellCID);
|
||||
if (appShell)
|
||||
appShell->FavorPerformanceHint(perfOverStarvation, starvationDelay);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsDocShellFocusController
|
||||
//*****************************************************************************
|
||||
@ -3197,11 +3205,8 @@ NS_IMETHODIMP
|
||||
nsDocShell::Stop(PRUint32 aStopFlags)
|
||||
{
|
||||
if (nsIWebNavigation::STOP_CONTENT & aStopFlags) {
|
||||
// Revoke any pending plevents related to content viewer restoration
|
||||
nsCOMPtr<nsIEventQueue> uiThreadQueue;
|
||||
NS_GetMainEventQ(getter_AddRefs(uiThreadQueue));
|
||||
if (uiThreadQueue)
|
||||
uiThreadQueue->RevokeEvents(this);
|
||||
// Revoke any pending event related to content viewer restoration
|
||||
mRestorePresentationEvent.Revoke();
|
||||
|
||||
// Stop the document loading
|
||||
if (mContentViewer)
|
||||
@ -4778,7 +4783,7 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
|
||||
// over performance
|
||||
if (--gNumberOfDocumentsLoading == 0) {
|
||||
// Hint to use normal native event dispatch priorities
|
||||
PL_FavorPerformanceHint(PR_FALSE, NS_EVENT_STARVATION_DELAY_HINT);
|
||||
FavorPerformanceHint(PR_FALSE, NS_EVENT_STARVATION_DELAY_HINT);
|
||||
}
|
||||
}
|
||||
/* Check if the httpChannel has any cache-control related response headers,
|
||||
@ -5066,39 +5071,12 @@ nsDocShell::CaptureState()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class RestorePresentationEvent : public PLEvent
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::RestorePresentationEvent::Run()
|
||||
{
|
||||
public:
|
||||
RestorePresentationEvent(nsDocShell *aShell);
|
||||
|
||||
nsRefPtr<nsDocShell> mDocShell;
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(void*)
|
||||
HandleRestorePresentationEvent(PLEvent *aEvent)
|
||||
{
|
||||
RestorePresentationEvent *event =
|
||||
NS_STATIC_CAST(RestorePresentationEvent*, aEvent);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
event->mDocShell->RestoreFromHistory();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "RestoreFromHistory failed");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
DestroyRestorePresentationEvent(PLEvent *aEvent)
|
||||
{
|
||||
delete NS_STATIC_CAST(RestorePresentationEvent*, aEvent);
|
||||
}
|
||||
|
||||
RestorePresentationEvent::RestorePresentationEvent(nsDocShell *aShell)
|
||||
: mDocShell(aShell)
|
||||
{
|
||||
PL_InitEvent(this, mDocShell, ::HandleRestorePresentationEvent,
|
||||
::DestroyRestorePresentationEvent);
|
||||
if (mDocShell && NS_FAILED(mDocShell->RestoreFromHistory()))
|
||||
NS_WARNING("RestoreFromHistory failed");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -5258,32 +5236,32 @@ nsDocShell::RestorePresentation(nsISHEntry *aSHEntry, PRBool *aRestoring)
|
||||
|
||||
BeginRestore(viewer, PR_TRUE);
|
||||
|
||||
// Post a PLEvent that will remove the request after we've returned
|
||||
// Post an event that will remove the request after we've returned
|
||||
// to the event loop. This mimics the way it is called by nsIChannel
|
||||
// implementations.
|
||||
|
||||
nsCOMPtr<nsIEventQueue> uiThreadQueue;
|
||||
NS_GetMainEventQ(getter_AddRefs(uiThreadQueue));
|
||||
NS_ENSURE_TRUE(uiThreadQueue, NS_ERROR_UNEXPECTED);
|
||||
// Revoke any pending restore (just in case)
|
||||
NS_ASSERTION(!mRestorePresentationEvent.IsPending(),
|
||||
"should only have one RestorePresentationEvent");
|
||||
mRestorePresentationEvent.Revoke();
|
||||
|
||||
PLEvent *evt = new RestorePresentationEvent(this);
|
||||
NS_ENSURE_TRUE(evt, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsresult rv = uiThreadQueue->PostEvent(evt);
|
||||
nsRefPtr<RestorePresentationEvent> evt = new RestorePresentationEvent(this);
|
||||
nsresult rv = NS_DispatchToCurrentThread(evt);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// The rest of the restore processing will happen on our PLEvent
|
||||
mRestorePresentationEvent = evt.get();
|
||||
// The rest of the restore processing will happen on our event
|
||||
// callback.
|
||||
*aRestoring = PR_TRUE;
|
||||
} else {
|
||||
PL_DestroyEvent(evt);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocShell::RestoreFromHistory()
|
||||
{
|
||||
mRestorePresentationEvent.Forget();
|
||||
|
||||
// This section of code follows the same ordering as CreateContentViewer.
|
||||
if (!mLSHE)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -5487,7 +5465,7 @@ nsDocShell::RestoreFromHistory()
|
||||
// Tell the event loop to favor plevents over user events, see comments
|
||||
// in CreateContentViewer.
|
||||
if (++gNumberOfDocumentsLoading == 1)
|
||||
PL_FavorPerformanceHint(PR_TRUE, NS_EVENT_STARVATION_DELAY_HINT);
|
||||
FavorPerformanceHint(PR_TRUE, NS_EVENT_STARVATION_DELAY_HINT);
|
||||
|
||||
|
||||
if (oldMUDV && newMUDV)
|
||||
@ -5730,7 +5708,7 @@ nsDocShell::CreateContentViewer(const char *aContentType,
|
||||
// Hint to favor performance for the plevent notification mechanism.
|
||||
// We want the pages to load as fast as possible even if its means
|
||||
// native messages might be starved.
|
||||
PL_FavorPerformanceHint(PR_TRUE, NS_EVENT_STARVATION_DELAY_HINT);
|
||||
FavorPerformanceHint(PR_TRUE, NS_EVENT_STARVATION_DELAY_HINT);
|
||||
}
|
||||
|
||||
if (onLocationChangeNeeded) {
|
||||
|
@ -72,6 +72,7 @@
|
||||
#include "nsPoint.h" // mCurrent/mDefaultScrollbarPreferences
|
||||
#include "nsString.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
// Threshold value in ms for META refresh based redirects
|
||||
#define REFRESH_REDIRECT_TIMER 15000
|
||||
@ -469,6 +470,16 @@ protected:
|
||||
// Override the parent setter from nsDocLoader
|
||||
virtual nsresult SetDocLoaderParent(nsDocLoader * aLoader);
|
||||
|
||||
// Event type dispatched by RestorePresentation
|
||||
class RestorePresentationEvent : public nsRunnable {
|
||||
public:
|
||||
NS_DECL_NSIRUNNABLE
|
||||
RestorePresentationEvent(nsDocShell *ds) : mDocShell(ds) {}
|
||||
void Revoke() { mDocShell = nsnull; }
|
||||
private:
|
||||
nsDocShell *mDocShell;
|
||||
};
|
||||
|
||||
PRPackedBool mAllowSubframes;
|
||||
PRPackedBool mAllowPlugins;
|
||||
PRPackedBool mAllowJavascript;
|
||||
@ -546,6 +557,11 @@ protected:
|
||||
// Somebody give me better name
|
||||
nsCOMPtr<nsISHEntry> mLSHE;
|
||||
|
||||
// Holds a weak pointer to a RestorePresentationEvent object if any that
|
||||
// holds a weak pointer back to us. We use this pointer to possibly revoke
|
||||
// the event whenever necessary.
|
||||
nsRevocableEventPtr<RestorePresentationEvent> mRestorePresentationEvent;
|
||||
|
||||
// Index into the SHTransaction list, indicating the previous and current
|
||||
// transaction at the time that this DocShell begins to load
|
||||
PRInt32 mPreviousTransIndex;
|
||||
|
@ -56,12 +56,10 @@
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "plevent.h"
|
||||
#include "prprf.h"
|
||||
#include "nsIPluginHost.h"
|
||||
#include "nsplugin.h"
|
||||
@ -105,6 +103,7 @@
|
||||
#include "nsIUploadChannel.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsIStringBundle.h"
|
||||
@ -404,10 +403,9 @@ nsWebShell::nsWebShell() : nsDocShell()
|
||||
++gNumberOfWebShells;
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
printf("++WEBSHELL %p == %ld\n", this, gNumberOfWebShells);
|
||||
printf("++WEBSHELL %p == %ld\n", (void*) this, gNumberOfWebShells);
|
||||
#endif
|
||||
|
||||
mThread = nsnull;
|
||||
InitFrameData();
|
||||
mItemType = typeContent;
|
||||
mCharsetReloadState = eCharsetReloadInit;
|
||||
@ -430,7 +428,7 @@ nsWebShell::~nsWebShell()
|
||||
--gNumberOfWebShells;
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
printf("--WEBSHELL %p == %ld\n", this, gNumberOfWebShells);
|
||||
printf("--WEBSHELL %p == %ld\n", (void*) this, gNumberOfWebShells);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -565,14 +563,15 @@ nsWebShell::SetRendering(PRBool aRender)
|
||||
|
||||
// WebShell link handling
|
||||
|
||||
struct OnLinkClickEvent : public PLEvent {
|
||||
class OnLinkClickEvent : public nsRunnable {
|
||||
public:
|
||||
OnLinkClickEvent(nsWebShell* aHandler, nsIContent* aContent,
|
||||
nsLinkVerb aVerb, nsIURI* aURI,
|
||||
const PRUnichar* aTargetSpec, nsIInputStream* aPostDataStream = 0,
|
||||
const PRUnichar* aTargetSpec,
|
||||
nsIInputStream* aPostDataStream = 0,
|
||||
nsIInputStream* aHeadersDataStream = 0);
|
||||
~OnLinkClickEvent();
|
||||
|
||||
void HandleEvent() {
|
||||
NS_IMETHOD Run() {
|
||||
nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(mHandler->mScriptGlobal));
|
||||
nsAutoPopupStatePusher popupStatePusher(window, mPopupState);
|
||||
|
||||
@ -580,9 +579,11 @@ struct OnLinkClickEvent : public PLEvent {
|
||||
mTargetSpec.get(), mPostDataStream,
|
||||
mHeadersDataStream,
|
||||
nsnull, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsWebShell* mHandler;
|
||||
private:
|
||||
nsRefPtr<nsWebShell> mHandler;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsString mTargetSpec;
|
||||
nsCOMPtr<nsIInputStream> mPostDataStream;
|
||||
@ -592,19 +593,6 @@ struct OnLinkClickEvent : public PLEvent {
|
||||
PopupControlState mPopupState;
|
||||
};
|
||||
|
||||
static void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent)
|
||||
{
|
||||
OnLinkClickEvent* event = NS_STATIC_CAST(OnLinkClickEvent*, aEvent);
|
||||
event->HandleEvent();
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent)
|
||||
{
|
||||
OnLinkClickEvent* event = NS_STATIC_CAST(OnLinkClickEvent*, aEvent);
|
||||
delete event;
|
||||
}
|
||||
|
||||
OnLinkClickEvent::OnLinkClickEvent(nsWebShell* aHandler,
|
||||
nsIContent *aContent,
|
||||
nsLinkVerb aVerb,
|
||||
@ -612,32 +600,17 @@ OnLinkClickEvent::OnLinkClickEvent(nsWebShell* aHandler,
|
||||
const PRUnichar* aTargetSpec,
|
||||
nsIInputStream* aPostDataStream,
|
||||
nsIInputStream* aHeadersDataStream)
|
||||
: mHandler(aHandler)
|
||||
, mURI(aURI)
|
||||
, mTargetSpec(aTargetSpec)
|
||||
, mPostDataStream(aPostDataStream)
|
||||
, mHeadersDataStream(aHeadersDataStream)
|
||||
, mContent(aContent)
|
||||
, mVerb(aVerb)
|
||||
{
|
||||
mHandler = aHandler;
|
||||
NS_ADDREF(aHandler);
|
||||
mURI = aURI;
|
||||
mTargetSpec.Assign(aTargetSpec);
|
||||
mPostDataStream = aPostDataStream;
|
||||
mHeadersDataStream = aHeadersDataStream;
|
||||
mContent = aContent;
|
||||
mVerb = aVerb;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(mHandler->mScriptGlobal));
|
||||
|
||||
mPopupState = window->GetPopupControlState();
|
||||
|
||||
PL_InitEvent(this, nsnull, ::HandlePLEvent, ::DestroyPLEvent);
|
||||
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
aHandler->GetEventQueue(getter_AddRefs(eventQueue));
|
||||
NS_ASSERTION(eventQueue, "no event queue");
|
||||
if (eventQueue)
|
||||
eventQueue->PostEvent(this);
|
||||
}
|
||||
|
||||
OnLinkClickEvent::~OnLinkClickEvent()
|
||||
{
|
||||
NS_IF_RELEASE(mHandler);
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
@ -650,26 +623,11 @@ nsWebShell::OnLinkClick(nsIContent* aContent,
|
||||
nsIInputStream* aPostDataStream,
|
||||
nsIInputStream* aHeadersDataStream)
|
||||
{
|
||||
OnLinkClickEvent* ev;
|
||||
|
||||
ev = new OnLinkClickEvent(this, aContent, aVerb, aURI,
|
||||
aTargetSpec, aPostDataStream, aHeadersDataStream);
|
||||
if (!ev) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsWebShell::GetEventQueue(nsIEventQueue **aQueue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aQueue);
|
||||
*aQueue = 0;
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> eventService(do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID));
|
||||
if (eventService)
|
||||
eventService->GetThreadEventQueue(mThread, aQueue);
|
||||
return *aQueue ? NS_OK : NS_ERROR_FAILURE;
|
||||
NS_ASSERTION(NS_IsMainThread(), "wrong thread");
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
new OnLinkClickEvent(this, aContent, aVerb, aURI, aTargetSpec,
|
||||
aPostDataStream, aHeadersDataStream);
|
||||
return NS_DispatchToCurrentThread(ev);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1386,14 +1344,6 @@ NS_IMETHODIMP nsWebShell::Create()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Remember the current thread (in current and forseeable implementations,
|
||||
// it'll just be the unique UI thread)
|
||||
//
|
||||
// Since this call must be made on the UI thread, we know the Event Queue
|
||||
// will be associated with the current thread...
|
||||
//
|
||||
mThread = PR_GetCurrentThread();
|
||||
|
||||
WEB_TRACE(WEB_TRACE_CALLS,
|
||||
("nsWebShell::Init: this=%p", this));
|
||||
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include "nsIIOService.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
class nsIEventQueue;
|
||||
class nsIController;
|
||||
struct PRThread;
|
||||
struct OnLinkClickEvent;
|
||||
@ -103,9 +102,6 @@ public:
|
||||
|
||||
NS_IMETHOD Create();
|
||||
|
||||
// nsWebShell
|
||||
nsresult GetEventQueue(nsIEventQueue **aQueue);
|
||||
|
||||
static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
|
||||
|
||||
// NS_IMETHOD SetURL(const PRUnichar* aURL);
|
||||
@ -129,8 +125,6 @@ protected:
|
||||
nsIChannel* channel,
|
||||
nsresult aStatus);
|
||||
|
||||
PRThread *mThread;
|
||||
|
||||
eCharsetReloadState mCharsetReloadState;
|
||||
|
||||
nsresult CreateViewer(nsIRequest* request,
|
||||
|
@ -49,10 +49,8 @@
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "plevent.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
|
||||
static PRUint32 gEntryID = 0;
|
||||
@ -685,63 +683,39 @@ nsSHEntry::ContentRemoved(nsIDocument* aDocument,
|
||||
DocumentMutated();
|
||||
}
|
||||
|
||||
class DestroyViewerEvent : public PLEvent
|
||||
class DestroyViewerEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
DestroyViewerEvent(nsIContentViewer* aViewer, nsIDocument* aDocument);
|
||||
DestroyViewerEvent(nsIContentViewer* aViewer, nsIDocument* aDocument)
|
||||
: mViewer(aViewer),
|
||||
mDocument(aDocument)
|
||||
{}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
if (mViewer)
|
||||
mViewer->Destroy();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContentViewer> mViewer;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(void*)
|
||||
HandleDestroyViewerEvent(PLEvent *aEvent)
|
||||
{
|
||||
nsIContentViewer* viewer = NS_STATIC_CAST(DestroyViewerEvent*, aEvent)->mViewer;
|
||||
if (viewer) {
|
||||
viewer->Destroy();
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
DestroyDestroyViewerEvent(PLEvent *aEvent)
|
||||
{
|
||||
delete NS_STATIC_CAST(DestroyViewerEvent*, aEvent);
|
||||
}
|
||||
|
||||
DestroyViewerEvent::DestroyViewerEvent(nsIContentViewer* aViewer,
|
||||
nsIDocument* aDocument)
|
||||
: mViewer(aViewer),
|
||||
mDocument(aDocument)
|
||||
{
|
||||
PL_InitEvent(this, mViewer, ::HandleDestroyViewerEvent,
|
||||
::DestroyDestroyViewerEvent);
|
||||
}
|
||||
|
||||
void
|
||||
nsSHEntry::DocumentMutated()
|
||||
{
|
||||
NS_ASSERTION(mContentViewer && mDocument,
|
||||
"we shouldn't still be observing the doc");
|
||||
|
||||
// Release the reference to the contentviewer asynconously so that the
|
||||
// Release the reference to the contentviewer asynchronously so that the
|
||||
// document doesn't get nuked mid-mutation.
|
||||
nsCOMPtr<nsIEventQueue> uiThreadQueue;
|
||||
NS_GetMainEventQ(getter_AddRefs(uiThreadQueue));
|
||||
if (!uiThreadQueue) {
|
||||
return;
|
||||
}
|
||||
|
||||
PLEvent *evt = new DestroyViewerEvent(mContentViewer, mDocument);
|
||||
if (!evt) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv = uiThreadQueue->PostEvent(evt);
|
||||
nsCOMPtr<nsIRunnable> evt =
|
||||
new DestroyViewerEvent(mContentViewer, mDocument);
|
||||
nsresult rv = NS_DispatchToCurrentThread(evt);
|
||||
if (NS_FAILED(rv)) {
|
||||
PL_DestroyEvent(evt);
|
||||
NS_WARNING("failed to dispatch DestroyViewerEvent");
|
||||
}
|
||||
else {
|
||||
// Drop presentation. Also ensures that we don't post more then one
|
||||
|
@ -96,7 +96,7 @@
|
||||
#include "nsIDOMPkcs11.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsIEmbeddingSiteWindow2.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIHttpProtocolHandler.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
@ -282,7 +282,6 @@ PRInt32 gTimeoutCnt = 0;
|
||||
PR_END_MACRO
|
||||
|
||||
// CIDs
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
#ifdef OJI
|
||||
static NS_DEFINE_CID(kJVMServiceCID, NS_JVMMANAGER_CID);
|
||||
#endif
|
||||
@ -4227,51 +4226,22 @@ nsGlobalWindow::GetFrames(nsIDOMWindow** aFrames)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
struct nsCloseEvent : public PLEvent {
|
||||
class nsCloseEvent : public nsRunnable {
|
||||
public:
|
||||
nsCloseEvent (nsGlobalWindow *aWindow)
|
||||
: mWindow(aWindow)
|
||||
{
|
||||
}
|
||||
|
||||
void HandleEvent() {
|
||||
NS_IMETHOD Run() {
|
||||
if (mWindow)
|
||||
mWindow->ReallyCloseWindow();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult PostCloseEvent();
|
||||
|
||||
nsRefPtr<nsGlobalWindow> mWindow;
|
||||
};
|
||||
|
||||
static void* PR_CALLBACK HandleCloseEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsCloseEvent *event = NS_STATIC_CAST(nsCloseEvent*, aEvent);
|
||||
event->HandleEvent();
|
||||
return nsnull;
|
||||
}
|
||||
static void PR_CALLBACK DestroyCloseEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsCloseEvent *event = NS_STATIC_CAST(nsCloseEvent*, aEvent);
|
||||
delete event;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCloseEvent::PostCloseEvent()
|
||||
{
|
||||
nsCOMPtr<nsIEventQueueService> eventService(do_GetService(kEventQueueServiceCID));
|
||||
if (eventService) {
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
eventService->GetThreadEventQueue(PR_GetCurrentThread(), getter_AddRefs(eventQueue));
|
||||
if (eventQueue) {
|
||||
|
||||
PL_InitEvent(this, nsnull, ::HandleCloseEvent, ::DestroyCloseEvent);
|
||||
return eventQueue->PostEvent(this);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::Close()
|
||||
{
|
||||
@ -4388,15 +4358,8 @@ nsGlobalWindow::Close()
|
||||
// to really close the window.
|
||||
rv = NS_ERROR_FAILURE;
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
nsCloseEvent *ev = new nsCloseEvent(this);
|
||||
|
||||
if (ev) {
|
||||
rv = ev->PostCloseEvent();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
PL_DestroyEvent(ev);
|
||||
}
|
||||
} else rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
nsCOMPtr<nsIRunnable> ev = new nsCloseEvent(this);
|
||||
rv = NS_DispatchToCurrentThread(ev);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -72,7 +72,7 @@
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsScriptNameSpaceManager.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "nsIAtom.h"
|
||||
@ -143,8 +143,6 @@ static const char kJSRuntimeServiceContractID[] =
|
||||
static const char kDOMStringBundleURL[] =
|
||||
"chrome://global/locale/dom/dom.properties";
|
||||
|
||||
static PRThread *gDOMThread;
|
||||
|
||||
static JSGCCallback gOldJSGCCallback;
|
||||
|
||||
static PRBool sIsInitialized;
|
||||
@ -2207,7 +2205,7 @@ DOMGCCallback(JSContext *cx, JSGCStatus status)
|
||||
{
|
||||
JSBool result = gOldJSGCCallback ? gOldJSGCCallback(cx, status) : JS_TRUE;
|
||||
|
||||
if (status == JSGC_BEGIN && PR_GetCurrentThread() != gDOMThread)
|
||||
if (status == JSGC_BEGIN && !NS_IsMainThread())
|
||||
return JS_FALSE;
|
||||
|
||||
// XPCJSRuntime::GCCallback does marking from the JSGC_MARK_END callback.
|
||||
@ -2231,7 +2229,6 @@ nsJSEnvironment::Startup()
|
||||
gNameSpaceManager = nsnull;
|
||||
sRuntimeService = nsnull;
|
||||
sRuntime = nsnull;
|
||||
gDOMThread = nsnull;
|
||||
gOldJSGCCallback = nsnull;
|
||||
sIsInitialized = PR_FALSE;
|
||||
sDidShutdown = PR_FALSE;
|
||||
@ -2305,19 +2302,8 @@ nsJSEnvironment::Init()
|
||||
rv = sRuntimeService->GetRuntime(&sRuntime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
gDOMThread = PR_GetCurrentThread();
|
||||
|
||||
#ifdef DEBUG
|
||||
// Let's make sure that our main thread is the same as the xpcom main thread.
|
||||
{
|
||||
nsCOMPtr<nsIThread> t;
|
||||
PRThread* mainThread;
|
||||
rv = nsIThread::GetMainThread(getter_AddRefs(t));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv) && t, "bad");
|
||||
rv = t->GetPRThread(&mainThread);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv) && mainThread == gDOMThread, "bad");
|
||||
}
|
||||
#endif
|
||||
NS_ASSERTION(NS_IsMainThread(), "bad");
|
||||
|
||||
NS_ASSERTION(!gOldJSGCCallback,
|
||||
"nsJSEnvironment initialized more than once");
|
||||
|
@ -61,10 +61,8 @@
|
||||
|
||||
#include "prthread.h"
|
||||
#include "prprf.h"
|
||||
#include "plevent.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsStringAPI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
@ -80,6 +78,7 @@
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#define _ATL_APARTMENT_THREADED
|
||||
#define _ATL_STATIC_REGISTRY
|
||||
|
@ -61,7 +61,6 @@
|
||||
|
||||
#include "prthread.h"
|
||||
#include "prprf.h"
|
||||
#include "plevent.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
@ -114,6 +113,7 @@
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#define _ATL_APARTMENT_THREADED
|
||||
#define _ATL_STATIC_REGISTRY
|
||||
|
@ -49,6 +49,7 @@
|
||||
|
||||
#define STRICT
|
||||
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#define _ATL_APARTMENT_THREADED
|
||||
#define _ATL_STATIC_REGISTRY
|
||||
|
@ -45,9 +45,6 @@
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
|
||||
// for NS_APPSHELL_CID
|
||||
#include <nsWidgetsCID.h>
|
||||
|
||||
// for do_GetInterface
|
||||
#include <nsIInterfaceRequestor.h>
|
||||
// for do_CreateInstance
|
||||
@ -96,13 +93,10 @@
|
||||
#include "nsIDOMDocument.h"
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
|
||||
PRUint32 EmbedPrivate::sWidgetCount = 0;
|
||||
|
||||
char *EmbedPrivate::sPath = nsnull;
|
||||
char *EmbedPrivate::sCompPath = nsnull;
|
||||
nsIAppShell *EmbedPrivate::sAppShell = nsnull;
|
||||
nsVoidArray *EmbedPrivate::sWindowList = nsnull;
|
||||
nsILocalFile *EmbedPrivate::sProfileDir = nsnull;
|
||||
nsISupports *EmbedPrivate::sProfileLock = nsnull;
|
||||
@ -568,21 +562,6 @@ EmbedPrivate::PushStartup(void)
|
||||
|
||||
rv = RegisterAppComponents();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Warning: Failed to register app components.\n");
|
||||
|
||||
// XXX startup appshell service?
|
||||
// XXX create offscreen window for appshell service?
|
||||
// XXX remove X prop from offscreen window?
|
||||
|
||||
nsCOMPtr<nsIAppShell> appShell;
|
||||
appShell = do_CreateInstance(kAppShellCID);
|
||||
if (!appShell) {
|
||||
NS_WARNING("Failed to create appshell in EmbedPrivate::PushStartup!\n");
|
||||
return;
|
||||
}
|
||||
sAppShell = appShell.get();
|
||||
NS_ADDREF(sAppShell);
|
||||
sAppShell->Create(0, nsnull);
|
||||
sAppShell->Spinup();
|
||||
}
|
||||
}
|
||||
|
||||
@ -602,13 +581,6 @@ EmbedPrivate::PopStartup(void)
|
||||
sAppFileLocProvider = nsnull;
|
||||
}
|
||||
|
||||
if (sAppShell) {
|
||||
// Shutdown the appshell service.
|
||||
sAppShell->Spindown();
|
||||
NS_RELEASE(sAppShell);
|
||||
sAppShell = 0;
|
||||
}
|
||||
|
||||
// shut down XPCOM/Embedding
|
||||
XRE_TermEmbedding();
|
||||
}
|
||||
|
@ -79,7 +79,6 @@
|
||||
#include "nsIURIFixup.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include "nsUnknownContentTypeHandler.h"
|
||||
|
@ -61,8 +61,6 @@
|
||||
#include "nsIScreen.h"
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIObserverService.h"
|
||||
@ -89,25 +87,10 @@
|
||||
|
||||
#include "jsinterp.h" // for js_AllocStack() and js_FreeStack()
|
||||
|
||||
#ifdef XP_UNIX
|
||||
// please see bug 78421 for the eventual "right" fix for this
|
||||
#define HAVE_LAME_APPSHELL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LAME_APPSHELL
|
||||
#include "nsIAppShell.h"
|
||||
// for NS_APPSHELL_CID
|
||||
#include <nsWidgetsCID.h>
|
||||
#endif
|
||||
|
||||
#ifdef USEWEAKREFS
|
||||
#include "nsIWeakReference.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LAME_APPSHELL
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
#endif
|
||||
|
||||
static const char *sJSStackContractID="@mozilla.org/js/xpc/ContextStack;1";
|
||||
|
||||
/****************************************************************
|
||||
@ -277,74 +260,6 @@ void nsWatcherWindowEnumerator::WindowRemoved(nsWatcherWindowEntry *inInfo) {
|
||||
inInfo->mYounger : 0;
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
********************* EventQueueAutoPopper *********************
|
||||
****************************************************************/
|
||||
|
||||
class EventQueueAutoPopper {
|
||||
public:
|
||||
EventQueueAutoPopper();
|
||||
~EventQueueAutoPopper();
|
||||
|
||||
nsresult Push();
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIEventQueueService> mService;
|
||||
nsCOMPtr<nsIEventQueue> mQueue;
|
||||
#ifdef HAVE_LAME_APPSHELL
|
||||
nsCOMPtr<nsIAppShell> mAppShell;
|
||||
#endif
|
||||
};
|
||||
|
||||
EventQueueAutoPopper::EventQueueAutoPopper() : mQueue(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
EventQueueAutoPopper::~EventQueueAutoPopper()
|
||||
{
|
||||
#ifdef HAVE_LAME_APPSHELL
|
||||
if (mAppShell) {
|
||||
if (mQueue)
|
||||
mAppShell->ListenToEventQueue(mQueue, PR_FALSE);
|
||||
mAppShell->Spindown();
|
||||
mAppShell = nsnull;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(mQueue)
|
||||
mService->PopThreadEventQueue(mQueue);
|
||||
}
|
||||
|
||||
nsresult EventQueueAutoPopper::Push()
|
||||
{
|
||||
if (mQueue) // only once
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID);
|
||||
if (!mService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// push a new queue onto it
|
||||
mService->PushThreadEventQueue(getter_AddRefs(mQueue));
|
||||
if (!mQueue)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef HAVE_LAME_APPSHELL
|
||||
// listen to the event queue
|
||||
mAppShell = do_CreateInstance(kAppShellCID);
|
||||
if (!mAppShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mAppShell->Create(0, nsnull);
|
||||
mAppShell->Spinup();
|
||||
|
||||
// listen to the new queue
|
||||
mAppShell->ListenToEventQueue(mQueue, PR_TRUE);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
********************** JSContextAutoPopper *********************
|
||||
****************************************************************/
|
||||
@ -568,7 +483,6 @@ nsWindowWatcher::OpenWindowJSInternal(nsIDOMWindow *aParent,
|
||||
nsCOMPtr<nsIURI> uriToLoad; // from aUrl, if any
|
||||
nsCOMPtr<nsIDocShellTreeOwner> parentTreeOwner; // from the parent window, if any
|
||||
nsCOMPtr<nsIDocShellTreeItem> newDocShellItem; // from the new window
|
||||
EventQueueAutoPopper queueGuard;
|
||||
JSContextAutoPopper callerContextGuard;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
@ -681,13 +595,10 @@ nsWindowWatcher::OpenWindowJSInternal(nsIDOMWindow *aParent,
|
||||
parentChrome->IsWindowModal(&weAreModal);
|
||||
|
||||
if (weAreModal) {
|
||||
rv = queueGuard.Push();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
windowIsModal = PR_TRUE;
|
||||
// in case we added this because weAreModal
|
||||
chromeFlags |= nsIWebBrowserChrome::CHROME_MODAL |
|
||||
nsIWebBrowserChrome::CHROME_DEPENDENT;
|
||||
}
|
||||
windowIsModal = PR_TRUE;
|
||||
// in case we added this because weAreModal
|
||||
chromeFlags |= nsIWebBrowserChrome::CHROME_MODAL |
|
||||
nsIWebBrowserChrome::CHROME_DEPENDENT;
|
||||
}
|
||||
|
||||
NS_ASSERTION(mWindowCreator,
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "nsMemory.h"
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIEmbeddingSiteWindow.h"
|
||||
#include "nsIFactory.h"
|
||||
@ -53,10 +54,6 @@
|
||||
#include "nsPrintDialogUtil.h"
|
||||
#include "PrintProgressDialog.h"
|
||||
|
||||
// For PLEvent
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "plevent.h"
|
||||
|
||||
static HINSTANCE gInstance;
|
||||
|
||||
//*****************************************************************************
|
||||
@ -103,11 +100,6 @@ private:
|
||||
CPrintProgressDialog* m_PPDlg;
|
||||
};
|
||||
|
||||
// Define PL Callback Functions
|
||||
static void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent);
|
||||
static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent);
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMPL_ISUPPORTS2(CPrintingPromptService, nsIPrintingPromptService, nsIWebProgressListener)
|
||||
@ -167,47 +159,13 @@ CPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
PRBool
|
||||
CPrintingPromptService::FirePauseEvent()
|
||||
{
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> event_service = do_GetService(kEventQueueServiceCID);
|
||||
|
||||
if (!event_service)
|
||||
{
|
||||
NS_WARNING("Failed to get event queue service");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEventQueue> event_queue;
|
||||
|
||||
event_service->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(event_queue));
|
||||
|
||||
if (!event_queue)
|
||||
{
|
||||
NS_WARNING("Failed to get event queue from service");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PLEvent *event = new PLEvent;
|
||||
|
||||
if (!event)
|
||||
{
|
||||
NS_WARNING("Out of memory?");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PL_InitEvent(event, this, ::HandlePLEvent, ::DestroyPLEvent);
|
||||
|
||||
// The event owns the content pointer now.
|
||||
NS_ADDREF_THIS();
|
||||
|
||||
event_queue->PostEvent(event);
|
||||
return PR_TRUE;
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NS_NewRunnableMethod(this, &CPrintingPromptService::NotifyObserver);
|
||||
return NS_SUCCEEDED(NS_DispatchToCurrentThread(event));
|
||||
}
|
||||
|
||||
/* void showProgress (in nsIDOMWindow parent, in nsIWebBrowserPrint webBrowserPrint, in nsIPrintSettings printSettings, in nsIObserver openDialogObserver, in boolean isForPrinting, out nsIWebProgressListener webProgressListener, out nsIPrintProgressParams printProgressParams, out boolean notifyOnOpen); */
|
||||
@ -276,27 +234,6 @@ void CPrintingPromptService::NotifyObserver()
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent)
|
||||
{
|
||||
CPrintingPromptService *printingPromptService = (CPrintingPromptService*)PL_GetEventOwner(aEvent);
|
||||
|
||||
NS_ASSERTION(printingPromptService, "The event owner is null.");
|
||||
if (printingPromptService) {
|
||||
printingPromptService->NotifyObserver();
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent)
|
||||
{
|
||||
CPrintingPromptService *printingPromptService = (CPrintingPromptService*)PL_GetEventOwner(aEvent);
|
||||
NS_IF_RELEASE(printingPromptService);
|
||||
|
||||
delete aEvent;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// nsIWebProgressListener
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsITXTToHTMLConv.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
@ -192,9 +192,8 @@ nsDateTimeChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
|
||||
nsresult rv = NS_CheckPortSafety(mPort, "datetime");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
rv = NS_GetCurrentEventQ(getter_AddRefs(eventQ));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
NS_ENSURE_STATE(thread);
|
||||
|
||||
//
|
||||
// create transport
|
||||
@ -208,7 +207,7 @@ nsDateTimeChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// not fatal if this fails
|
||||
mTransport->SetEventSink(this, eventQ);
|
||||
mTransport->SetEventSink(this, thread);
|
||||
|
||||
//
|
||||
// create TXT to HTML stream converter
|
||||
|
@ -52,7 +52,7 @@
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsITXTToHTMLConv.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
@ -211,9 +211,8 @@ nsFingerChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
|
||||
nsresult rv = NS_CheckPortSafety(mPort, "finger");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
rv = NS_GetCurrentEventQ(getter_AddRefs(eventQ));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
NS_ENSURE_STATE(thread);
|
||||
|
||||
//
|
||||
// create transport
|
||||
@ -227,7 +226,7 @@ nsFingerChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// not fatal if this fails
|
||||
mTransport->SetEventSink(this, eventQ);
|
||||
mTransport->SetEventSink(this, thread);
|
||||
|
||||
rv = WriteRequest(mTransport);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -47,7 +47,7 @@ extern "C" {
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch2.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsProxyRelease.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIStringBundle.h"
|
||||
@ -282,31 +282,20 @@ ProxiedAuthCallback(gconstpointer in,
|
||||
nsMemory::Free(pass);
|
||||
}
|
||||
|
||||
struct nsGnomeVFSAuthParams
|
||||
struct nsGnomeVFSAuthCallbackEvent : public nsRunnable
|
||||
{
|
||||
gconstpointer in;
|
||||
gsize in_size;
|
||||
gpointer out;
|
||||
gsize out_size;
|
||||
gpointer callback_data;
|
||||
|
||||
NS_IMETHOD Run() {
|
||||
ProxiedAuthCallback(in, in_size, out, out_size, callback_data);
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(void *)
|
||||
AuthCallbackEventHandler(PLEvent *ev)
|
||||
{
|
||||
nsGnomeVFSAuthParams *params = (nsGnomeVFSAuthParams *) ev->owner;
|
||||
ProxiedAuthCallback(params->in, params->in_size,
|
||||
params->out, params->out_size,
|
||||
params->callback_data);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
AuthCallbackEventDestructor(PLEvent *ev)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
static void
|
||||
AuthCallback(gconstpointer in,
|
||||
gsize in_size,
|
||||
@ -314,30 +303,20 @@ AuthCallback(gconstpointer in,
|
||||
gsize out_size,
|
||||
gpointer callback_data)
|
||||
{
|
||||
// Need to proxy this callback over to the main thread. This code is greatly
|
||||
// simplified by the fact that we are making a synchronous callback. E.g., we
|
||||
// don't need to allocate the PLEvent on the heap.
|
||||
// Need to proxy this callback over to the main thread. Synchronous dispatch
|
||||
// is required in order to provide data to the GnomeVFS callback.
|
||||
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
NS_GetMainEventQ(getter_AddRefs(eventQ));
|
||||
if (!eventQ)
|
||||
return;
|
||||
nsRefPtr<nsGnomeVFSAuthCallbackEvent> ev = new nsGnomeVFSAuthCallbackEvent();
|
||||
if (!ev)
|
||||
return; // OOM
|
||||
|
||||
nsGnomeVFSAuthParams params;
|
||||
params.in = in;
|
||||
params.in_size = in_size;
|
||||
params.out = out;
|
||||
params.out_size = out_size;
|
||||
params.callback_data = callback_data;
|
||||
ev->in = in;
|
||||
ev->in_size = in_size;
|
||||
ev->out = out;
|
||||
ev->out_size = out_size;
|
||||
ev->callback_data = callback_data;
|
||||
|
||||
PLEvent ev;
|
||||
PL_InitEvent(&ev, ¶ms,
|
||||
AuthCallbackEventHandler,
|
||||
AuthCallbackEventDestructor);
|
||||
|
||||
void *result;
|
||||
if (NS_FAILED(eventQ->PostSynchronousEvent(&ev, &result)))
|
||||
PL_DestroyEvent(&ev);
|
||||
NS_DispatchToMainThread(ev, NS_DISPATCH_SYNC);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -618,32 +597,25 @@ nsGnomeVFSInputStream::DoRead(char *aBuf, PRUint32 aCount, PRUint32 *aCountRead)
|
||||
}
|
||||
|
||||
// This class is used to implement SetContentTypeOfChannel.
|
||||
class nsGnomeVFSSetContentTypeEvent : public PLEvent
|
||||
class nsGnomeVFSSetContentTypeEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsGnomeVFSSetContentTypeEvent(nsIChannel *channel, const char *contentType)
|
||||
: mContentType(contentType)
|
||||
: mChannel(channel), mContentType(contentType)
|
||||
{
|
||||
// stash channel reference in owner field. no AddRef here! see note
|
||||
// stash channel reference in mChannel. no AddRef here! see note
|
||||
// in SetContentTypeOfchannel.
|
||||
PL_InitEvent(this, channel, EventHandler, EventDestructor);
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void *) EventHandler(PLEvent *ev)
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
nsGnomeVFSSetContentTypeEvent *self = (nsGnomeVFSSetContentTypeEvent *) ev;
|
||||
((nsIChannel *) self->owner)->SetContentType(self->mContentType);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void) EventDestructor(PLEvent *ev)
|
||||
{
|
||||
nsGnomeVFSSetContentTypeEvent *self = (nsGnomeVFSSetContentTypeEvent *) ev;
|
||||
delete self;
|
||||
mChannel->SetContentType(mContentType);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsCString mContentType;
|
||||
nsIChannel *mChannel;
|
||||
nsCString mContentType;
|
||||
};
|
||||
|
||||
nsresult
|
||||
@ -656,12 +628,7 @@ nsGnomeVFSInputStream::SetContentTypeOfChannel(const char *contentType)
|
||||
// thread's event queue to protect us against memory corruption.
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
rv = NS_GetMainEventQ(getter_AddRefs(eventQ));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsGnomeVFSSetContentTypeEvent *ev =
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
new nsGnomeVFSSetContentTypeEvent(mChannel, contentType);
|
||||
if (!ev)
|
||||
{
|
||||
@ -669,9 +636,7 @@ nsGnomeVFSInputStream::SetContentTypeOfChannel(const char *contentType)
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = eventQ->PostEvent(ev);
|
||||
if (NS_FAILED(rv))
|
||||
PL_DestroyEvent(ev);
|
||||
rv = NS_DispatchToMainThread(ev);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -698,14 +663,13 @@ nsGnomeVFSInputStream::Close()
|
||||
|
||||
if (mChannel)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
rv = NS_GetMainEventQ(getter_AddRefs(eventQ));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = NS_ProxyRelease(eventQ, mChannel);
|
||||
nsCOMPtr<nsIThread> thread = do_GetMainThread();
|
||||
if (thread)
|
||||
rv = NS_ProxyRelease(thread, mChannel);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "leaking channel reference");
|
||||
NS_ASSERTION(thread && NS_SUCCEEDED(rv), "leaking channel reference");
|
||||
mChannel = nsnull;
|
||||
}
|
||||
|
||||
|
@ -130,10 +130,14 @@ function dcc_addhost(host, auth)
|
||||
};
|
||||
|
||||
try {
|
||||
const EQS = getService("@mozilla.org/event-queue-service;1",
|
||||
"nsIEventQueueService");
|
||||
var th = EQS.getSpecialEventQueue(EQS.CURRENT_THREAD_EVENT_QUEUE);
|
||||
|
||||
var th;
|
||||
if (jsenv.HAS_THREAD_MANAGER) {
|
||||
th = getService("@mozilla.org/thread-manager;1").currentThread;
|
||||
} else {
|
||||
const EQS = getService("@mozilla.org/event-queue-service;1",
|
||||
"nsIEventQueueService");
|
||||
th = EQS.getSpecialEventQueue(EQS.CURRENT_THREAD_EVENT_QUEUE);
|
||||
}
|
||||
var dnsRecord = this._dnsSvc.asyncResolve(host, false, listener, th);
|
||||
} catch (ex) {
|
||||
dd("Error resolving host to IP: " + ex);
|
||||
|
@ -120,6 +120,7 @@ jsenv.HAS_DOCUMENT = (typeof document == "object");
|
||||
jsenv.HAS_NSPR_EVENTQ = jsenv.HAS_DOCUMENT;
|
||||
jsenv.HAS_STREAM_PROVIDER = ("nsIStreamProvider" in Components.interfaces);
|
||||
jsenv.HAS_SERVER_SOCKETS = ("nsIServerSocket" in Components.interfaces);
|
||||
jsenv.HAS_THREAD_MANAGER = ("nsIThreadManager" in Components.interfaces);
|
||||
|
||||
function dumpObject (o, pfx, sep)
|
||||
{
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsAppFileLocProviderProxy.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
||||
@ -137,13 +136,6 @@ InitXPCOM_Impl(JNIEnv* env, jobject aMozBinDirectory,
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// init Event Queue
|
||||
nsCOMPtr<nsIEventQueueService> eventQService =
|
||||
do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = eventQService->CreateThreadEventQueue();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// create Java proxy for service manager returned by NS_InitXPCOM2
|
||||
return GetNewOrUsedJavaObject(env, servMan, NS_GET_IID(nsIServiceManager),
|
||||
aResult);
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include "jni.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsProxyRelease.h"
|
||||
|
||||
|
||||
@ -742,11 +742,10 @@ JavaXPCOMInstance::JavaXPCOMInstance(nsISupports* aInstance,
|
||||
JavaXPCOMInstance::~JavaXPCOMInstance()
|
||||
{
|
||||
// Need to release these objects on the main thread.
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
nsresult rv = NS_GetMainEventQ(getter_AddRefs(eventQ));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = NS_ProxyRelease(eventQ, mInstance);
|
||||
rv += NS_ProxyRelease(eventQ, mIInfo);
|
||||
nsCOMPtr<nsIThread> thread = do_GetMainThread();
|
||||
if (thread) {
|
||||
rv = NS_ProxyRelease(thread, mInstance);
|
||||
rv |= NS_ProxyRelease(thread, mIInfo);
|
||||
}
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to release using NS_ProxyRelease");
|
||||
}
|
||||
|
@ -41,18 +41,14 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsDependentString.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
|
||||
|
||||
|
||||
//**********************************************************************
|
||||
@ -202,20 +198,7 @@ FlushEventQueue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv
|
||||
nsJSSh* shell;
|
||||
if (!GetJSShGlobal(cx, obj, &shell)) return JS_FALSE;
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID);
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(eventQueue));
|
||||
PRBool avail;
|
||||
while(NS_SUCCEEDED(eventQueue->EventAvailable(avail)) && avail) {
|
||||
#ifdef DEBUG
|
||||
printf(".");
|
||||
#endif
|
||||
PLEvent *ev;
|
||||
eventQueue->GetEvent(&ev);
|
||||
eventQueue->HandleEvent(ev);
|
||||
}
|
||||
NS_ProcessPendingEvents(nsnull);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
@ -226,28 +209,15 @@ Suspend(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
nsJSSh* shell;
|
||||
if (!GetJSShGlobal(cx, obj, &shell)) return JS_FALSE;
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID);
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(eventQueue));
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
|
||||
PR_AtomicIncrement(&shell->mSuspendCount);
|
||||
|
||||
PLEvent *ev;
|
||||
while(shell->mSuspendCount) {
|
||||
while (shell->mSuspendCount) {
|
||||
#ifdef DEBUG
|
||||
printf("|");
|
||||
#endif
|
||||
|
||||
// eventQueue->ProcessPendingEvents();
|
||||
// XXX We can't use ProcessPendingEvents() here, because the JSSh
|
||||
// itself gets called from an AppShell's call to
|
||||
// ProcessPendingEvents() (via a proxy-event) and
|
||||
// ProcessPendingEvents() guards against recursive entry. We have
|
||||
// to pump events manually:
|
||||
|
||||
eventQueue->WaitForEvent(&ev);
|
||||
eventQueue->HandleEvent(ev);
|
||||
NS_ProcessNextEvent(thread);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
@ -488,23 +458,12 @@ NS_INTERFACE_MAP_END
|
||||
NS_IMETHODIMP nsJSSh::Run()
|
||||
{
|
||||
nsCOMPtr<nsIJSSh> proxied_shell;
|
||||
nsCOMPtr<nsIEventQueueService> eventQService =
|
||||
do_GetService(kEventQueueServiceCID);
|
||||
nsCOMPtr<nsIEventQueue> currentEventQ;
|
||||
eventQService->GetSpecialEventQueue(nsIEventQueueService::CURRENT_THREAD_EVENT_QUEUE,
|
||||
getter_AddRefs(currentEventQ));
|
||||
nsCOMPtr<nsIEventQueue> mainEventQ;
|
||||
eventQService->GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
|
||||
getter_AddRefs(mainEventQ));
|
||||
if (!SameCOMIdentity(mainEventQ, currentEventQ)) {
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyObjMgr =
|
||||
do_GetService(kProxyObjectManagerCID);
|
||||
NS_ASSERTION(proxyObjMgr, "no proxy object manager!");
|
||||
proxyObjMgr->GetProxyForObject(NS_UI_THREAD_EVENTQ,
|
||||
NS_GET_IID(nsIJSSh),
|
||||
(nsIJSSh*)this,
|
||||
PROXY_SYNC,
|
||||
getter_AddRefs(proxied_shell));
|
||||
if (!NS_IsMainThread()) {
|
||||
NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsIJSSh),
|
||||
(nsIJSSh*)this,
|
||||
NS_PROXY_SYNC,
|
||||
getter_AddRefs(proxied_shell));
|
||||
}
|
||||
else {
|
||||
#ifdef DEBUG
|
||||
@ -554,6 +513,19 @@ NS_IMETHODIMP nsJSSh::Run()
|
||||
}
|
||||
|
||||
proxied_shell->Cleanup();
|
||||
|
||||
if (!NS_IsMainThread()) {
|
||||
// Shutdown the current thread, which must be done from the main thread.
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
nsCOMPtr<nsIThread> proxied_thread;
|
||||
NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsIThread),
|
||||
thread.get(),
|
||||
NS_PROXY_ASYNC,
|
||||
getter_AddRefs(proxied_thread));
|
||||
if (proxied_thread)
|
||||
proxied_thread->Shutdown();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -42,11 +42,10 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsJSSh.h"
|
||||
|
||||
static NS_DEFINE_CID(kServerSocketCID, NS_SERVERSOCKET_CID);
|
||||
static NS_DEFINE_CID(kThreadCID, NS_THREAD_CID);
|
||||
|
||||
//**********************************************************************
|
||||
// ConnectionListener helper class
|
||||
@ -110,8 +109,9 @@ NS_IMETHODIMP ConnectionListener::OnSocketAccepted(nsIServerSocket *aServ, nsISo
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIRunnable> shell = CreateJSSh(input, output, mStartupURI);
|
||||
nsCOMPtr<nsIThread> thread = do_CreateInstance(kThreadCID);
|
||||
thread->Init(shell, 0, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD , PR_UNJOINABLE_THREAD);
|
||||
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
NS_NewThread(getter_AddRefs(thread), shell);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -210,8 +210,8 @@ nsJSShServer::RunShell(nsIInputStream *input, nsIOutputStream *output,
|
||||
{
|
||||
nsCOMPtr<nsIRunnable> shell = CreateJSSh(input, output, nsCString(startupURI));
|
||||
if (!blocking) {
|
||||
nsCOMPtr<nsIThread> thread = do_CreateInstance(kThreadCID);
|
||||
thread->Init(shell, 0, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD , PR_UNJOINABLE_THREAD);
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
NS_NewThread(getter_AddRefs(thread), shell);
|
||||
}
|
||||
else
|
||||
shell->Run();
|
||||
|
@ -44,11 +44,11 @@
|
||||
#include "nsIURI.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIFileStreams.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "prmem.h"
|
||||
#include "nsIProfile.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsLiteralString.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
@ -353,19 +353,11 @@ nsresult nsAutoConfig::downloadAutoConfig()
|
||||
|
||||
firstTime = PR_FALSE;
|
||||
|
||||
// Getting an event queue. If we start an AsyncOpen, the thread
|
||||
// Getting the current thread. If we start an AsyncOpen, the thread
|
||||
// needs to wait before the reading of autoconfig is done
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> service =
|
||||
do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIEventQueue> currentThreadQ;
|
||||
rv = service->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(currentThreadQ));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
NS_ENSURE_STATE(thread);
|
||||
|
||||
/* process events until we're finished. AutoConfig.jsc reading needs
|
||||
to be finished before the browser starts loading up
|
||||
@ -375,18 +367,8 @@ nsresult nsAutoConfig::downloadAutoConfig()
|
||||
that mLoaded will be set to true in any case (success/failure)
|
||||
*/
|
||||
|
||||
while (!mLoaded) {
|
||||
|
||||
PRBool isEventPending;
|
||||
rv = currentThreadQ->PendingEvents(&isEventPending);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (isEventPending) {
|
||||
rv = currentThreadQ->ProcessPendingEvents();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
while (!mLoaded)
|
||||
NS_ENSURE_STATE(NS_ProcessNextEvent(thread));
|
||||
|
||||
PRInt32 minutes = 0;
|
||||
rv = mPrefBranch->GetIntPref("autoadmin.refresh_interval",
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsILDAPErrors.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsILDAPMessage.h"
|
||||
|
||||
@ -144,10 +144,10 @@ nsLDAPSyncQuery::OnLDAPInit(nsILDAPConnection *aConn, nsresult aStatus)
|
||||
|
||||
// get a proxy object so the callback happens on the main thread
|
||||
//
|
||||
rv = NS_GetProxyForObject(NS_CURRENT_EVENTQ,
|
||||
rv = NS_GetProxyForObject(NS_PROXY_TO_CURRENT_THREAD,
|
||||
NS_GET_IID(nsILDAPMessageListener),
|
||||
NS_STATIC_CAST(nsILDAPMessageListener *, this),
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
NS_PROXY_ASYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(selfProxy));
|
||||
if (NS_FAILED(rv)) {
|
||||
FinishLDAPQuery();
|
||||
@ -283,10 +283,10 @@ nsLDAPSyncQuery::StartLDAPSearch()
|
||||
|
||||
// get a proxy object so the callback happens on the main thread
|
||||
//
|
||||
rv = NS_GetProxyForObject(NS_CURRENT_EVENTQ,
|
||||
rv = NS_GetProxyForObject(NS_PROXY_TO_CURRENT_THREAD,
|
||||
NS_GET_IID(nsILDAPMessageListener),
|
||||
NS_STATIC_CAST(nsILDAPMessageListener *, this),
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
NS_PROXY_ASYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(selfProxy));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("nsLDAPSyncQuery::StartLDAPSearch(): couldn't "
|
||||
@ -407,10 +407,10 @@ nsresult nsLDAPSyncQuery::InitConnection()
|
||||
|
||||
// get a proxy object so the callback happens on the main thread
|
||||
//
|
||||
rv = NS_GetProxyForObject(NS_CURRENT_EVENTQ,
|
||||
rv = NS_GetProxyForObject(NS_PROXY_TO_CURRENT_THREAD,
|
||||
NS_GET_IID(nsILDAPMessageListener),
|
||||
NS_STATIC_CAST(nsILDAPMessageListener *, this),
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
NS_PROXY_ASYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(selfProxy));
|
||||
if (NS_FAILED(rv)) {
|
||||
FinishLDAPQuery();
|
||||
@ -461,22 +461,7 @@ NS_IMETHODIMP nsLDAPSyncQuery::GetQueryResults(nsILDAPURL *aServerURL,
|
||||
mServerURL = aServerURL;
|
||||
mProtocolVersion = aProtocolVersion;
|
||||
|
||||
nsCOMPtr<nsIEventQueue> currentThreadQ;
|
||||
nsCOMPtr<nsIEventQueueService> service;
|
||||
|
||||
// Get the eventQueue Service
|
||||
//
|
||||
service = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Get the eventQ for the Current Thread
|
||||
//
|
||||
rv = service->PushThreadEventQueue(getter_AddRefs(currentThreadQ));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIThread> currentThread = do_GetCurrentThread();
|
||||
|
||||
// Start an LDAP query.
|
||||
// InitConnection will bind to the ldap server and post a OnLDAPMessage
|
||||
@ -484,10 +469,8 @@ NS_IMETHODIMP nsLDAPSyncQuery::GetQueryResults(nsILDAPURL *aServerURL,
|
||||
// be carried out by chain of events
|
||||
//
|
||||
rv = InitConnection();
|
||||
if (NS_FAILED(rv)) {
|
||||
service->PopThreadEventQueue(currentThreadQ);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
// We want this LDAP query to be synchronous while the XPCOM LDAP is
|
||||
// async in nature. So this eventQueue handling will wait for the
|
||||
@ -499,26 +482,8 @@ NS_IMETHODIMP nsLDAPSyncQuery::GetQueryResults(nsILDAPURL *aServerURL,
|
||||
// Run the event loop,
|
||||
// mFinished is a control variable
|
||||
//
|
||||
while (!mFinished) {
|
||||
|
||||
PRBool isEventPending;
|
||||
rv = currentThreadQ->PendingEvents(&isEventPending);
|
||||
if (NS_FAILED(rv)) {
|
||||
service->PopThreadEventQueue(currentThreadQ);
|
||||
return rv;
|
||||
}
|
||||
if (isEventPending) {
|
||||
rv = currentThreadQ->ProcessPendingEvents();
|
||||
if (NS_FAILED(rv)) {
|
||||
service->PopThreadEventQueue(currentThreadQ);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
rv = service->PopThreadEventQueue(currentThreadQ);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
while (!mFinished)
|
||||
NS_ENSURE_STATE(NS_ProcessNextEvent(currentThread));
|
||||
|
||||
// Return results
|
||||
//
|
||||
|
@ -180,15 +180,14 @@ OperationListener.prototype =
|
||||
}
|
||||
}
|
||||
|
||||
const evQSvc = getService("@mozilla.org/event-queue-service;1",
|
||||
"nsIEventQueueService");
|
||||
const evQ = evQSvc.getSpecialEventQueue(CI.nsIEventQueueService.CURRENT_THREAD_EVENT_QUEUE);
|
||||
const thrd =
|
||||
C.classes["@mozilla.org/thread-manager;1"].getService().currentThread;
|
||||
|
||||
function runEventPump()
|
||||
{
|
||||
pumpRunning = true;
|
||||
while (pumpRunning) {
|
||||
evQ.processPendingEvents();
|
||||
thrd.processNextEvent();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,14 +45,12 @@
|
||||
#include "nsIDNSRecord.h"
|
||||
#include "nsICancelable.h"
|
||||
#include "nsIRequest.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
static const char kSecurityProperties[] =
|
||||
"chrome://global/locale/webservices/security.properties";
|
||||
static NS_DEFINE_CID(kDNSServiceCID, NS_DNSSERVICE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
class nsDNSListener : public nsIDNSListener
|
||||
{
|
||||
@ -228,7 +226,7 @@ nsWSAUtils::GetOfficialHostName(nsIURI* aServiceURI,
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDNSService> dns(do_GetService(kDNSServiceCID, &rv));
|
||||
nsCOMPtr<nsIDNSService> dns(do_GetService(NS_DNSSERVICE_CONTRACTID, &rv));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
@ -239,36 +237,21 @@ nsWSAUtils::GetOfficialHostName(nsIURI* aServiceURI,
|
||||
nsRefPtr<nsDNSListener> listener = new nsDNSListener();
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> eventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
rv = eventQService->PushThreadEventQueue(getter_AddRefs(eventQ));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
NS_ENSURE_STATE(thread);
|
||||
|
||||
nsCOMPtr<nsICancelable> dummy;
|
||||
rv = dns->AsyncResolve(host, nsIDNSService::RESOLVE_CANONICAL_NAME,
|
||||
listener, eventQ, getter_AddRefs(dummy));
|
||||
listener, thread, getter_AddRefs(dummy));
|
||||
|
||||
PLEvent *ev;
|
||||
while (NS_SUCCEEDED(rv) && !listener->mLookupFinished) {
|
||||
rv = eventQ->WaitForEvent(&ev);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "WaitForEvent failed");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = eventQ->HandleEvent(ev);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "HandleEvent failed");
|
||||
while (!listener->mLookupFinished) {
|
||||
if (!NS_ProcessNextEvent(thread)) {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
aResult.Assign(listener->mOfficialHostName);
|
||||
|
||||
eventQService->PopThreadEventQueue(eventQ);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -295,4 +278,3 @@ nsDNSListener::OnLookupComplete(nsICancelable* aRequest,
|
||||
mLookupFinished = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,6 @@
|
||||
#define nsWSAUtils_h__
|
||||
|
||||
#include "nsIDNSListener.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
|
@ -74,9 +74,6 @@
|
||||
#include "nsIStringStream.h"
|
||||
#endif
|
||||
|
||||
// eventQ
|
||||
#include "nsIEventQueueService.h"
|
||||
|
||||
#include "prenv.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "nsIURL.h"
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "ipcm.h"
|
||||
|
||||
#include "nsIFile.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsCOMPtr.h"
|
||||
@ -81,8 +81,8 @@ public:
|
||||
// this may be null
|
||||
nsCOMPtr<ipcIMessageObserver> observer;
|
||||
|
||||
// the message observer is called via this event queue
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
// the message observer is called on this thread
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
|
||||
// incoming messages are added to this list
|
||||
ipcMessageQ pendingQ;
|
||||
@ -130,9 +130,9 @@ ipcTargetData::SetObserver(ipcIMessageObserver *aObserver, PRBool aOnCurrentThre
|
||||
observer = aObserver;
|
||||
|
||||
if (aOnCurrentThread)
|
||||
NS_GetCurrentEventQ(getter_AddRefs(eventQ));
|
||||
NS_GetCurrentThread(getter_AddRefs(thread));
|
||||
else
|
||||
eventQ = nsnull;
|
||||
thread = nsnull;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -400,65 +400,27 @@ WaitTarget(const nsID &aTarget,
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
PostEvent(nsIEventTarget *eventTarget, PLEvent *ev)
|
||||
{
|
||||
if (!ev)
|
||||
return;
|
||||
|
||||
nsresult rv = eventTarget->PostEvent(ev);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
NS_WARNING("PostEvent failed");
|
||||
PL_DestroyEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
PostEventToMainThread(PLEvent *ev)
|
||||
{
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
NS_GetMainEventQ(getter_AddRefs(eventQ));
|
||||
if (!eventQ)
|
||||
{
|
||||
NS_WARNING("unable to get reference to main event queue");
|
||||
PL_DestroyEvent(ev);
|
||||
return;
|
||||
}
|
||||
PostEvent(eventQ, ev);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class ipcEvent_ClientState : public PLEvent
|
||||
class ipcEvent_ClientState : public nsRunnable
|
||||
{
|
||||
public:
|
||||
ipcEvent_ClientState(PRUint32 aClientID, PRUint32 aClientState)
|
||||
: mClientID(aClientID)
|
||||
, mClientState(aClientState)
|
||||
{
|
||||
PL_InitEvent(this, nsnull, HandleEvent, DestroyEvent);
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void *) HandleEvent(PLEvent *ev)
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
// maybe we've been shutdown!
|
||||
if (!gClientState)
|
||||
return nsnull;
|
||||
|
||||
ipcEvent_ClientState *self = (ipcEvent_ClientState *) ev;
|
||||
|
||||
for (PRInt32 i=0; i<gClientState->clientObservers.Count(); ++i)
|
||||
gClientState->clientObservers[i]->OnClientStateChange(self->mClientID,
|
||||
self->mClientState);
|
||||
gClientState->clientObservers[i]->OnClientStateChange(mClientID,
|
||||
mClientState);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void) DestroyEvent(PLEvent *ev)
|
||||
{
|
||||
delete (ipcEvent_ClientState *) ev;
|
||||
}
|
||||
|
||||
private:
|
||||
PRUint32 mClientID;
|
||||
PRUint32 mClientState;
|
||||
@ -466,48 +428,55 @@ private:
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class ipcEvent_ProcessPendingQ : public PLEvent
|
||||
class ipcEvent_ProcessPendingQ : public nsRunnable
|
||||
{
|
||||
public:
|
||||
ipcEvent_ProcessPendingQ(const nsID &aTarget)
|
||||
: mTarget(aTarget)
|
||||
{
|
||||
PL_InitEvent(this, nsnull, HandleEvent, DestroyEvent);
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void *) HandleEvent(PLEvent *ev)
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
ProcessPendingQ(((ipcEvent_ProcessPendingQ *) ev)->mTarget);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void) DestroyEvent(PLEvent *ev)
|
||||
{
|
||||
delete (ipcEvent_ProcessPendingQ *) ev;
|
||||
ProcessPendingQ(mTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
const nsID mTarget;
|
||||
};
|
||||
|
||||
static void
|
||||
RunEvent(void *arg)
|
||||
{
|
||||
nsIRunnable *ev = NS_STATIC_CAST(nsIRunnable *, arg);
|
||||
ev->Run();
|
||||
NS_RELEASE(ev);
|
||||
}
|
||||
|
||||
static void
|
||||
CallProcessPendingQ(const nsID &target, ipcTargetData *td)
|
||||
{
|
||||
// we assume that we are inside td's monitor
|
||||
|
||||
PLEvent *ev = new ipcEvent_ProcessPendingQ(target);
|
||||
nsIRunnable *ev = new ipcEvent_ProcessPendingQ(target);
|
||||
if (!ev)
|
||||
return;
|
||||
NS_ADDREF(ev);
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if (td->eventQ)
|
||||
rv = td->eventQ->PostEvent(ev);
|
||||
else
|
||||
rv = IPC_DoCallback((ipcCallbackFunc) PL_HandleEvent, ev);
|
||||
if (td->thread)
|
||||
{
|
||||
rv = td->thread->Dispatch(ev, NS_DISPATCH_NORMAL);
|
||||
NS_RELEASE(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = IPC_DoCallback(RunEvent, ev);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
PL_DestroyEvent(ev);
|
||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to process pending queue");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -1087,8 +1056,10 @@ IPC_OnMessageAvailable(ipcMessage *msg)
|
||||
case IPCM_MSG_PSH_CLIENT_STATE:
|
||||
{
|
||||
ipcMessageCast<ipcmMessageClientState> status(msg);
|
||||
PostEventToMainThread(new ipcEvent_ClientState(status->ClientID(),
|
||||
status->ClientState()));
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
new ipcEvent_ClientState(status->ClientID(),
|
||||
status->ClientState());
|
||||
NS_DispatchToMainThread(ev);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ const ipcIService = Components.interfaces.ipcIService;
|
||||
const ipcIDConnectService = Components.interfaces.ipcIDConnectService;
|
||||
const nsIFile = Components.interfaces.nsIFile;
|
||||
const nsILocalFile = Components.interfaces.nsILocalFile;
|
||||
const nsIEventQueueService = Components.interfaces.nsIEventQueueService;
|
||||
|
||||
// XXX use directory service for this
|
||||
const TEST_PATH = "/tmp";
|
||||
@ -92,14 +91,6 @@ function doTest()
|
||||
dump("localObj.equals(file) = " + localObj.equals(file) + "\n");
|
||||
}
|
||||
|
||||
function setupEventQ()
|
||||
{
|
||||
var eqs = Components.classes["@mozilla.org/event-queue-service;1"]
|
||||
.getService(nsIEventQueueService);
|
||||
eqs.createMonitoredThreadEventQueue();
|
||||
}
|
||||
|
||||
setupEventQ();
|
||||
findServer();
|
||||
dump("\n---------------------------------------------------\n");
|
||||
doTest();
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include "ipcIDConnectService.h"
|
||||
#include "ipcCID.h"
|
||||
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
|
||||
@ -63,8 +63,6 @@
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static nsIEventQueue* gEventQ = nsnull;
|
||||
static PRBool gKeepRunning = PR_TRUE;
|
||||
|
||||
static ipcIService *gIpcServ = nsnull;
|
||||
@ -219,17 +217,6 @@ int main(int argc, char **argv)
|
||||
if (registrar)
|
||||
registrar->AutoRegister(nsnull);
|
||||
|
||||
// Create the Event Queue for this thread...
|
||||
nsCOMPtr<nsIEventQueueService> eqs =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
RETURN_IF_FAILED(rv, "do_GetService(EventQueueService)");
|
||||
|
||||
rv = eqs->CreateMonitoredThreadEventQueue();
|
||||
RETURN_IF_FAILED(rv, "CreateMonitoredThreadEventQueue");
|
||||
|
||||
rv = eqs->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);
|
||||
RETURN_IF_FAILED(rv, "GetThreadEventQueue");
|
||||
|
||||
nsCOMPtr<ipcIService> ipcServ(do_GetService(IPC_SERVICE_CONTRACTID, &rv));
|
||||
RETURN_IF_FAILED(rv, "do_GetService(ipcServ)");
|
||||
NS_ADDREF(gIpcServ = ipcServ);
|
||||
@ -244,20 +231,16 @@ int main(int argc, char **argv)
|
||||
gIpcServ->AddName("DConnectServer");
|
||||
}
|
||||
|
||||
PLEvent *ev;
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
while (gKeepRunning)
|
||||
{
|
||||
gEventQ->WaitForEvent(&ev);
|
||||
gEventQ->HandleEvent(ev);
|
||||
}
|
||||
NS_ProcessNextEvent(thread);
|
||||
|
||||
NS_RELEASE(gIpcServ);
|
||||
|
||||
printf("*** processing remaining events\n");
|
||||
|
||||
// process any remaining events
|
||||
while (NS_SUCCEEDED(gEventQ->GetEvent(&ev)) && ev)
|
||||
gEventQ->HandleEvent(ev);
|
||||
NS_ProcessPendingEvents(thread);
|
||||
|
||||
printf("*** done\n");
|
||||
} // this scopes the nsCOMPtrs
|
||||
|
@ -41,9 +41,7 @@
|
||||
* can connect and control this process.
|
||||
*/
|
||||
|
||||
const ipcIService = Components.interfaces.ipcIService;
|
||||
const nsIEventQueueService = Components.interfaces.nsIEventQueueService;
|
||||
const nsIEventQueue = Components.interfaces.nsIEventQueue;
|
||||
const ipcIService = Components.interfaces.ipcIService;
|
||||
|
||||
function registerServer()
|
||||
{
|
||||
@ -53,13 +51,13 @@ function registerServer()
|
||||
|
||||
function runEventQ()
|
||||
{
|
||||
var eqs = Components.classes["@mozilla.org/event-queue-service;1"]
|
||||
.getService(nsIEventQueueService);
|
||||
eqs.createMonitoredThreadEventQueue();
|
||||
var queue = eqs.getSpecialEventQueue(eqs.CURRENT_THREAD_EVENT_QUEUE);
|
||||
var thread =
|
||||
Components.classes["@mozilla.org/thread-manager;1"].
|
||||
getService().currentThread;
|
||||
|
||||
// this never returns
|
||||
queue.eventLoop();
|
||||
while (true)
|
||||
thread.processNextEvent();
|
||||
}
|
||||
|
||||
registerServer();
|
||||
|
@ -48,6 +48,7 @@ MOZILLA_INTERNAL_API = 1
|
||||
REQUIRES = ipcd \
|
||||
nspr \
|
||||
xpcom \
|
||||
string \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include "ipcILockService.h"
|
||||
#include "ipcLockCID.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "prproces.h"
|
||||
@ -144,22 +144,6 @@ static const char *kLockNames[] = {
|
||||
|
||||
static nsresult DoTest()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> eqs =
|
||||
do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = eqs->CreateMonitoredThreadEventQueue();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIEventQueue> eq;
|
||||
rv = eqs->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(eq));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<ipcILockService> lockService =
|
||||
do_GetService(IPC_LOCKSERVICE_CONTRACTID);
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
// core & xpcom ns includes
|
||||
#include "nsDebug.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include "nsString.h"
|
||||
@ -80,8 +80,6 @@ PRUint32 dataLen = 10; // includes the null terminator for "test data
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static nsIEventQueue* gEventQ = nsnull;
|
||||
static PRBool gKeepRunning = PR_TRUE;
|
||||
//static PRInt32 gMsgCount = 0;
|
||||
static ipcIService *gIpcServ = nsnull;
|
||||
@ -195,16 +193,6 @@ int main(PRInt32 argc, char *argv[])
|
||||
if (registrar)
|
||||
registrar->AutoRegister(nsnull);
|
||||
|
||||
// Create the Event Queue for this thread...
|
||||
nsCOMPtr<nsIEventQueueService> eqs = do_GetService(kEventQueueServiceCID, &rv);
|
||||
RETURN_IF_FAILED(rv, "do_GetService(EventQueueService)");
|
||||
|
||||
rv = eqs->CreateMonitoredThreadEventQueue();
|
||||
RETURN_IF_FAILED(rv, "CreateMonitoredThreadEventQueue");
|
||||
|
||||
rv = eqs->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);
|
||||
RETURN_IF_FAILED(rv, "GetThreadEventQueue");
|
||||
|
||||
// Need to make sure the ipc system has been started
|
||||
printf("tmModuleTest: getting ipc service\n");
|
||||
nsCOMPtr<ipcIService> ipcServ(do_GetService("@mozilla.org/ipc/service;1", &rv));
|
||||
@ -229,6 +217,7 @@ int main(PRInt32 argc, char *argv[])
|
||||
gTransServ->Attach(nsDependentCString(queueName), observ, PR_TRUE);
|
||||
printf("tmModuleTest: observing queue [%s]\n", queueName);
|
||||
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
|
||||
// run specific patterns based on the mode
|
||||
int i = 0; // wasn't working inside the cases
|
||||
@ -242,7 +231,7 @@ int main(PRInt32 argc, char *argv[])
|
||||
}
|
||||
// listen for events
|
||||
while (gKeepRunning)
|
||||
gEventQ->ProcessPendingEvents();
|
||||
NS_ProcessNextEvent(thread);
|
||||
printf("tmModuleTest: end standard\n");
|
||||
break;
|
||||
case 'b':
|
||||
@ -253,7 +242,7 @@ int main(PRInt32 argc, char *argv[])
|
||||
}
|
||||
// listen for events
|
||||
while (gKeepRunning)
|
||||
gEventQ->ProcessPendingEvents();
|
||||
NS_ProcessNextEvent(thread);
|
||||
printf("tmModuleTest: end broadcast\n");
|
||||
break;
|
||||
case 'f':
|
||||
@ -270,7 +259,7 @@ int main(PRInt32 argc, char *argv[])
|
||||
}
|
||||
// listen for events
|
||||
while (gKeepRunning)
|
||||
gEventQ->ProcessPendingEvents();
|
||||
NS_ProcessNextEvent(thread);
|
||||
// detach
|
||||
gTransServ->Detach(nsDependentCString(queueName));
|
||||
printf("tmModuleTest: end flush\n");
|
||||
@ -289,7 +278,7 @@ int main(PRInt32 argc, char *argv[])
|
||||
printf("tmModuleTest: start listener\n");
|
||||
// listen for events
|
||||
while (gKeepRunning)
|
||||
gEventQ->ProcessPendingEvents();
|
||||
NS_ProcessNextEvent(thread);
|
||||
printf("tmModuleTest: end listener\n");
|
||||
break;
|
||||
default :
|
||||
@ -305,9 +294,8 @@ int main(PRInt32 argc, char *argv[])
|
||||
printf("tmModuleTest: processing remaining events\n");
|
||||
|
||||
// process any remaining events
|
||||
PLEvent *ev;
|
||||
while (NS_SUCCEEDED(gEventQ->GetEvent(&ev)) && ev)
|
||||
gEventQ->HandleEvent(ev);
|
||||
|
||||
NS_ProcessPendingEvents(thread);
|
||||
|
||||
printf("tmModuleTest: done\n");
|
||||
} // this scopes the nsCOMPtrs
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "ipcCID.h"
|
||||
#include "ipcLockCID.h"
|
||||
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
|
||||
@ -72,8 +72,6 @@ static const nsID kTestTargetID =
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static nsIEventQueue* gEventQ = nsnull;
|
||||
static PRBool gKeepRunning = PR_TRUE;
|
||||
static ipcIService *gIpcServ = nsnull;
|
||||
static ipcILockService *gIpcLockServ = nsnull;
|
||||
@ -201,17 +199,6 @@ int main(int argc, char **argv)
|
||||
if (registrar)
|
||||
registrar->AutoRegister(nsnull);
|
||||
|
||||
// Create the Event Queue for this thread...
|
||||
nsCOMPtr<nsIEventQueueService> eqs =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
RETURN_IF_FAILED(rv, "do_GetService(EventQueueService)");
|
||||
|
||||
rv = eqs->CreateMonitoredThreadEventQueue();
|
||||
RETURN_IF_FAILED(rv, "CreateMonitoredThreadEventQueue");
|
||||
|
||||
rv = eqs->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);
|
||||
RETURN_IF_FAILED(rv, "GetThreadEventQueue");
|
||||
|
||||
printf("*** getting ipc service\n");
|
||||
nsCOMPtr<ipcIService> ipcServ(do_GetService(IPC_SERVICE_CONTRACTID, &rv));
|
||||
RETURN_IF_FAILED(rv, "do_GetService(ipcServ)");
|
||||
@ -313,19 +300,17 @@ int main(int argc, char **argv)
|
||||
rv = gIpcLockServ->AcquireLock("foo", PR_TRUE);
|
||||
printf("*** sync AcquireLock returned [rv=%x]\n", rv);
|
||||
|
||||
PLEvent *ev;
|
||||
while (gKeepRunning) {
|
||||
gEventQ->WaitForEvent(&ev);
|
||||
gEventQ->HandleEvent(ev);
|
||||
}
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
|
||||
while (gKeepRunning)
|
||||
NS_ProcessNextEvent(thread);
|
||||
|
||||
NS_RELEASE(gIpcServ);
|
||||
|
||||
printf("*** processing remaining events\n");
|
||||
|
||||
// process any remaining events
|
||||
while (NS_SUCCEEDED(gEventQ->GetEvent(&ev)) && ev)
|
||||
gEventQ->HandleEvent(ev);
|
||||
NS_ProcessPendingEvents(thread);
|
||||
|
||||
printf("*** done\n");
|
||||
} // this scopes the nsCOMPtrs
|
||||
|
@ -50,7 +50,8 @@
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIJSRuntimeService.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIThreadInternal.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsMemory.h"
|
||||
#include "jsdebug.h"
|
||||
#include "nsReadableUtils.h"
|
||||
@ -118,8 +119,6 @@ jsds_GCCallbackProc (JSContext *cx, JSGCStatus status);
|
||||
******************************************************************************/
|
||||
|
||||
const char implementationString[] = "Mozilla JavaScript Debugger Service";
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
const char jsdServiceCtrID[] = "@mozilla.org/js/jsd/debugger-service;1";
|
||||
const char jsdARObserverCtrID[] = "@mozilla.org/js/jsd/app-start-observer;2";
|
||||
@ -2942,40 +2941,28 @@ jsdService::WrapValue(jsdIValue **_rval)
|
||||
NS_IMETHODIMP
|
||||
jsdService::EnterNestedEventLoop (jsdINestCallback *callback, PRUint32 *_rval)
|
||||
{
|
||||
nsCOMPtr<nsIAppShell> appShell(do_CreateInstance(kAppShellCID));
|
||||
NS_ENSURE_TRUE(appShell, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIEventQueueService>
|
||||
eventService(do_GetService(kEventQueueServiceCID));
|
||||
NS_ENSURE_TRUE(eventService, NS_ERROR_FAILURE);
|
||||
|
||||
appShell->Create(0, nsnull);
|
||||
appShell->Spinup();
|
||||
|
||||
// Nesting event queues is a thing of the past. Now, we just spin the
|
||||
// current event loop.
|
||||
|
||||
nsCOMPtr<nsIJSContextStack>
|
||||
stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
||||
nsresult rv = NS_OK;
|
||||
PRUint32 nestLevel = ++mNestedLoopLevel;
|
||||
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
if (stack && NS_SUCCEEDED(stack->Push(nsnull)) &&
|
||||
NS_SUCCEEDED(eventService->PushThreadEventQueue(getter_AddRefs(eventQ))))
|
||||
{
|
||||
if (NS_SUCCEEDED(rv) && callback) {
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
|
||||
if (stack && NS_SUCCEEDED(stack->Push(nsnull))) {
|
||||
if (callback) {
|
||||
Pause(nsnull);
|
||||
rv = callback->OnNest();
|
||||
UnPause(nsnull);
|
||||
}
|
||||
|
||||
while(NS_SUCCEEDED(rv) && mNestedLoopLevel >= nestLevel)
|
||||
{
|
||||
void* data;
|
||||
PRBool isRealEvent;
|
||||
//PRBool processEvent;
|
||||
|
||||
rv = appShell->GetNativeEvent(isRealEvent, data);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
appShell->DispatchNativeEvent(isRealEvent, data);
|
||||
}
|
||||
while (NS_SUCCEEDED(rv) && mNestedLoopLevel >= nestLevel) {
|
||||
if (!NS_ProcessNextEvent(thread))
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
JSContext* cx;
|
||||
stack->Pop(&cx);
|
||||
NS_ASSERTION(cx == nsnull, "JSContextStack mismatch");
|
||||
@ -2983,9 +2970,6 @@ jsdService::EnterNestedEventLoop (jsdINestCallback *callback, PRUint32 *_rval)
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
eventService->PopThreadEventQueue(eventQ);
|
||||
appShell->Spindown();
|
||||
|
||||
NS_ASSERTION (mNestedLoopLevel <= nestLevel,
|
||||
"nested event didn't unwind properly");
|
||||
if (mNestedLoopLevel == nestLevel)
|
||||
|
@ -49,7 +49,6 @@ NS_IMPL_THREADSAFE_ISUPPORTS2(nsXPConnect,nsIXPConnect,nsISupportsWeakReference)
|
||||
|
||||
nsXPConnect* nsXPConnect::gSelf = nsnull;
|
||||
JSBool nsXPConnect::gOnceAliveNowDead = JS_FALSE;
|
||||
PRThread* nsXPConnect::gMainThread = nsnull;
|
||||
|
||||
const char XPC_CONTEXT_STACK_CONTRACTID[] = "@mozilla.org/js/xpc/ContextStack;1";
|
||||
const char XPC_RUNTIME_CONTRACTID[] = "@mozilla.org/js/xpc/RuntimeService;1";
|
||||
@ -326,19 +325,6 @@ nsXPConnect::CreateRuntime()
|
||||
return nsnull != mRuntime;
|
||||
}
|
||||
|
||||
// static
|
||||
PRThread*
|
||||
nsXPConnect::FindMainThread()
|
||||
{
|
||||
nsCOMPtr<nsIThread> t;
|
||||
nsresult rv;
|
||||
rv = nsIThread::GetMainThread(getter_AddRefs(t));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv) && t, "bad");
|
||||
rv = t->GetPRThread(&gMainThread);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv) && gMainThread, "bad");
|
||||
return gMainThread;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef PRBool (*InfoTester)(nsIInterfaceInfoManager* manager, const void* data,
|
||||
|
@ -236,8 +236,7 @@ JSBool XPCJSRuntime::GCCallback(JSContext *cx, JSGCStatus status)
|
||||
{
|
||||
case JSGC_BEGIN:
|
||||
{
|
||||
if(self->GetMainThreadOnlyGC() &&
|
||||
PR_GetCurrentThread() != nsXPConnect::GetMainThread())
|
||||
if(self->GetMainThreadOnlyGC() && !NS_IsMainThread())
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
@ -93,9 +93,8 @@
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsIThread.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "prthread.h"
|
||||
#include "nsDeque.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
@ -455,9 +454,6 @@ public:
|
||||
|
||||
static JSBool IsISupportsDescendant(nsIInterfaceInfo* info);
|
||||
|
||||
static PRThread* GetMainThread()
|
||||
{return gMainThread ? gMainThread : FindMainThread();}
|
||||
|
||||
nsIXPCSecurityManager* GetDefaultSecurityManager() const
|
||||
{return mDefaultSecurityManager;}
|
||||
|
||||
@ -498,7 +494,6 @@ private:
|
||||
// Singleton instance
|
||||
static nsXPConnect* gSelf;
|
||||
static JSBool gOnceAliveNowDead;
|
||||
static PRThread* gMainThread;
|
||||
|
||||
XPCJSRuntime* mRuntime;
|
||||
nsCOMPtr<nsIInterfaceInfoSuperManager> mInterfaceInfoManager;
|
||||
@ -2099,8 +2094,7 @@ private:
|
||||
|
||||
#ifdef XPC_CHECK_WRAPPER_THREADSAFETY
|
||||
public:
|
||||
PRThread* mThread; // Don't want to overload _mOwningThread
|
||||
static PRThread* gMainThread;
|
||||
nsCOMPtr<nsIThread> mThread; // Don't want to overload _mOwningThread
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -53,10 +53,6 @@ static void DEBUG_CheckClassInfoClaims(XPCWrappedNative* wrapper);
|
||||
#define DEBUG_CheckClassInfoClaims(wrapper) ((void)0)
|
||||
#endif
|
||||
|
||||
#ifdef XPC_CHECK_WRAPPER_THREADSAFETY
|
||||
PRThread* XPCWrappedNative::gMainThread = nsnull;
|
||||
#endif
|
||||
|
||||
#ifdef XPC_TRACK_WRAPPER_STATS
|
||||
static int DEBUG_TotalWrappedNativeCount;
|
||||
static int DEBUG_TotalLiveWrappedNativeCount;
|
||||
@ -806,12 +802,9 @@ XPCWrappedNative::Init(XPCCallContext& ccx, JSObject* parent,
|
||||
}
|
||||
|
||||
#ifdef XPC_CHECK_WRAPPER_THREADSAFETY
|
||||
if(!gMainThread)
|
||||
gMainThread = nsXPConnect::GetMainThread();
|
||||
mThread = do_GetCurrentThread();
|
||||
|
||||
mThread = PR_GetCurrentThread();
|
||||
|
||||
if(HasProto() && GetProto()->ClassIsMainThreadOnly() && gMainThread != mThread)
|
||||
if(HasProto() && GetProto()->ClassIsMainThreadOnly() && !NS_IsMainThread())
|
||||
DEBUG_ReportWrapperThreadSafetyError(ccx,
|
||||
"MainThread only wrapper created on the wrong thread", this);
|
||||
#endif
|
||||
@ -3099,18 +3092,17 @@ void DEBUG_CheckWrapperThreadSafety(const XPCWrappedNative* wrapper)
|
||||
if(proto && proto->ClassIsThreadSafe())
|
||||
return;
|
||||
|
||||
PRThread* currentThread = PR_GetCurrentThread();
|
||||
|
||||
PRBool val;
|
||||
if(proto && proto->ClassIsMainThreadOnly())
|
||||
{
|
||||
if(currentThread != wrapper->gMainThread)
|
||||
if(!NS_IsMainThread())
|
||||
{
|
||||
XPCCallContext ccx(NATIVE_CALLER);
|
||||
DEBUG_ReportWrapperThreadSafetyError(ccx,
|
||||
"Main Thread Only wrapper accessed on another thread", wrapper);
|
||||
}
|
||||
}
|
||||
else if(currentThread != wrapper->mThread)
|
||||
else if(NS_SUCCEEDED(wrapper->mThread->IsOnCurrentThread(&val)) && !val)
|
||||
{
|
||||
XPCCallContext ccx(NATIVE_CALLER);
|
||||
DEBUG_ReportWrapperThreadSafetyError(ccx,
|
||||
|
@ -122,8 +122,6 @@
|
||||
#include "nsIObjectLoadingContent.h"
|
||||
#include "nsContentErrors.h"
|
||||
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIMenuFrame.h"
|
||||
|
||||
@ -1939,9 +1937,6 @@ nsCSSFrameConstructor::nsCSSFrameConstructor(nsIDocument *aDocument,
|
||||
// now what?
|
||||
}
|
||||
|
||||
// XXXbz this should be in Init() or something!
|
||||
mEventQueueService = do_GetService(kEventQueueServiceCID);
|
||||
|
||||
#ifdef DEBUG
|
||||
static PRBool gFirstTime = PR_TRUE;
|
||||
if (gFirstTime) {
|
||||
@ -10833,12 +10828,8 @@ nsCSSFrameConstructor::WillDestroyFrameTree()
|
||||
mQuoteList.Clear();
|
||||
mCounterManager.Clear();
|
||||
|
||||
// Cancel all pending reresolves
|
||||
mRestyleEventQueue = nsnull;
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
mEventQueueService->GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
|
||||
getter_AddRefs(eventQueue));
|
||||
eventQueue->RevokeEvents(this);
|
||||
// Cancel all pending re-resolves
|
||||
mRestyleEvent.Revoke();
|
||||
}
|
||||
|
||||
//STATIC
|
||||
@ -13482,7 +13473,7 @@ nsCSSFrameConstructor::PostRestyleEvent(nsIContent* aContent,
|
||||
// Nothing to do here
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
RestyleData existingData;
|
||||
existingData.mRestyleHint = nsReStyleHint(0);
|
||||
existingData.mChangeHint = NS_STYLE_HINT_NONE;
|
||||
@ -13494,64 +13485,40 @@ nsCSSFrameConstructor::PostRestyleEvent(nsIContent* aContent,
|
||||
|
||||
mPendingRestyles.Put(aContent, existingData);
|
||||
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
mEventQueueService->GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
|
||||
getter_AddRefs(eventQueue));
|
||||
|
||||
if (eventQueue != mRestyleEventQueue) {
|
||||
RestyleEvent* ev = new RestyleEvent(this);
|
||||
if (NS_FAILED(eventQueue->PostEvent(ev))) {
|
||||
PL_DestroyEvent(ev);
|
||||
if (!mRestyleEvent.IsPending()) {
|
||||
nsRefPtr<RestyleEvent> ev = new RestyleEvent(this);
|
||||
if (NS_FAILED(NS_DispatchToCurrentThread(ev))) {
|
||||
NS_WARNING("failed to dispatch restyle event");
|
||||
// XXXbz and what?
|
||||
} else {
|
||||
mRestyleEventQueue = eventQueue;
|
||||
mRestyleEvent = ev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nsCSSFrameConstructor::RestyleEvent::HandleEvent() {
|
||||
nsCSSFrameConstructor* constructor =
|
||||
NS_STATIC_CAST(nsCSSFrameConstructor*, owner);
|
||||
NS_IMETHODIMP nsCSSFrameConstructor::RestyleEvent::Run() {
|
||||
if (!mConstructor)
|
||||
return NS_OK; // event was revoked
|
||||
|
||||
nsIViewManager* viewManager =
|
||||
constructor->mPresShell->GetViewManager();
|
||||
mConstructor->mPresShell->GetViewManager();
|
||||
NS_ASSERTION(viewManager, "Must have view manager for update");
|
||||
|
||||
viewManager->BeginUpdateViewBatch();
|
||||
// Force flushing of any pending content notifications that might have queued
|
||||
// up while our event was pending. That will ensure that we don't construct
|
||||
// frames for content right now that's still waiting to be notified on,
|
||||
constructor->mPresShell->GetDocument()->
|
||||
mConstructor->mPresShell->GetDocument()->
|
||||
FlushPendingNotifications(Flush_ContentAndNotify);
|
||||
|
||||
// Make sure that any restyles that happen from now on will go into
|
||||
// a new event.
|
||||
constructor->mRestyleEventQueue = nsnull;
|
||||
mConstructor->mRestyleEvent.Forget();
|
||||
|
||||
constructor->ProcessPendingRestyles();
|
||||
mConstructor->ProcessPendingRestyles();
|
||||
viewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void*)
|
||||
HandleRestyleEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsCSSFrameConstructor::RestyleEvent* evt =
|
||||
NS_STATIC_CAST(nsCSSFrameConstructor::RestyleEvent*, aEvent);
|
||||
evt->HandleEvent();
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
DestroyRestyleEvent(PLEvent* aEvent)
|
||||
{
|
||||
delete NS_STATIC_CAST(nsCSSFrameConstructor::RestyleEvent*, aEvent);
|
||||
}
|
||||
|
||||
nsCSSFrameConstructor::RestyleEvent::RestyleEvent(nsCSSFrameConstructor* aConstructor)
|
||||
{
|
||||
NS_PRECONDITION(aConstructor, "Must have a constructor!");
|
||||
|
||||
PL_InitEvent(this, aConstructor,
|
||||
::HandleRestyleEvent, ::DestroyRestyleEvent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -50,9 +50,7 @@
|
||||
#include "nsCounterManager.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "plevent.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
class nsIDocument;
|
||||
struct nsFrameItems;
|
||||
@ -83,7 +81,7 @@ class nsCSSFrameConstructor
|
||||
{
|
||||
public:
|
||||
nsCSSFrameConstructor(nsIDocument *aDocument, nsIPresShell* aPresShell);
|
||||
~nsCSSFrameConstructor(void) {}
|
||||
~nsCSSFrameConstructor(void) { }
|
||||
|
||||
// Maintain global objects - gXBLService
|
||||
static nsIXBLService * GetXBLService();
|
||||
@ -1010,20 +1008,23 @@ public:
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
};
|
||||
|
||||
struct RestyleEvent;
|
||||
friend struct RestyleEvent;
|
||||
class RestyleEvent;
|
||||
friend class RestyleEvent;
|
||||
|
||||
struct RestyleEvent : public PLEvent {
|
||||
RestyleEvent(nsCSSFrameConstructor* aConstructor);
|
||||
~RestyleEvent() { }
|
||||
void HandleEvent();
|
||||
class RestyleEvent : public nsRunnable {
|
||||
public:
|
||||
NS_DECL_NSIRUNNABLE
|
||||
RestyleEvent(nsCSSFrameConstructor *aConstructor)
|
||||
: mConstructor(aConstructor) {
|
||||
NS_PRECONDITION(aConstructor, "Must have a constructor!");
|
||||
}
|
||||
void Revoke() { mConstructor = nsnull; }
|
||||
private:
|
||||
nsCSSFrameConstructor *mConstructor;
|
||||
};
|
||||
|
||||
friend class nsFrameConstructorState;
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIEventQueue> mRestyleEventQueue;
|
||||
|
||||
private:
|
||||
#ifdef ACCESSIBILITY
|
||||
// If the frame is visible, return the frame type
|
||||
@ -1053,9 +1054,9 @@ private:
|
||||
PRPackedBool mQuotesDirty;
|
||||
PRPackedBool mCountersDirty;
|
||||
|
||||
nsCOMPtr<nsILayoutHistoryState> mTempFrameTreeState;
|
||||
nsRevocableEventPtr<RestyleEvent> mRestyleEvent;
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> mEventQueueService;
|
||||
nsCOMPtr<nsILayoutHistoryState> mTempFrameTreeState;
|
||||
|
||||
nsDataHashtable<nsISupportsHashKey, RestyleData> mPendingRestyles;
|
||||
|
||||
|
@ -117,9 +117,6 @@
|
||||
|
||||
#include "nsIClipboardHelper.h"
|
||||
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIEventQueue.h"
|
||||
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIFocusController.h"
|
||||
|
||||
@ -155,8 +152,6 @@
|
||||
static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printsettings-service;1";
|
||||
|
||||
// Printing Events
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsPrintPreviewListener.h"
|
||||
|
||||
#include "nsIDOMHTMLFrameElement.h"
|
||||
|
@ -54,7 +54,6 @@
|
||||
#include "nsCSSFrameConstructor.h"
|
||||
#include "nsStyleContext.h"
|
||||
#include "nsStyleChangeList.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "prthread.h"
|
||||
@ -113,9 +112,6 @@
|
||||
#define NOISY_TRACE_FRAME(_msg,_frame);
|
||||
#endif
|
||||
|
||||
// Class IID's
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
// IID's
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -160,6 +160,7 @@
|
||||
#include "nsIObjectLoadingContent.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
// Drag & Drop, Clipboard
|
||||
#include "nsWidgetsCID.h"
|
||||
@ -167,9 +168,6 @@
|
||||
#include "nsIClipboardHelper.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "prtime.h"
|
||||
#include "prlong.h"
|
||||
@ -1306,7 +1304,7 @@ protected:
|
||||
void WillDoReflow();
|
||||
void DidDoReflow();
|
||||
nsresult ProcessReflowCommands(PRBool aInterruptible);
|
||||
nsresult ClearReflowEventStatus();
|
||||
void ClearReflowEventStatus();
|
||||
void PostReflowEvent();
|
||||
|
||||
// Note: when PR_FALSE is returned, AlreadyInQueue assumes the command will
|
||||
@ -1314,9 +1312,22 @@ protected:
|
||||
// mReflowCommandTable (AlreadyInQueue will insert it in that table).
|
||||
PRBool AlreadyInQueue(nsHTMLReflowCommand* aReflowCommand);
|
||||
|
||||
friend struct ReflowEvent;
|
||||
friend class nsPresShellEventCB;
|
||||
|
||||
class ReflowEvent;
|
||||
friend class ReflowEvent;
|
||||
|
||||
class ReflowEvent : public nsRunnable {
|
||||
public:
|
||||
NS_DECL_NSIRUNNABLE
|
||||
ReflowEvent(PresShell *aPresShell) : mPresShell(aPresShell) {
|
||||
NS_ASSERTION(aPresShell, "Null parameters!");
|
||||
}
|
||||
void Revoke() { mPresShell = nsnull; }
|
||||
private:
|
||||
PresShell *mPresShell;
|
||||
};
|
||||
|
||||
// Utility to determine if we're in the middle of a drag.
|
||||
PRBool IsDragInProgress ( ) const ;
|
||||
|
||||
@ -1383,11 +1394,12 @@ protected:
|
||||
PRInt16 mSelectionFlags;
|
||||
PRPackedBool mBatchReflows; // When set to true, the pres shell batches reflow commands.
|
||||
PresShellViewEventListener *mViewEventListener;
|
||||
nsCOMPtr<nsIEventQueue> mReflowEventQueue;
|
||||
FrameArena mFrameArena;
|
||||
StackArena* mStackArena;
|
||||
nsCOMPtr<nsIDragService> mDragService;
|
||||
PRInt32 mRCCreatedDuringLoad; // Counter to keep track of reflow commands created during doc
|
||||
|
||||
nsRevocableEventPtr<ReflowEvent> mReflowEvent;
|
||||
|
||||
// used for list of posted events and attribute changes. To be done
|
||||
// after reflow.
|
||||
@ -1927,14 +1939,8 @@ PresShell::Destroy()
|
||||
NS_RELEASE(mViewEventListener);
|
||||
}
|
||||
|
||||
// Revoke pending events
|
||||
mReflowEventQueue = nsnull;
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
nsresult rv = NS_GetCurrentEventQ(getter_AddRefs(eventQueue),
|
||||
nsContentUtils::EventQueueService());
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
eventQueue->RevokeEvents(this);
|
||||
}
|
||||
// Revoke any pending reflow event
|
||||
mReflowEvent.Revoke();
|
||||
|
||||
CancelAllReflowCommands();
|
||||
|
||||
@ -6354,96 +6360,57 @@ PresShell::Thaw()
|
||||
|
||||
//-------------- Begin Reflow Event Definition ------------------------
|
||||
|
||||
struct ReflowEvent : public PLEvent {
|
||||
ReflowEvent(nsIPresShell* aPresShell);
|
||||
~ReflowEvent() { }
|
||||
|
||||
void HandleEvent() {
|
||||
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
|
||||
if (presShell) {
|
||||
NS_IMETHODIMP
|
||||
PresShell::ReflowEvent::Run() {
|
||||
// Take an owning reference to the PresShell during this call to ensure
|
||||
// that it doesn't get killed off prematurely.
|
||||
nsRefPtr<PresShell> ps = mPresShell;
|
||||
if (ps) {
|
||||
#ifdef DEBUG
|
||||
if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
|
||||
printf("\n*** Handling reflow event: PresShell=%p, event=%p\n", (void*)presShell.get(), (void*)this);
|
||||
}
|
||||
#endif
|
||||
// XXX Statically cast the pres shell pointer so that we can call
|
||||
// protected methods on the pres shell. (the ReflowEvent struct
|
||||
// is a friend of the PresShell class)
|
||||
PresShell* ps = NS_REINTERPRET_CAST(PresShell*, presShell.get());
|
||||
PRBool isBatching;
|
||||
ps->ClearReflowEventStatus();
|
||||
ps->GetReflowBatchingStatus(&isBatching);
|
||||
if (!isBatching) {
|
||||
// Set a kung fu death grip on the view manager associated with the pres shell
|
||||
// before processing that pres shell's reflow commands. Fixes bug 54868.
|
||||
nsCOMPtr<nsIViewManager> viewManager = presShell->GetViewManager();
|
||||
|
||||
viewManager->BeginUpdateViewBatch();
|
||||
ps->ProcessReflowCommands(PR_TRUE);
|
||||
viewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
|
||||
|
||||
// Now, explicitly release the pres shell before the view manager
|
||||
presShell = nsnull;
|
||||
viewManager = nsnull;
|
||||
}
|
||||
if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
|
||||
printf("\n*** Handling reflow event: PresShell=%p, event=%p\n", (void*)ps, (void*)this);
|
||||
}
|
||||
#endif
|
||||
// NOTE: the ReflowEvent class is a friend of the PresShell class
|
||||
PRBool isBatching;
|
||||
ps->ClearReflowEventStatus();
|
||||
ps->GetReflowBatchingStatus(&isBatching);
|
||||
if (!isBatching) {
|
||||
// Set a kung fu death grip on the view manager associated with the pres shell
|
||||
// before processing that pres shell's reflow commands. Fixes bug 54868.
|
||||
nsCOMPtr<nsIViewManager> viewManager = ps->GetViewManager();
|
||||
|
||||
viewManager->BeginUpdateViewBatch();
|
||||
ps->ProcessReflowCommands(PR_TRUE);
|
||||
viewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
|
||||
|
||||
// Now, explicitly release the pres shell before the view manager
|
||||
ps = nsnull;
|
||||
viewManager = nsnull;
|
||||
}
|
||||
else
|
||||
mPresShell = 0;
|
||||
}
|
||||
|
||||
nsWeakPtr mPresShell;
|
||||
};
|
||||
|
||||
static void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent)
|
||||
{
|
||||
ReflowEvent* event = NS_STATIC_CAST(ReflowEvent*, aEvent);
|
||||
event->HandleEvent();
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent)
|
||||
{
|
||||
ReflowEvent* event = NS_STATIC_CAST(ReflowEvent*, aEvent);
|
||||
delete event;
|
||||
}
|
||||
|
||||
|
||||
ReflowEvent::ReflowEvent(nsIPresShell* aPresShell)
|
||||
{
|
||||
NS_ASSERTION(aPresShell, "Null parameters!");
|
||||
|
||||
mPresShell = do_GetWeakReference(aPresShell);
|
||||
|
||||
PL_InitEvent(this, aPresShell, ::HandlePLEvent, ::DestroyPLEvent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------- End Reflow Event Definition ---------------------------
|
||||
|
||||
|
||||
void
|
||||
PresShell::PostReflowEvent()
|
||||
{
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
nsContentUtils::EventQueueService()->
|
||||
GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
|
||||
getter_AddRefs(eventQueue));
|
||||
if (mReflowEvent.IsPending() || mIsDestroying || mIsReflowing ||
|
||||
mReflowCommands.Count() == 0)
|
||||
return;
|
||||
|
||||
if (eventQueue != mReflowEventQueue && !mIsDestroying &&
|
||||
!mIsReflowing && mReflowCommands.Count() > 0) {
|
||||
ReflowEvent* ev = new ReflowEvent(NS_STATIC_CAST(nsIPresShell*, this));
|
||||
// OOM note: both PostEvent and PL_DestroyEvent accept a null arg.
|
||||
if (NS_FAILED(eventQueue->PostEvent(ev))) {
|
||||
NS_ERROR("failed to post reflow event");
|
||||
PL_DestroyEvent(ev);
|
||||
}
|
||||
else {
|
||||
mReflowEventQueue = eventQueue;
|
||||
nsRefPtr<ReflowEvent> ev = new ReflowEvent(this);
|
||||
if (NS_FAILED(NS_DispatchToCurrentThread(ev))) {
|
||||
NS_WARNING("failed to dispatch reflow event");
|
||||
} else {
|
||||
mReflowEvent = ev;
|
||||
#ifdef DEBUG
|
||||
if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
|
||||
printf("\n*** PresShell::PostReflowEvent(), this=%p, event=%p\n", (void*)this, (void*)ev);
|
||||
}
|
||||
#endif
|
||||
if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
|
||||
printf("\n*** PresShell::PostReflowEvent(), this=%p, event=%p\n", (void*)this, (void*)ev);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -6642,11 +6609,10 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
void
|
||||
PresShell::ClearReflowEventStatus()
|
||||
{
|
||||
mReflowEventQueue = nsnull;
|
||||
return NS_OK;
|
||||
mReflowEvent.Forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -98,45 +98,12 @@
|
||||
#include "nsIFontMetrics.h"
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
class RedisplayTextEvent : public PLEvent
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::RedisplayTextEvent::Run()
|
||||
{
|
||||
public:
|
||||
RedisplayTextEvent(nsComboboxControlFrame* aComboboxControlFrame);
|
||||
|
||||
void HandleEvent()
|
||||
{
|
||||
NS_STATIC_CAST(nsComboboxControlFrame*, owner) ->
|
||||
HandleRedisplayTextEvent();
|
||||
}
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(void*)
|
||||
HandleRedisplayTextPLEvent(PLEvent* aEvent)
|
||||
{
|
||||
NS_ASSERTION(nsnull != aEvent, "Event is null");
|
||||
RedisplayTextEvent* event = NS_STATIC_CAST(RedisplayTextEvent*, aEvent);
|
||||
|
||||
event->HandleEvent();
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
DestroyRedisplayTextPLEvent(PLEvent* aEvent)
|
||||
{
|
||||
NS_ASSERTION(nsnull != aEvent, "Event is null");
|
||||
RedisplayTextEvent* event = NS_STATIC_CAST(RedisplayTextEvent*, aEvent);
|
||||
|
||||
delete event;
|
||||
}
|
||||
|
||||
RedisplayTextEvent::RedisplayTextEvent(nsComboboxControlFrame* aComboboxControlFrame)
|
||||
{
|
||||
PL_InitEvent(this, aComboboxControlFrame,
|
||||
::HandleRedisplayTextPLEvent,
|
||||
::DestroyRedisplayTextPLEvent);
|
||||
if (mControlFrame)
|
||||
mControlFrame->HandleRedisplayTextEvent();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class nsPresState;
|
||||
@ -339,7 +306,6 @@ nsComboboxControlFrame::nsComboboxControlFrame(nsStyleContext* aContext)
|
||||
mItemDisplayWidth = 0;
|
||||
|
||||
mInRedisplayText = PR_FALSE;
|
||||
mRedisplayTextEventPosted = PR_FALSE;
|
||||
|
||||
mRecentSelectedIndex = -1;
|
||||
|
||||
@ -1592,31 +1558,15 @@ nsComboboxControlFrame::RedisplayText(PRInt32 aIndex)
|
||||
// Don't call ActuallyDisplayText(PR_TRUE) directly here since that
|
||||
// could cause recursive frame construction. See bug 283117 and the comment in
|
||||
// HandleRedisplayTextEvent() below.
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
rv = nsContentUtils::EventQueueService()->
|
||||
GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
|
||||
getter_AddRefs(eventQueue));
|
||||
if (eventQueue) {
|
||||
RedisplayTextEvent* event = new RedisplayTextEvent(this);
|
||||
if (event) {
|
||||
// Revoke outstanding events to avoid out-of-order events which could mean
|
||||
// displaying the wrong text.
|
||||
if (mRedisplayTextEventPosted) {
|
||||
eventQueue->RevokeEvents(this);
|
||||
mRedisplayTextEventPosted = PR_FALSE;
|
||||
}
|
||||
|
||||
rv = eventQueue->PostEvent(event);
|
||||
// Revoke outstanding events to avoid out-of-order events which could mean
|
||||
// displaying the wrong text.
|
||||
mRedisplayTextEvent.Revoke();
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mRedisplayTextEventPosted = PR_TRUE;
|
||||
} else {
|
||||
PL_DestroyEvent(event);
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
nsRefPtr<RedisplayTextEvent> event = new RedisplayTextEvent(this);
|
||||
rv = NS_DispatchToCurrentThread(event);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mRedisplayTextEvent = event;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -1638,7 +1588,7 @@ nsComboboxControlFrame::HandleRedisplayTextEvent()
|
||||
// into the correct parent (mDisplayFrame). See bug 282607.
|
||||
NS_PRECONDITION(!mInRedisplayText, "Nested RedisplayText");
|
||||
mInRedisplayText = PR_TRUE;
|
||||
mRedisplayTextEventPosted = PR_FALSE;
|
||||
mRedisplayTextEvent.Forget();
|
||||
|
||||
ActuallyDisplayText(PR_TRUE);
|
||||
mDisplayFrame->AddStateBits(NS_FRAME_IS_DIRTY);
|
||||
@ -1941,14 +1891,8 @@ nsComboboxControlFrame::CreateFrameFor(nsPresContext* aPresContext,
|
||||
void
|
||||
nsComboboxControlFrame::Destroy()
|
||||
{
|
||||
// Revoke queued RedisplayTextEvents
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
nsContentUtils::EventQueueService()->
|
||||
GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
|
||||
getter_AddRefs(eventQueue));
|
||||
if (eventQueue) {
|
||||
eventQueue->RevokeEvents(this);
|
||||
}
|
||||
// Revoke any pending RedisplayTextEvent
|
||||
mRedisplayTextEvent.Revoke();
|
||||
|
||||
nsFormControlFrame::RegUnRegAccessKey(NS_STATIC_CAST(nsIFrame*, this), PR_FALSE);
|
||||
|
||||
|
@ -64,6 +64,7 @@
|
||||
#include "nsIScrollableViewProvider.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
class nsIView;
|
||||
class nsStyleContext;
|
||||
@ -87,7 +88,6 @@ class nsComboboxControlFrame : public nsAreaFrame,
|
||||
{
|
||||
public:
|
||||
friend nsIFrame* NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRUint32 aFlags);
|
||||
friend class RedisplayTextEvent;
|
||||
|
||||
nsComboboxControlFrame(nsStyleContext* aContext);
|
||||
~nsComboboxControlFrame();
|
||||
@ -205,6 +205,18 @@ public:
|
||||
nsRect aAbsoluteTwipsRect,
|
||||
nsRect aAbsolutePixelRect);
|
||||
protected:
|
||||
class RedisplayTextEvent;
|
||||
friend class RedisplayTextEvent;
|
||||
|
||||
class RedisplayTextEvent : public nsRunnable {
|
||||
public:
|
||||
NS_DECL_NSIRUNNABLE
|
||||
RedisplayTextEvent(nsComboboxControlFrame *c) : mControlFrame(c) {}
|
||||
void Revoke() { mControlFrame = nsnull; }
|
||||
private:
|
||||
nsComboboxControlFrame *mControlFrame;
|
||||
};
|
||||
|
||||
void ShowPopup(PRBool aShowPopup);
|
||||
void ShowList(nsPresContext* aPresContext, PRBool aShowList);
|
||||
void SetButtonFrameSize(const nsSize& aSize);
|
||||
@ -249,7 +261,8 @@ protected:
|
||||
|
||||
PRPackedBool mDroppedDown; // Current state of the dropdown list, PR_TRUE is dropped down
|
||||
PRPackedBool mInRedisplayText;
|
||||
PRPackedBool mRedisplayTextEventPosted;
|
||||
|
||||
nsRevocableEventPtr<RedisplayTextEvent> mRedisplayTextEvent;
|
||||
|
||||
PRInt32 mRecentSelectedIndex;
|
||||
PRInt32 mDisplayedIndex;
|
||||
|
@ -1485,10 +1485,9 @@ nsFrame::FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent)
|
||||
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(aContent ? aContent : mContent);
|
||||
|
||||
if (domNode) {
|
||||
nsPLDOMEvent *event = new nsPLDOMEvent(domNode, aDOMEventName);
|
||||
if (event && NS_FAILED(event->PostDOMEvent())) {
|
||||
PL_DestroyEvent(event);
|
||||
}
|
||||
nsRefPtr<nsPLDOMEvent> event = new nsPLDOMEvent(domNode, aDOMEventName);
|
||||
if (!event || NS_FAILED(event->PostDOMEvent()))
|
||||
NS_WARNING("Failed to dispatch nsPLDOMEvent");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,6 @@
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsReflowPath.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsPresState.h"
|
||||
@ -88,8 +87,6 @@
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsBidiUtils.h"
|
||||
|
||||
static const char kEventQueueServiceCID[] = NS_EVENTQUEUESERVICE_CONTRACTID;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
//----------nsHTMLScrollFrame-------------------------------------------
|
||||
@ -1310,14 +1307,11 @@ nsGfxScrollFrameInner::nsGfxScrollFrameInner(nsContainerFrame* aOuter,
|
||||
|
||||
nsGfxScrollFrameInner::~nsGfxScrollFrameInner()
|
||||
{
|
||||
if (mScrollEventQueue) {
|
||||
mScrollEventQueue->RevokeEvents(this);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt) nsGfxScrollFrameInner::AddRef(void)
|
||||
{
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt) nsGfxScrollFrameInner::Release(void)
|
||||
@ -1811,24 +1805,19 @@ void nsGfxScrollFrameInner::CurPosAttributeChanged(nsIContent* aContent)
|
||||
}
|
||||
|
||||
/* ============= Scroll events ========== */
|
||||
PR_STATIC_CALLBACK(void*) HandleScrollEvent(PLEvent* aEvent)
|
||||
{
|
||||
NS_ASSERTION(nsnull != aEvent,"Event is null");
|
||||
nsGfxScrollFrameInner* inner = NS_STATIC_CAST(nsGfxScrollFrameInner*, aEvent->owner);
|
||||
inner->FireScrollEvent();
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void) DestroyScrollEvent(PLEvent* aEvent)
|
||||
NS_IMETHODIMP
|
||||
nsGfxScrollFrameInner::ScrollEvent::Run()
|
||||
{
|
||||
NS_ASSERTION(nsnull != aEvent,"Event is null");
|
||||
delete aEvent;
|
||||
if (mInner)
|
||||
mInner->FireScrollEvent();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsGfxScrollFrameInner::FireScrollEvent()
|
||||
{
|
||||
mScrollEventQueue = nsnull;
|
||||
mScrollEvent.Forget();
|
||||
|
||||
nsScrollbarEvent event(PR_TRUE, NS_SCROLL_EVENT, nsnull);
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
@ -1852,26 +1841,15 @@ nsGfxScrollFrameInner::FireScrollEvent()
|
||||
void
|
||||
nsGfxScrollFrameInner::PostScrollEvent()
|
||||
{
|
||||
nsCOMPtr<nsIEventQueueService> service = do_GetService(kEventQueueServiceCID);
|
||||
NS_ASSERTION(service, "No event service");
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
service->GetSpecialEventQueue(
|
||||
nsIEventQueueService::UI_THREAD_EVENT_QUEUE, getter_AddRefs(eventQueue));
|
||||
NS_ASSERTION(eventQueue, "Event queue is null");
|
||||
|
||||
if (eventQueue == mScrollEventQueue)
|
||||
if (mScrollEvent.IsPending())
|
||||
return;
|
||||
|
||||
PLEvent* ev = new PLEvent;
|
||||
if (!ev)
|
||||
return;
|
||||
PL_InitEvent(ev, this, ::HandleScrollEvent, ::DestroyScrollEvent);
|
||||
|
||||
if (mScrollEventQueue) {
|
||||
mScrollEventQueue->RevokeEvents(this);
|
||||
nsRefPtr<ScrollEvent> ev = new ScrollEvent(this);
|
||||
if (NS_FAILED(NS_DispatchToCurrentThread(ev))) {
|
||||
NS_WARNING("failed to dispatch ScrollEvent");
|
||||
} else {
|
||||
mScrollEvent = ev;
|
||||
}
|
||||
eventQueue->PostEvent(ev);
|
||||
mScrollEventQueue = eventQueue;
|
||||
}
|
||||
|
||||
PRBool
|
||||
|
@ -47,7 +47,7 @@
|
||||
#include "nsIScrollPositionListener.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIScrollableView.h"
|
||||
|
||||
class nsISupportsArray;
|
||||
@ -98,6 +98,15 @@ public:
|
||||
void PostScrollEvent();
|
||||
void FireScrollEvent();
|
||||
|
||||
class ScrollEvent : public nsRunnable {
|
||||
public:
|
||||
NS_DECL_NSIRUNNABLE
|
||||
ScrollEvent(nsGfxScrollFrameInner *inner) : mInner(inner) {}
|
||||
void Revoke() { mInner = nsnull; }
|
||||
private:
|
||||
nsGfxScrollFrameInner *mInner;
|
||||
};
|
||||
|
||||
void SetScrollbarEnabled(nsIBox* aBox, nscoord aMaxPos, PRBool aReflow=PR_TRUE);
|
||||
PRBool SetCoordAttribute(nsIBox* aBox, nsIAtom* aAtom, nscoord aSize, PRBool aReflow=PR_TRUE);
|
||||
nscoord GetCoordAttribute(nsIBox* aFrame, nsIAtom* atom, nscoord defaultValue);
|
||||
@ -149,7 +158,7 @@ public:
|
||||
const nsRect& aOldScrollArea,
|
||||
const nsRect& aScrollArea);
|
||||
|
||||
nsCOMPtr<nsIEventQueue> mScrollEventQueue;
|
||||
nsRevocableEventPtr<ScrollEvent> mScrollEvent;
|
||||
nsIScrollableView* mScrollableView;
|
||||
nsIBox* mHScrollbarBox;
|
||||
nsIBox* mVScrollbarBox;
|
||||
|
@ -91,9 +91,6 @@
|
||||
#include "imgIContainer.h"
|
||||
#include "imgILoader.h"
|
||||
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "plevent.h"
|
||||
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsCSSFrameConstructor.h"
|
||||
#include "nsIPrefBranch2.h"
|
||||
|
@ -40,6 +40,10 @@
|
||||
#ifndef nsObjectFrame_h___
|
||||
#define nsObjectFrame_h___
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "nsIObjectFrame.h"
|
||||
#include "nsFrame.h"
|
||||
|
||||
|
@ -83,6 +83,7 @@ static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);
|
||||
#include "nsIDOMText.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
//included for desired x position;
|
||||
#include "nsPresContext.h"
|
||||
@ -96,8 +97,6 @@ static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
|
||||
// notifications
|
||||
#include "nsIDOMDocument.h"
|
||||
@ -145,7 +144,6 @@ static NS_DEFINE_IID(kCSubtreeIteratorCID, NS_SUBTREEITERATOR_CID);
|
||||
class nsSelectionIterator;
|
||||
class nsFrameSelection;
|
||||
class nsAutoScrollTimer;
|
||||
struct nsScrollSelectionIntoViewEvent;
|
||||
|
||||
PRBool IsValidSelectionPoint(nsFrameSelection *aFrameSel, nsIContent *aContent);
|
||||
PRBool IsValidSelectionPoint(nsFrameSelection *aFrameSel, nsIDOMNode *aDomNode);
|
||||
@ -262,8 +260,24 @@ public:
|
||||
|
||||
private:
|
||||
friend class nsSelectionIterator;
|
||||
friend struct nsScrollSelectionIntoViewEvent;
|
||||
|
||||
class ScrollSelectionIntoViewEvent;
|
||||
friend class ScrollSelectionIntoViewEvent;
|
||||
|
||||
class ScrollSelectionIntoViewEvent : public nsRunnable {
|
||||
public:
|
||||
NS_DECL_NSIRUNNABLE
|
||||
ScrollSelectionIntoViewEvent(nsTypedSelection *aTypedSelection,
|
||||
SelectionRegion aRegion)
|
||||
: mTypedSelection(aTypedSelection),
|
||||
mRegion(aRegion) {
|
||||
NS_ASSERTION(aTypedSelection, "null parameter");
|
||||
}
|
||||
void Revoke() { mTypedSelection = nsnull; }
|
||||
private:
|
||||
nsTypedSelection *mTypedSelection;
|
||||
SelectionRegion mRegion;
|
||||
};
|
||||
|
||||
void setAnchorFocusRange(PRInt32 aIndex); //pass in index into FrameSelection
|
||||
NS_IMETHOD selectFrames(nsPresContext* aPresContext, nsIContentIterator *aInnerIter, nsIContent *aContent, nsIDOMRange *aRange, nsIPresShell *aPresShell, PRBool aFlags);
|
||||
@ -287,9 +301,8 @@ private:
|
||||
SelectionType mType;//type of this nsTypedSelection;
|
||||
nsAutoScrollTimer *mAutoScrollTimer; // timer for autoscrolling.
|
||||
nsCOMArray<nsISelectionListener> mSelectionListeners;
|
||||
PRBool mTrueDirection;
|
||||
nsCOMPtr<nsIEventQueue> mEventQueue;
|
||||
PRBool mScrollEventPosted;
|
||||
PRPackedBool mTrueDirection;
|
||||
nsRevocableEventPtr<ScrollSelectionIntoViewEvent> mScrollEvent;
|
||||
CachedOffsetForFrame *mCachedOffsetForFrame;
|
||||
};
|
||||
|
||||
@ -3879,7 +3892,6 @@ nsTypedSelection::nsTypedSelection(nsFrameSelection *aList)
|
||||
mFixupState = PR_FALSE;
|
||||
mDirection = eDirNext;
|
||||
mAutoScrollTimer = nsnull;
|
||||
mScrollEventPosted = PR_FALSE;
|
||||
mCachedOffsetForFrame = nsnull;
|
||||
}
|
||||
|
||||
@ -3890,7 +3902,6 @@ nsTypedSelection::nsTypedSelection()
|
||||
mFixupState = PR_FALSE;
|
||||
mDirection = eDirNext;
|
||||
mAutoScrollTimer = nsnull;
|
||||
mScrollEventPosted = PR_FALSE;
|
||||
mCachedOffsetForFrame = nsnull;
|
||||
}
|
||||
|
||||
@ -3909,10 +3920,7 @@ void nsTypedSelection::DetachFromPresentation() {
|
||||
NS_RELEASE(mAutoScrollTimer);
|
||||
}
|
||||
|
||||
if (mEventQueue && mScrollEventPosted) {
|
||||
mEventQueue->RevokeEvents(this);
|
||||
mScrollEventPosted = PR_FALSE;
|
||||
}
|
||||
mScrollEvent.Revoke();
|
||||
|
||||
if (mCachedOffsetForFrame) {
|
||||
delete mCachedOffsetForFrame;
|
||||
@ -6670,88 +6678,33 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView,
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent);
|
||||
static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent);
|
||||
|
||||
struct nsScrollSelectionIntoViewEvent : public PLEvent {
|
||||
nsScrollSelectionIntoViewEvent(nsTypedSelection *aTypedSelection, SelectionRegion aRegion) {
|
||||
if (!aTypedSelection)
|
||||
return;
|
||||
|
||||
mTypedSelection = aTypedSelection;
|
||||
mRegion = aRegion;
|
||||
|
||||
PL_InitEvent(this, aTypedSelection, ::HandlePLEvent, ::DestroyPLEvent);
|
||||
}
|
||||
|
||||
~nsScrollSelectionIntoViewEvent() {}
|
||||
|
||||
void HandleEvent() {
|
||||
mTypedSelection->mScrollEventPosted = PR_FALSE;
|
||||
|
||||
if (!mTypedSelection)
|
||||
return;
|
||||
|
||||
mTypedSelection->ScrollIntoView(mRegion, PR_TRUE);
|
||||
}
|
||||
|
||||
nsTypedSelection *mTypedSelection;
|
||||
SelectionRegion mRegion;
|
||||
};
|
||||
|
||||
static void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent)
|
||||
NS_IMETHODIMP
|
||||
nsTypedSelection::ScrollSelectionIntoViewEvent::Run()
|
||||
{
|
||||
nsScrollSelectionIntoViewEvent* event =
|
||||
NS_STATIC_CAST(nsScrollSelectionIntoViewEvent*, aEvent);
|
||||
NS_ASSERTION(nsnull != event,"Event is null");
|
||||
event->HandleEvent();
|
||||
return nsnull;
|
||||
}
|
||||
if (!mTypedSelection)
|
||||
return NS_OK; // event revoked
|
||||
|
||||
static void PR_CALLBACK DestroyPLEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsScrollSelectionIntoViewEvent* event =
|
||||
NS_STATIC_CAST(nsScrollSelectionIntoViewEvent*, aEvent);
|
||||
NS_ASSERTION(nsnull != event,"Event is null");
|
||||
delete event;
|
||||
mTypedSelection->mScrollEvent.Forget();
|
||||
mTypedSelection->ScrollIntoView(mRegion, PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTypedSelection::PostScrollSelectionIntoViewEvent(SelectionRegion aRegion)
|
||||
{
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
// If we've already posted an event, revoke it and place a new one at the
|
||||
// end of the queue to make sure that any new pending reflow events are
|
||||
// processed before we scroll. This will insure that we scroll to the
|
||||
// correct place on screen.
|
||||
mScrollEvent.Revoke();
|
||||
|
||||
if (!mEventQueue) {
|
||||
nsresult rv;
|
||||
nsRefPtr<ScrollSelectionIntoViewEvent> ev =
|
||||
new ScrollSelectionIntoViewEvent(this, aRegion);
|
||||
nsresult rv = NS_DispatchToCurrentThread(ev);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Cache the event queue of the current UI thread
|
||||
nsCOMPtr<nsIEventQueueService> eventService = do_GetService(kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && (nsnull != eventService)) { // XXX this implies that the UI is the current thread.
|
||||
rv = eventService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(mEventQueue));
|
||||
}
|
||||
}
|
||||
|
||||
if (mEventQueue) {
|
||||
if (mScrollEventPosted) {
|
||||
// We've already posted an event, revoke it and
|
||||
// place a new one at the end of the queue to make
|
||||
// sure that any new pending reflow events are processed
|
||||
// before we scroll. This will insure that we scroll
|
||||
// to the correct place on screen.
|
||||
|
||||
mEventQueue->RevokeEvents(this);
|
||||
mScrollEventPosted = PR_FALSE;
|
||||
}
|
||||
|
||||
nsScrollSelectionIntoViewEvent *ev = new nsScrollSelectionIntoViewEvent(this, aRegion);
|
||||
if (ev) {
|
||||
mEventQueue->PostEvent(ev);
|
||||
mScrollEventPosted = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
mScrollEvent = ev;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -64,10 +64,8 @@ static const char sPrintSettingsServiceContractID[] = "@mozilla.org/gfx/printset
|
||||
static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printsettings-service;1";
|
||||
|
||||
// Printing Events
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsPrintPreviewListener.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
// Printing
|
||||
#include "nsIWebBrowserPrint.h"
|
||||
@ -162,9 +160,6 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro
|
||||
#include "nsIContentViewerContainer.h"
|
||||
#include "nsIContentViewer.h"
|
||||
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIEventQueue.h"
|
||||
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIFocusController.h"
|
||||
|
||||
@ -3731,66 +3726,30 @@ nsPrintEngine::Observe(nsISupports *aSubject, const char *aTopic, const PRUnicha
|
||||
//---------------------------------------------------------------
|
||||
//-- PLEvent Notification
|
||||
//---------------------------------------------------------------
|
||||
PR_STATIC_CALLBACK(void*) HandlePLEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsIDocumentViewerPrint *docViewerPrint = (nsIDocumentViewerPrint*)PL_GetEventOwner(aEvent);
|
||||
|
||||
NS_ASSERTION(docViewerPrint, "The event owner is null.");
|
||||
if (docViewerPrint) {
|
||||
docViewerPrint->OnDonePrinting();
|
||||
class nsPrintCompletionEvent : public nsRunnable {
|
||||
public:
|
||||
nsPrintCompletionEvent(nsIDocumentViewerPrint *docViewerPrint)
|
||||
: mDocViewerPrint(docViewerPrint) {
|
||||
NS_ASSERTION(mDocViewerPrint, "mDocViewerPrint is null.");
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
NS_IMETHOD Run() {
|
||||
if (mDocViewerPrint)
|
||||
mDocViewerPrint->OnDonePrinting();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
PR_STATIC_CALLBACK(void) DestroyPLEvent(PLEvent* aEvent)
|
||||
{
|
||||
nsIDocumentViewerPrint *docViewerPrint = (nsIDocumentViewerPrint*)PL_GetEventOwner(aEvent);
|
||||
NS_IF_RELEASE(docViewerPrint);
|
||||
private:
|
||||
nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint;
|
||||
};
|
||||
|
||||
delete aEvent;
|
||||
}
|
||||
//-----------------------------------------------------------
|
||||
void
|
||||
nsPrintEngine::FirePrintCompletionEvent()
|
||||
{
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> event_service = do_GetService(kEventQueueServiceCID);
|
||||
|
||||
if (!event_service)
|
||||
{
|
||||
NS_WARNING("Failed to get event queue service");
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEventQueue> event_queue;
|
||||
|
||||
event_service->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(event_queue));
|
||||
|
||||
if (!event_queue)
|
||||
{
|
||||
NS_WARNING("Failed to get event queue from service");
|
||||
return;
|
||||
}
|
||||
|
||||
PLEvent *event = new PLEvent;
|
||||
|
||||
if (!event)
|
||||
{
|
||||
NS_WARNING("Out of memory?");
|
||||
return;
|
||||
}
|
||||
|
||||
PL_InitEvent(event, mDocViewerPrint, ::HandlePLEvent, ::DestroyPLEvent);
|
||||
|
||||
// The event owns the docviewer pointer now.
|
||||
NS_ADDREF(mDocViewerPrint);
|
||||
|
||||
event_queue->PostEvent(event);
|
||||
return;
|
||||
nsCOMPtr<nsIRunnable> event = new nsPrintCompletionEvent(mDocViewerPrint);
|
||||
if (NS_FAILED(NS_DispatchToCurrentThread(event)))
|
||||
NS_WARNING("failed to dispatch print completion event");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
@ -77,9 +77,7 @@
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsICSSParser.h"
|
||||
#include "nsICSSImportRule.h"
|
||||
#include "plevent.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
@ -141,7 +139,7 @@ static const char* const gStateStrings[] = {
|
||||
/********************************
|
||||
* SheetLoadData implementation *
|
||||
********************************/
|
||||
NS_IMPL_ISUPPORTS1(SheetLoadData, nsIUnicharStreamLoaderObserver)
|
||||
NS_IMPL_ISUPPORTS2(SheetLoadData, nsIUnicharStreamLoaderObserver, nsIRunnable)
|
||||
|
||||
SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader,
|
||||
const nsSubstring& aTitle,
|
||||
@ -241,6 +239,14 @@ SheetLoadData::~SheetLoadData()
|
||||
NS_IF_RELEASE(mNext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SheetLoadData::Run()
|
||||
{
|
||||
mLoader->HandleLoadEvent(this);
|
||||
mLoader->DestroyLoadEvent(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*************************
|
||||
* Loader Implementation *
|
||||
*************************/
|
||||
@ -1924,26 +1930,6 @@ CSSLoaderImpl::InternalLoadNonDocumentSheet(nsIURI* aURL,
|
||||
return rv;
|
||||
}
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
PR_STATIC_CALLBACK(void*) HandleStyleSheetLoadedEvent(PLEvent* aEvent);
|
||||
PR_STATIC_CALLBACK(void) DestroyStyleSheetLoadedEvent(PLEvent* aEvent);
|
||||
PR_END_EXTERN_C
|
||||
|
||||
PR_STATIC_CALLBACK(void*)
|
||||
HandleStyleSheetLoadedEvent(PLEvent* aEvent)
|
||||
{
|
||||
SheetLoadData* data = NS_STATIC_CAST(SheetLoadData*, aEvent);
|
||||
data->mLoader->HandleLoadEvent(data);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
DestroyStyleSheetLoadedEvent(PLEvent* aEvent)
|
||||
{
|
||||
SheetLoadData* data = NS_STATIC_CAST(SheetLoadData*, aEvent);
|
||||
data->mLoader->DestroyLoadEvent(data);
|
||||
}
|
||||
|
||||
nsresult
|
||||
CSSLoaderImpl::PostLoadEvent(nsIURI* aURI,
|
||||
nsICSSStyleSheet* aSheet,
|
||||
@ -1957,13 +1943,7 @@ CSSLoaderImpl::PostLoadEvent(nsIURI* aURI,
|
||||
// observer, since we may need to unblock the parser
|
||||
// NS_PRECONDITION(aObserver, "Must have observer");
|
||||
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
nsresult rv = nsContentUtils::EventQueueService()->
|
||||
GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
|
||||
getter_AddRefs(eventQ));
|
||||
NS_ENSURE_TRUE(eventQ, rv);
|
||||
|
||||
SheetLoadData* evt =
|
||||
SheetLoadData *evt =
|
||||
new SheetLoadData(this, EmptyString(), // title doesn't matter here
|
||||
aParserToUnblock,
|
||||
aURI,
|
||||
@ -1974,9 +1954,11 @@ CSSLoaderImpl::PostLoadEvent(nsIURI* aURI,
|
||||
NS_ENSURE_TRUE(evt, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(evt);
|
||||
|
||||
PL_InitEvent(evt, this, ::HandleStyleSheetLoadedEvent,
|
||||
::DestroyStyleSheetLoadedEvent);
|
||||
|
||||
if (!mPostedEvents.AppendElement(evt)) {
|
||||
NS_RELEASE(evt);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// We'll unblock onload when we destroy the event, so make sure to block it
|
||||
// now. We unblock from destruction, not firing, just in case events get
|
||||
@ -1984,15 +1966,11 @@ CSSLoaderImpl::PostLoadEvent(nsIURI* aURI,
|
||||
if (mDocument) {
|
||||
mDocument->BlockOnload();
|
||||
}
|
||||
|
||||
if (!mPostedEvents.AppendElement(evt)) {
|
||||
PL_DestroyEvent(evt);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
rv = eventQ->PostEvent(evt);
|
||||
nsresult rv = NS_DispatchToCurrentThread(evt);
|
||||
if (NS_FAILED(rv)) {
|
||||
PL_DestroyEvent(evt);
|
||||
NS_WARNING("failed to dispatch stylesheet load event");
|
||||
DestroyLoadEvent(evt);
|
||||
} else {
|
||||
// We want to notify the observer for this data. We didn't want to set
|
||||
// this earlier, since we would have returned an error _and_ notified.
|
||||
|
@ -62,6 +62,7 @@ class nsICSSImportRule;
|
||||
class nsMediaList;
|
||||
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsIUnicharStreamLoader.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
@ -69,7 +70,6 @@ class nsMediaList;
|
||||
#include "nsURIHashKey.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "plevent.h"
|
||||
|
||||
/**
|
||||
* OVERALL ARCHITECTURE
|
||||
@ -103,7 +103,7 @@ class nsMediaList;
|
||||
* Data needed to properly load a stylesheet *
|
||||
*********************************************/
|
||||
|
||||
class SheetLoadData : public PLEvent,
|
||||
class SheetLoadData : public nsIRunnable,
|
||||
public nsIUnicharStreamLoaderObserver
|
||||
{
|
||||
public:
|
||||
@ -135,6 +135,7 @@ public:
|
||||
already_AddRefed<nsIURI> GetReferrerURI();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIRUNNABLE
|
||||
NS_DECL_NSIUNICHARSTREAMLOADEROBSERVER
|
||||
|
||||
// Hold a ref to the CSSLoader so we can call back to it to let it
|
||||
|
@ -83,13 +83,13 @@
|
||||
#include "nsIDOMHTMLMapElement.h"
|
||||
#include "nsBoxLayoutState.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsTransform2D.h"
|
||||
#include "nsITheme.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsDisplayList.h"
|
||||
@ -98,73 +98,46 @@
|
||||
|
||||
#define ONLOAD_CALLED_TOO_EARLY 1
|
||||
|
||||
static void PR_CALLBACK
|
||||
HandleImagePLEvent(nsIContent *aContent, PRUint32 aMessage,
|
||||
PRUint32 aEventFlags)
|
||||
class nsImageBoxFrameEvent : public nsRunnable
|
||||
{
|
||||
if (!aContent) {
|
||||
NS_ERROR("null node passed to HandleImagePLEvent!");
|
||||
public:
|
||||
nsImageBoxFrameEvent(nsIContent *content, PRUint32 message)
|
||||
: mContent(content), mMessage(message) {}
|
||||
|
||||
return;
|
||||
}
|
||||
NS_IMETHOD Run();
|
||||
|
||||
nsIDocument* doc = aContent->GetOwnerDoc();
|
||||
private:
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
PRUint32 mMessage;
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageBoxFrameEvent::Run()
|
||||
{
|
||||
nsIDocument* doc = mContent->GetOwnerDoc();
|
||||
if (!doc) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIPresShell *pres_shell = doc->GetShellAt(0);
|
||||
if (!pres_shell) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPresContext> pres_context = pres_shell->GetPresContext();
|
||||
if (!pres_context) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event(PR_TRUE, aMessage);
|
||||
nsEvent event(PR_TRUE, mMessage);
|
||||
|
||||
event.flags |= aEventFlags;
|
||||
nsEventDispatcher::Dispatch(aContent, pres_context, &event, nsnull, &status);
|
||||
event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
|
||||
nsEventDispatcher::Dispatch(mContent, pres_context, &event, nsnull, &status);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static void* PR_CALLBACK
|
||||
HandleImageOnloadPLEvent(PLEvent *aEvent)
|
||||
{
|
||||
nsIContent *content = (nsIContent *)PL_GetEventOwner(aEvent);
|
||||
|
||||
HandleImagePLEvent(content, NS_IMAGE_LOAD,
|
||||
NS_EVENT_FLAG_CANT_BUBBLE);
|
||||
|
||||
// XXXldb Why not put this in DestroyImagePLEvent?
|
||||
NS_RELEASE(content);
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
static void* PR_CALLBACK
|
||||
HandleImageOnerrorPLEvent(PLEvent *aEvent)
|
||||
{
|
||||
nsIContent *content = (nsIContent *)PL_GetEventOwner(aEvent);
|
||||
|
||||
HandleImagePLEvent(content, NS_IMAGE_ERROR, NS_EVENT_FLAG_CANT_BUBBLE);
|
||||
|
||||
// XXXldb Why not put this in DestroyImagePLEvent?
|
||||
NS_RELEASE(content);
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
static void PR_CALLBACK
|
||||
DestroyImagePLEvent(PLEvent* aEvent)
|
||||
{
|
||||
delete aEvent;
|
||||
}
|
||||
|
||||
// Fire off a PLEvent that'll asynchronously call the image elements
|
||||
// Fire off an event that'll asynchronously call the image elements
|
||||
// onload handler once handled. This is needed since the image library
|
||||
// can't decide if it wants to call it's observer methods
|
||||
// synchronously or asynchronously. If an image is loaded from the
|
||||
@ -175,62 +148,12 @@ DestroyImagePLEvent(PLEvent* aEvent)
|
||||
void
|
||||
FireImageDOMEvent(nsIContent* aContent, PRUint32 aMessage)
|
||||
{
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
NS_ASSERTION(aMessage == NS_IMAGE_LOAD || aMessage == NS_IMAGE_ERROR,
|
||||
"invalid message");
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> event_service =
|
||||
do_GetService(kEventQueueServiceCID);
|
||||
|
||||
if (!event_service) {
|
||||
NS_WARNING("Failed to get event queue service");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEventQueue> event_queue;
|
||||
|
||||
event_service->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(event_queue));
|
||||
|
||||
if (!event_queue) {
|
||||
NS_WARNING("Failed to get event queue from service");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PLEvent *event = new PLEvent;
|
||||
|
||||
if (!event) {
|
||||
// Out of memory, but none of our callers care, so just warn and
|
||||
// don't fire the event
|
||||
|
||||
NS_WARNING("Out of memory?");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PLHandleEventProc f;
|
||||
|
||||
switch (aMessage) {
|
||||
case NS_IMAGE_LOAD :
|
||||
f = ::HandleImageOnloadPLEvent;
|
||||
|
||||
break;
|
||||
case NS_IMAGE_ERROR :
|
||||
f = ::HandleImageOnerrorPLEvent;
|
||||
|
||||
break;
|
||||
default:
|
||||
NS_WARNING("Huh, I don't know how to fire this type of event?!");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PL_InitEvent(event, aContent, f, ::DestroyImagePLEvent);
|
||||
|
||||
// The event owns the content pointer now.
|
||||
NS_ADDREF(aContent);
|
||||
|
||||
event_queue->PostEvent(event);
|
||||
nsCOMPtr<nsIRunnable> event = new nsImageBoxFrameEvent(aContent, aMessage);
|
||||
if (NS_FAILED(NS_DispatchToCurrentThread(event)))
|
||||
NS_WARNING("failed to dispatch image event");
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "nsXULAtoms.h"
|
||||
#include "nsPLDOMEvent.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
// A helper class for managing our ranges of selection.
|
||||
struct nsTreeRange
|
||||
@ -612,21 +613,12 @@ NS_IMETHODIMP nsTreeSelection::SetCurrentIndex(PRInt32 aIndex)
|
||||
nsCOMPtr<nsIDOMNode> treeDOMNode(do_QueryInterface(treeElt));
|
||||
NS_ENSURE_TRUE(treeDOMNode, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsPLDOMEvent *event = new nsPLDOMEvent(treeDOMNode,
|
||||
nsRefPtr<nsPLDOMEvent> event = new nsPLDOMEvent(treeDOMNode,
|
||||
NS_LITERAL_STRING("DOMMenuItemActive"));
|
||||
if (!event)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv;
|
||||
if (event) {
|
||||
rv = event->PostDOMEvent();
|
||||
if (NS_FAILED(rv)) {
|
||||
PL_DestroyEvent(event);
|
||||
}
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return rv;
|
||||
return event->PostDOMEvent();
|
||||
}
|
||||
|
||||
#define ADD_NEW_RANGE(macro_range, macro_selection, macro_start, macro_end) \
|
||||
|
@ -402,10 +402,10 @@ NS_IMETHODIMP nsAbQueryLDAPMessageListener::OnLDAPInit(nsILDAPConnection *aConn,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsILDAPMessageListener> proxyListener;
|
||||
rv = NS_GetProxyForObject(NS_UI_THREAD_EVENTQ,
|
||||
rv = NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsILDAPMessageListener),
|
||||
NS_STATIC_CAST(nsILDAPMessageListener *, this),
|
||||
PROXY_SYNC | PROXY_ALWAYS,
|
||||
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(proxyListener));
|
||||
|
||||
rv = ldapOperation->Init(mConnection, proxyListener, nsnull);
|
||||
@ -471,13 +471,11 @@ nsresult nsAbQueryLDAPMessageListener::OnLDAPMessageBind (nsILDAPMessage *aMessa
|
||||
mSearchOperation = do_CreateInstance(NS_LDAPOPERATION_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyMgr =
|
||||
do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsILDAPMessageListener> proxyListener;
|
||||
rv = proxyMgr->GetProxyForObject( NS_UI_THREAD_EVENTQ, NS_GET_IID(nsILDAPMessageListener),
|
||||
this, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs(proxyListener));
|
||||
rv = NS_GetProxyForObject( NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsILDAPMessageListener),
|
||||
this, NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(proxyListener));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mSearchOperation->Init (mConnection, proxyListener, nsnull);
|
||||
|
@ -144,10 +144,10 @@ NS_IMETHODIMP nsAbLDAPProcessReplicationData::OnLDAPInit(nsILDAPConnection *aCon
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILDAPMessageListener> listener;
|
||||
nsresult rv = NS_GetProxyForObject(NS_CURRENT_EVENTQ,
|
||||
nsresult rv = NS_GetProxyForObject(NS_PROXY_TO_CURRENT_THREAD,
|
||||
NS_GET_IID(nsILDAPMessageListener),
|
||||
NS_STATIC_CAST(nsILDAPMessageListener*, this),
|
||||
PROXY_SYNC | PROXY_ALWAYS,
|
||||
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(listener));
|
||||
if(NS_FAILED(rv)) {
|
||||
Done(PR_FALSE);
|
||||
|
@ -165,10 +165,10 @@ NS_IMETHODIMP nsAbLDAPReplicationQuery::ConnectToLDAPServer(nsILDAPURL *aURL, co
|
||||
|
||||
// Initiate LDAP message listener to the current thread
|
||||
nsCOMPtr<nsILDAPMessageListener> listener;
|
||||
rv = NS_GetProxyForObject(NS_CURRENT_EVENTQ,
|
||||
rv = NS_GetProxyForObject(NS_PROXY_TO_CURRENT_THREAD,
|
||||
NS_GET_IID(nsILDAPMessageListener),
|
||||
NS_STATIC_CAST(nsILDAPMessageListener*, mDataProcessor),
|
||||
PROXY_SYNC | PROXY_ALWAYS,
|
||||
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(listener));
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1027,10 +1027,10 @@ NS_IMETHODIMP nsAbOutlookDirectory::StartSearch(void)
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
nsCOMPtr<nsIAbDirectoryQueryResultListener> proxyListener;
|
||||
|
||||
retCode = NS_GetProxyForObject(NS_UI_THREAD_EVENTQ,
|
||||
retCode = NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsIAbDirectoryQueryResultListener),
|
||||
NS_STATIC_CAST(nsIAbDirectoryQueryResultListener *, new nsAbDirSearchListener(this)),
|
||||
PROXY_SYNC | PROXY_ALWAYS,
|
||||
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(proxyListener));
|
||||
NS_ENSURE_SUCCESS(retCode, retCode) ;
|
||||
|
||||
|
@ -48,8 +48,6 @@
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
|
||||
#include "nsString.h"
|
||||
@ -57,6 +55,7 @@
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
// this is used for notification of observers using nsVoidArray
|
||||
typedef struct _nsAbRDFNotification {
|
||||
@ -136,34 +135,21 @@ nsresult nsAbRDFDataSource::CreateProxyObserver (nsIRDFObserver* observer,
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> eventQSvc = do_GetService (NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Get the UI event queue
|
||||
nsCOMPtr<nsIEventQueue> uiQueue;
|
||||
rv = eventQSvc->GetSpecialEventQueue (
|
||||
nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
|
||||
getter_AddRefs (uiQueue));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyMgr =
|
||||
do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Proxy the observer on the UI queue
|
||||
// Proxy the observer on the UI thread
|
||||
/*
|
||||
* TODO
|
||||
* Currenly using PROXY_ASYNC, however
|
||||
* Currenly using NS_PROXY_ASYNC, however
|
||||
* this can flood the event queue if
|
||||
* rate of events on the observer is
|
||||
* greater that the time to process the
|
||||
* events.
|
||||
* This causes the UI to pause.
|
||||
*/
|
||||
rv = proxyMgr->GetProxyForObject (uiQueue,
|
||||
rv = NS_GetProxyForObject (
|
||||
NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsIRDFObserver),
|
||||
observer,
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
NS_PROXY_ASYNC | NS_PROXY_ALWAYS,
|
||||
(void** )proxyObserver);
|
||||
|
||||
return rv;
|
||||
@ -232,12 +218,6 @@ nsresult nsAbRDFDataSource::NotifyObservers(nsIRDFResource *subject,
|
||||
return NS_OK;
|
||||
|
||||
|
||||
// Get the current thread
|
||||
nsCOMPtr<nsIThread> currentThread;
|
||||
rv = nsIThread::GetCurrent (getter_AddRefs(currentThread));
|
||||
NS_ENSURE_SUCCESS (rv, rv);
|
||||
|
||||
// Get the main thread, which is the UI thread
|
||||
/*
|
||||
* TODO
|
||||
* Is the main thread always guaranteed to be
|
||||
@ -249,12 +229,8 @@ nsresult nsAbRDFDataSource::NotifyObservers(nsIRDFResource *subject,
|
||||
* RDF datasources that are not UI specific
|
||||
* but are used in the UI?
|
||||
*/
|
||||
nsCOMPtr<nsIThread> uiThread;
|
||||
rv = nsIThread::GetMainThread (getter_AddRefs(uiThread));
|
||||
NS_ENSURE_SUCCESS (rv, rv);
|
||||
|
||||
nsCOMPtr<nsISupportsArray> observers;
|
||||
if (currentThread == uiThread)
|
||||
if (NS_IsMainThread())
|
||||
{
|
||||
/*
|
||||
* Since this is the UI Thread use the
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsMsgUtils.h"
|
||||
@ -3619,12 +3620,9 @@ NS_IMETHODIMP nsAddrDatabase::AddListDirNode(nsIMdbRow * listRow)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIProxyObjectManager> proxyMgr =
|
||||
do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
NS_WITH_PROXIED_SERVICE(nsIRDFService, rdfService, kRDFServiceCID, NS_UI_THREAD_EVENTQ, &rv);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
NS_WITH_PROXIED_SERVICE(nsIRDFService, rdfService, kRDFServiceCID,
|
||||
NS_PROXY_TO_MAIN_THREAD, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> parentResource;
|
||||
@ -3637,8 +3635,11 @@ NS_IMETHODIMP nsAddrDatabase::AddListDirNode(nsIMdbRow * listRow)
|
||||
|
||||
rv = rdfService->GetResource(NS_ConvertUTF16toUTF8(parentURI), getter_AddRefs(parentResource));
|
||||
nsCOMPtr<nsIAbDirectory> parentDir;
|
||||
rv = proxyMgr->GetProxyForObject( NS_UI_THREAD_EVENTQ, NS_GET_IID( nsIAbDirectory),
|
||||
parentResource, PROXY_SYNC | PROXY_ALWAYS, getter_AddRefs( parentDir));
|
||||
rv = NS_GetProxyForObject( NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID( nsIAbDirectory),
|
||||
parentResource,
|
||||
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs( parentDir));
|
||||
if (parentDir)
|
||||
{
|
||||
m_dbDirectory = parentDir;
|
||||
|
@ -581,10 +581,10 @@ nsLDAPAutoCompleteSession::OnLDAPInit(nsILDAPConnection *aConn, nsresult aStatus
|
||||
|
||||
// get a proxy object so the callback happens on the main thread
|
||||
//
|
||||
rv = NS_GetProxyForObject(NS_UI_THREAD_EVENTQ,
|
||||
rv = NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsILDAPMessageListener),
|
||||
NS_STATIC_CAST(nsILDAPMessageListener *, this),
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
NS_PROXY_ASYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(selfProxy));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("nsLDAPAutoCompleteSession::OnLDAPInit(): couldn't "
|
||||
@ -866,10 +866,10 @@ nsLDAPAutoCompleteSession::StartLDAPSearch()
|
||||
|
||||
// get a proxy object so the callback happens on the main thread
|
||||
//
|
||||
rv = NS_GetProxyForObject(NS_UI_THREAD_EVENTQ,
|
||||
rv = NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsILDAPMessageListener),
|
||||
NS_STATIC_CAST(nsILDAPMessageListener *, this),
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
NS_PROXY_ASYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(selfProxy));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("nsLDAPAutoCompleteSession::StartLDAPSearch(): couldn't "
|
||||
@ -1170,10 +1170,10 @@ nsLDAPAutoCompleteSession::InitConnection()
|
||||
|
||||
// get a proxy object so the callback happens on the main thread
|
||||
//
|
||||
rv = NS_GetProxyForObject(NS_UI_THREAD_EVENTQ,
|
||||
rv = NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
|
||||
NS_GET_IID(nsILDAPMessageListener),
|
||||
NS_STATIC_CAST(nsILDAPMessageListener *, this),
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
NS_PROXY_ASYNC | NS_PROXY_ALWAYS,
|
||||
getter_AddRefs(selfProxy));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("nsLDAPAutoCompleteSession::InitConnection(): couldn't "
|
||||
|
@ -76,7 +76,6 @@
|
||||
#include "nsIMsgPurgeService.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIMsgMailSession.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsMsgFolderFlags.h"
|
||||
@ -94,6 +93,7 @@
|
||||
#include "nsIDBFolderInfo.h"
|
||||
#include "nsIMsgHdr.h"
|
||||
#include "nsILineInputStream.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsEscape.h"
|
||||
|
||||
@ -112,7 +112,6 @@
|
||||
|
||||
static NS_DEFINE_CID(kMsgAccountCID, NS_MSGACCOUNT_CID);
|
||||
static NS_DEFINE_CID(kMsgFolderCacheCID, NS_MSGFOLDERCACHE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
// use this to search for all servers with the given hostname/iid and
|
||||
// put them in "servers"
|
||||
@ -1052,12 +1051,6 @@ PRBool PR_CALLBACK nsMsgAccountManager::cleanupOnExit(nsHashKey *aKey, void *aDa
|
||||
nsCOMPtr<nsIMsgAccountManager> accountManager =
|
||||
do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(eventQueue));
|
||||
if (isImap)
|
||||
urlListener = do_QueryInterface(accountManager, &rv);
|
||||
|
||||
@ -1094,6 +1087,8 @@ PRBool PR_CALLBACK nsMsgAccountManager::cleanupOnExit(nsHashKey *aKey, void *aDa
|
||||
|
||||
if (isImap && urlListener)
|
||||
{
|
||||
nsIThread *thread = NS_GetCurrentThread();
|
||||
|
||||
PRBool inProgress = PR_FALSE;
|
||||
if (cleanupInboxOnExit)
|
||||
{
|
||||
@ -1104,8 +1099,7 @@ PRBool PR_CALLBACK nsMsgAccountManager::cleanupOnExit(nsHashKey *aKey, void *aDa
|
||||
PR_CEnterMonitor(folder);
|
||||
PR_CWait(folder, PR_MicrosecondsToInterval(1000UL));
|
||||
PR_CExitMonitor(folder);
|
||||
if (eventQueue)
|
||||
eventQueue->ProcessPendingEvents();
|
||||
NS_ProcessPendingEvents(thread);
|
||||
}
|
||||
}
|
||||
if (emptyTrashOnExit)
|
||||
@ -1117,8 +1111,7 @@ PRBool PR_CALLBACK nsMsgAccountManager::cleanupOnExit(nsHashKey *aKey, void *aDa
|
||||
PR_CEnterMonitor(folder);
|
||||
PR_CWait(folder, PR_MicrosecondsToInterval(1000UL));
|
||||
PR_CExitMonitor(folder);
|
||||
if (eventQueue)
|
||||
eventQueue->ProcessPendingEvents();
|
||||
NS_ProcessPendingEvents(thread);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,12 +69,8 @@
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
|
||||
// For PLEvents
|
||||
#include "plevent.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
// Interfaces Needed
|
||||
#include "nsIBaseWindow.h"
|
||||
@ -726,114 +722,61 @@ nsMsgPrintEngine::PrintMsgWindow()
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
//-- PLEvent Notification
|
||||
//-- Event Notification
|
||||
//---------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------
|
||||
class nsPrintMsgWindowEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsPrintMsgWindowEvent(nsMsgPrintEngine *mpe)
|
||||
: mMsgPrintEngine(mpe)
|
||||
{}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
if (mMsgPrintEngine)
|
||||
mMsgPrintEngine->PrintMsgWindow();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<nsMsgPrintEngine> mMsgPrintEngine;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------
|
||||
PRBool
|
||||
FireEvent(nsMsgPrintEngine* aMPE, PLHandleEventProc handler, PLDestroyEventProc destructor)
|
||||
class nsStartNextPrintOpEvent : public nsRunnable
|
||||
{
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
public:
|
||||
nsStartNextPrintOpEvent(nsMsgPrintEngine *mpe)
|
||||
: mMsgPrintEngine(mpe)
|
||||
{}
|
||||
|
||||
nsCOMPtr<nsIEventQueueService> event_service = do_GetService(kEventQueueServiceCID);
|
||||
|
||||
if (!event_service)
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
NS_WARNING("Failed to get event queue service");
|
||||
return PR_FALSE;
|
||||
if (mMsgPrintEngine)
|
||||
mMsgPrintEngine->StartNextPrintOperation();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEventQueue> event_queue;
|
||||
|
||||
event_service->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(event_queue));
|
||||
|
||||
if (!event_queue)
|
||||
{
|
||||
NS_WARNING("Failed to get event queue from service");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PLEvent *event = new PLEvent;
|
||||
|
||||
if (!event)
|
||||
{
|
||||
NS_WARNING("Out of memory?");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PL_InitEvent(event, aMPE, handler, destructor);
|
||||
|
||||
// The event owns the msgPrintEngine pointer now.
|
||||
NS_ADDREF(aMPE);
|
||||
|
||||
if (NS_FAILED(event_queue->PostEvent(event)))
|
||||
{
|
||||
NS_WARNING("Failed to post event");
|
||||
PL_DestroyEvent(event);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void*) HandlePLEventPrintMsgWindow(PLEvent* aEvent)
|
||||
{
|
||||
nsMsgPrintEngine *msgPrintEngine = (nsMsgPrintEngine*)PL_GetEventOwner(aEvent);
|
||||
|
||||
NS_ASSERTION(msgPrintEngine, "The event owner is null.");
|
||||
if (msgPrintEngine)
|
||||
{
|
||||
msgPrintEngine->PrintMsgWindow();
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
PR_STATIC_CALLBACK(void) DestroyPLEventPrintMsgWindow(PLEvent* aEvent)
|
||||
{
|
||||
nsMsgPrintEngine *msgPrintEngine = (nsMsgPrintEngine*)PL_GetEventOwner(aEvent);
|
||||
NS_IF_RELEASE(msgPrintEngine);
|
||||
|
||||
delete aEvent;
|
||||
}
|
||||
private:
|
||||
nsRefPtr<nsMsgPrintEngine> mMsgPrintEngine;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------
|
||||
PRBool
|
||||
nsMsgPrintEngine::FirePrintEvent()
|
||||
{
|
||||
return FireEvent(this, ::HandlePLEventPrintMsgWindow,
|
||||
::DestroyPLEventPrintMsgWindow);
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void*) HandlePLEventStartNext(PLEvent* aEvent)
|
||||
{
|
||||
nsMsgPrintEngine *msgPrintEngine = (nsMsgPrintEngine*)PL_GetEventOwner(aEvent);
|
||||
|
||||
NS_ASSERTION(msgPrintEngine, "The event owner is null.");
|
||||
if (msgPrintEngine)
|
||||
{
|
||||
msgPrintEngine->StartNextPrintOperation();
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
PR_STATIC_CALLBACK(void) DestroyPLEventStartNext(PLEvent* aEvent)
|
||||
{
|
||||
nsMsgPrintEngine *msgPrintEngine = (nsMsgPrintEngine*)PL_GetEventOwner(aEvent);
|
||||
NS_IF_RELEASE(msgPrintEngine);
|
||||
|
||||
delete aEvent;
|
||||
nsCOMPtr<nsIRunnable> event = new nsPrintMsgWindowEvent(this);
|
||||
return NS_DispatchToCurrentThread(event);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
PRBool
|
||||
nsMsgPrintEngine::FireStartNextEvent()
|
||||
{
|
||||
return FireEvent(this, ::HandlePLEventStartNext,
|
||||
::DestroyPLEventStartNext);
|
||||
nsCOMPtr<nsIRunnable> event = new nsStartNextPrintOpEvent(this);
|
||||
return NS_DispatchToCurrentThread(event);
|
||||
}
|
||||
|
||||
/* void setStartupPPObserver (in nsIObserver startupPPObs); */
|
||||
|
@ -45,10 +45,8 @@
|
||||
#include "nsIMsgFolder.h" // TO include biffState enum. Change to bool later...
|
||||
#include "nsMsgFolderFlags.h"
|
||||
#include "nsIMsgHdr.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIMsgImapMailFolder.h"
|
||||
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsImapMoveCoalescer, nsIUrlListener)
|
||||
|
||||
@ -287,14 +285,9 @@ NS_IMETHODIMP nsMoveCoalescerCopyListener::OnStopCopy(nsresult aStatus)
|
||||
nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr <nsIURI> url;
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
nsCOMPtr <nsIEventQueue> eventQueue;
|
||||
if (NS_SUCCEEDED(rv) && pEventQService)
|
||||
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(eventQueue));
|
||||
nsCOMPtr <nsIUrlListener> listener = do_QueryInterface(m_coalescer);
|
||||
rv = imapService->SelectFolder(eventQueue, m_destFolder, listener, nsnull, getter_AddRefs(url));
|
||||
nsIThread *thread = NS_GetCurrentThread();
|
||||
rv = imapService->SelectFolder(thread, m_destFolder, listener, nsnull, getter_AddRefs(url));
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
@ -59,7 +59,7 @@
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIProtocolProxyService.h"
|
||||
#include "nsIProxyInfo.h"
|
||||
#include "nsEventQueueUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
@ -142,10 +142,7 @@ nsMsgProtocol::OpenNetworkSocketWithInfo(const char * aHostName,
|
||||
strans->SetSecurityCallbacks(callbacks);
|
||||
|
||||
// creates cyclic reference!
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
NS_GetCurrentEventQ(getter_AddRefs(eventQ));
|
||||
if (eventQ)
|
||||
strans->SetEventSink(this, eventQ);
|
||||
strans->SetEventSink(this, NS_GetCurrentThread());
|
||||
|
||||
m_socketIsOpen = PR_FALSE;
|
||||
m_transport = strans;
|
||||
@ -1093,7 +1090,7 @@ public:
|
||||
|
||||
// try to write again...
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = aOutStream->AsyncWait(this, 0, 0, mMsgProtocol->mProviderEventQ);
|
||||
rv = aOutStream->AsyncWait(this, 0, 0, mMsgProtocol->mProviderThread);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv) || rv == NS_BINDING_ABORTED, "unexpected error writing stream");
|
||||
return NS_OK;
|
||||
@ -1192,7 +1189,7 @@ NS_IMETHODIMP nsMsgFilePostHelper::OnDataAvailable(nsIRequest * /* aChannel */,
|
||||
// things off again.
|
||||
mProtInstance->mSuspendedWrite = PR_FALSE;
|
||||
mProtInstance->mAsyncOutStream->AsyncWait(mProtInstance->mProvider, 0, 0,
|
||||
mProtInstance->mProviderEventQ);
|
||||
mProtInstance->mProviderThread);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -1459,7 +1456,7 @@ nsresult nsMsgAsyncWriteProtocol::SetupTransportState()
|
||||
PR_TRUE,
|
||||
PR_TRUE);
|
||||
|
||||
rv = NS_GetCurrentEventQ(getter_AddRefs(mProviderEventQ));
|
||||
rv = NS_GetCurrentThread(getter_AddRefs(mProviderThread));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsMsgProtocolStreamProvider *provider;
|
||||
@ -1477,7 +1474,7 @@ nsresult nsMsgAsyncWriteProtocol::SetupTransportState()
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// wait for the output stream to become writable
|
||||
rv = mAsyncOutStream->AsyncWait(mProvider, 0, 0, mProviderEventQ);
|
||||
rv = mAsyncOutStream->AsyncWait(mProvider, 0, 0, mProviderThread);
|
||||
} // if m_transport
|
||||
|
||||
return rv;
|
||||
@ -1499,7 +1496,7 @@ nsresult nsMsgAsyncWriteProtocol::CloseSocket()
|
||||
|
||||
mAsyncOutStream = 0;
|
||||
mProvider = 0;
|
||||
mProviderEventQ = 0;
|
||||
mProviderThread = 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -1541,7 +1538,7 @@ PRInt32 nsMsgAsyncWriteProtocol::SendData(nsIURI * aURL, const char * dataBuffer
|
||||
// data to write (i.e. the pipe went empty). So resume the channel to kick
|
||||
// things off again.
|
||||
mSuspendedWrite = PR_FALSE;
|
||||
mAsyncOutStream->AsyncWait(mProvider, 0, 0, mProviderEventQ);
|
||||
mAsyncOutStream->AsyncWait(mProvider, 0, 0, mProviderThread);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIFileSpec.h"
|
||||
@ -51,7 +52,6 @@
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsITransport.h"
|
||||
#include "nsIAsyncOutputStream.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIAuthModule.h"
|
||||
|
||||
#define UNKNOWN_ERROR 101
|
||||
@ -217,7 +217,7 @@ public:
|
||||
nsCOMPtr<nsIRequest> m_WriteRequest;
|
||||
nsCOMPtr<nsIAsyncOutputStream> mAsyncOutStream;
|
||||
nsCOMPtr<nsIOutputStreamCallback> mProvider;
|
||||
nsCOMPtr<nsIEventQueue> mProviderEventQ;
|
||||
nsCOMPtr<nsIThread> mProviderThread;
|
||||
|
||||
// because we are reading the post data in asychronously, it's possible that we aren't sending it
|
||||
// out fast enough and the reading gets blocked. The following set of state variables are used to
|
||||
|
@ -56,13 +56,12 @@
|
||||
#include "nsMsgCompUtils.h"
|
||||
#include "prcmon.h"
|
||||
#include "nsIMsgImapMailFolder.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsMsgSimulateError.h"
|
||||
#include "nsIMsgWindow.h"
|
||||
#include "nsIMsgProgress.h"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// This is the listener class for the copy operation. We have to create this class
|
||||
@ -282,7 +281,7 @@ nsMsgCopy::DoCopy(nsIFileSpec *aDiskFile, nsIMsgFolder *dstFolder,
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
copyListener->SetMsgComposeAndSendObject(aMsgSendObj);
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
nsIThread *thread = nsnull;
|
||||
|
||||
if (aIsDraft)
|
||||
{
|
||||
@ -299,11 +298,7 @@ nsMsgCopy::DoCopy(nsIFileSpec *aDiskFile, nsIMsgFolder *dstFolder,
|
||||
// set the following only when we were in the middle of shutdown
|
||||
// process
|
||||
copyListener->mCopyInProgress = PR_TRUE;
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(eventQueue));
|
||||
thread = NS_GetCurrentThread();
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv);
|
||||
@ -318,8 +313,8 @@ nsMsgCopy::DoCopy(nsIFileSpec *aDiskFile, nsIMsgFolder *dstFolder,
|
||||
PR_CEnterMonitor(copyListener);
|
||||
PR_CWait(copyListener, PR_MicrosecondsToInterval(1000UL));
|
||||
PR_CExitMonitor(copyListener);
|
||||
if (eventQueue)
|
||||
eventQueue->ProcessPendingEvents();
|
||||
if (thread)
|
||||
NS_ProcessPendingEvents(thread);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
|
@ -40,7 +40,7 @@
|
||||
interface nsIUrlListener;
|
||||
interface nsIURI;
|
||||
interface nsIImapUrl;
|
||||
interface nsIEventQueue;
|
||||
interface nsIEventTarget;
|
||||
interface nsIImapProtocol;
|
||||
interface nsISupportsArray;
|
||||
interface nsIMsgFolder;
|
||||
@ -56,7 +56,7 @@ interface nsMsgImapDeleteModels
|
||||
const long DeleteNoTrash = 2; /* delete is shift delete - don't create or use trash */
|
||||
};
|
||||
|
||||
[scriptable, uuid(a54c32c7-17ae-4733-b551-1725f15044f6)]
|
||||
[scriptable, uuid(5e8f307e-4432-4b5e-8f92-0b0ffc3ee594)]
|
||||
interface nsIImapIncomingServer : nsISupports {
|
||||
|
||||
attribute long maximumConnectionsNumber;
|
||||
@ -88,7 +88,7 @@ interface nsIImapIncomingServer : nsISupports {
|
||||
nsIMsgFolder getPFC(in boolean createIfMissing);
|
||||
attribute boolean downloadBodiesOnGetNewMail;
|
||||
attribute boolean autoSyncOfflineStores;
|
||||
void GetImapConnectionAndLoadUrl(in nsIEventQueue aClientEventQueue,
|
||||
void GetImapConnectionAndLoadUrl(in nsIEventTarget aClientEventTarget,
|
||||
in nsIImapUrl aImapUrl,
|
||||
in nsISupports aConsumer);
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
interface nsIUrlListener;
|
||||
interface nsIURI;
|
||||
interface nsIImapUrl;
|
||||
interface nsIEventQueue;
|
||||
interface nsIEventTarget;
|
||||
interface nsIImapProtocol;
|
||||
interface nsIImapIncomingServer;
|
||||
interface nsISupportsArray;
|
||||
@ -49,7 +49,7 @@ interface nsIMsgFolder;
|
||||
interface nsIImapHostSessionList;
|
||||
interface nsIMsgWindow;
|
||||
|
||||
[scriptable, uuid(0f660d51-e3f1-4f80-86b5-66fa31732f2b)]
|
||||
[scriptable, uuid(9410ec75-854c-4b0e-96f4-b485ffe1f0d4)]
|
||||
interface nsIImapProtocol : nsISupports {
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
/* LoadUrl should really be pushed into a generic protocol interface
|
||||
@ -79,7 +79,7 @@ interface nsIImapProtocol : nsISupports {
|
||||
// protocol data. The protocol also needs a host session list.
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
void Initialize(in nsIImapHostSessionList aHostSessionList, in nsIImapIncomingServer aServer,
|
||||
in nsIEventQueue aSinkEventQueue) ;
|
||||
in nsIEventTarget aSinkEventTarget) ;
|
||||
|
||||
void NotifyHdrsToDownload(out unsigned long keys, in unsigned long keyCount);
|
||||
void NotifyBodysToDownload(out unsigned long keys, in unsigned long count);
|
||||
|
@ -51,27 +51,27 @@ interface nsIImapProtocol;
|
||||
interface nsIImapMessageSink;
|
||||
interface nsIUrlListener;
|
||||
interface nsIURI;
|
||||
interface nsIEventQueue;
|
||||
interface nsIEventTarget;
|
||||
interface nsIMsgFolder;
|
||||
interface nsIMsgWindow;
|
||||
interface nsIImapIncomingServer;
|
||||
interface nsICacheSession;
|
||||
|
||||
|
||||
[scriptable, uuid(4032dc12-8684-4458-9b41-647034d8c7d2)]
|
||||
[scriptable, uuid(0819ca53-746b-4072-896a-87a452dc5a77)]
|
||||
interface nsIImapService : nsISupports
|
||||
{
|
||||
// As always, you can pass in null for the url listener and the url if you don't require either.....
|
||||
// aClientEventQueue is the event queue of the event sinks. We post events into this queue.
|
||||
// aClientEventTarget is the event queue of the event sinks. We post events into this queue.
|
||||
// mscott -- eventually this function will take in the account (identity/incoming server) associated with
|
||||
// the request
|
||||
void selectFolder(in nsIEventQueue aClientEventQueue,
|
||||
void selectFolder(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
in nsIMsgWindow aMsgWindow,
|
||||
out nsIURI aURL);
|
||||
|
||||
void liteSelectFolder(in nsIEventQueue aClientEventQueue,
|
||||
void liteSelectFolder(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
out nsIURI aURL);
|
||||
@ -87,52 +87,52 @@ interface nsIImapService : nsISupports
|
||||
in string additionalHeader,
|
||||
out nsIURI aOutURL);
|
||||
|
||||
void noop(in nsIEventQueue aClientEventQueue,
|
||||
void noop(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
out nsIURI aURL);
|
||||
|
||||
void getHeaders(in nsIEventQueue aClientEventQueue,
|
||||
void getHeaders(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
out nsIURI aURL,
|
||||
in string aMessageIdentifierList,
|
||||
in boolean aMessageIdsAreUID);
|
||||
|
||||
nsIURI getBodyStart(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI getBodyStart(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
in string aMessageIdentifierList,
|
||||
in long numBytes);
|
||||
|
||||
void expunge(in nsIEventQueue aClientEventQueue,
|
||||
void expunge(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
out nsIURI aURL);
|
||||
|
||||
nsIURI updateFolderStatus(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI updateFolderStatus(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener);
|
||||
|
||||
void biff(in nsIEventQueue aClientEventQueue,
|
||||
void biff(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
out nsIURI aURL,
|
||||
in unsigned long aUidHighWater);
|
||||
|
||||
void deleteMessages(in nsIEventQueue aClientEventQueue,
|
||||
void deleteMessages(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
out nsIURI aURL,
|
||||
in string aMessageIdentifierList,
|
||||
in boolean aMessageIdsAreUID);
|
||||
|
||||
void deleteAllMessages(in nsIEventQueue aClientEventQueue,
|
||||
void deleteAllMessages(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
out nsIURI aURL);
|
||||
|
||||
void addMessageFlags(in nsIEventQueue aClientEventQueue,
|
||||
void addMessageFlags(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
out nsIURI aURL,
|
||||
@ -140,7 +140,7 @@ interface nsIImapService : nsISupports
|
||||
in imapMessageFlagsType aFlags,
|
||||
in boolean aMessageIdsAreUID);
|
||||
|
||||
void subtractMessageFlags(in nsIEventQueue aClientEventQueue,
|
||||
void subtractMessageFlags(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
out nsIURI aURL,
|
||||
@ -148,7 +148,7 @@ interface nsIImapService : nsISupports
|
||||
in imapMessageFlagsType aFlags,
|
||||
in boolean aMessageIdsAreUID);
|
||||
|
||||
void setMessageFlags(in nsIEventQueue aClientEventQueue,
|
||||
void setMessageFlags(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
out nsIURI aURL,
|
||||
@ -156,23 +156,23 @@ interface nsIImapService : nsISupports
|
||||
in imapMessageFlagsType aFlags,
|
||||
in boolean aMessageIdsAreUID);
|
||||
|
||||
void discoverAllFolders(in nsIEventQueue aClientEventQueue,
|
||||
void discoverAllFolders(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
in nsIMsgWindow aMsgWindow,
|
||||
out nsIURI aURL);
|
||||
|
||||
void discoverAllAndSubscribedFolders(in nsIEventQueue aClientEventQueue,
|
||||
void discoverAllAndSubscribedFolders(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
out nsIURI aURL);
|
||||
void discoverChildren(in nsIEventQueue aClientEventQueue,
|
||||
void discoverChildren(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aImapMailFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
in string folderPath,
|
||||
out nsIURI aURL);
|
||||
|
||||
void onlineMessageCopy(in nsIEventQueue aClientEventQueue,
|
||||
void onlineMessageCopy(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aSrcFolder,
|
||||
in string aMessageIds,
|
||||
in nsIMsgFolder aDstFolder,
|
||||
@ -184,7 +184,7 @@ interface nsIImapService : nsISupports
|
||||
in nsIMsgWindow aWindow);
|
||||
|
||||
|
||||
void appendMessageFromFile(in nsIEventQueue aClientEventQueue,
|
||||
void appendMessageFromFile(in nsIEventTarget aClientEventTarget,
|
||||
in nsIFileSpec aFileSpec,
|
||||
in nsIMsgFolder aDstFolder,
|
||||
in string aMessageId,
|
||||
@ -198,37 +198,37 @@ interface nsIImapService : nsISupports
|
||||
void downloadMessagesForOffline(in string aMessageIds, in nsIMsgFolder aSrcFolder,
|
||||
in nsIUrlListener aListener, in nsIMsgWindow aMsgWindow);
|
||||
|
||||
nsIURI moveFolder(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI moveFolder(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aSrcFolder,
|
||||
in nsIMsgFolder aDstFolder,
|
||||
in nsIUrlListener aUrlListener,
|
||||
in nsIMsgWindow msgWindow);
|
||||
|
||||
nsIURI renameLeaf(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI renameLeaf(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aSrcFolder,
|
||||
in wstring aLeafName,
|
||||
in nsIUrlListener aUrlListener,
|
||||
in nsIMsgWindow msgWindow);
|
||||
|
||||
nsIURI deleteFolder(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI deleteFolder(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aFolder,
|
||||
in nsIUrlListener aUrlListener);
|
||||
|
||||
nsIURI createFolder(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI createFolder(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aParentFolder,
|
||||
in wstring aLeafName,
|
||||
in nsIUrlListener aUrlListener);
|
||||
|
||||
nsIURI listFolder(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI listFolder(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aMailFolder,
|
||||
in nsIUrlListener aUrlListener);
|
||||
|
||||
nsIURI subscribeFolder(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI subscribeFolder(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aMailFolder,
|
||||
in wstring mailboxName,
|
||||
in nsIUrlListener aUrlListener);
|
||||
|
||||
nsIURI unsubscribeFolder(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI unsubscribeFolder(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aMailFolder,
|
||||
in wstring mailboxName,
|
||||
in nsIUrlListener aUrlListener);
|
||||
@ -237,30 +237,30 @@ interface nsIImapService : nsISupports
|
||||
// not subscribed to, in which case it will subscribe to the folder.
|
||||
// otherwise, it will try to create the folder. It will try to do this
|
||||
// with one url.
|
||||
nsIURI ensureFolderExists(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI ensureFolderExists(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aParentFolder,
|
||||
in wstring aLeafName,
|
||||
in nsIUrlListener aUrlListener);
|
||||
|
||||
|
||||
nsIURI getFolderAdminUrl(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI getFolderAdminUrl(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aMailFolder,
|
||||
in nsIMsgWindow aMsgWindow,
|
||||
in nsIUrlListener aUrlListener);
|
||||
|
||||
nsIURI issueCommandOnMsgs(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI issueCommandOnMsgs(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aMailFolder,
|
||||
in nsIMsgWindow aMsgWindow,
|
||||
in string aCommand,
|
||||
in string aMessageIdentifierList);
|
||||
|
||||
nsIURI fetchCustomMsgAttribute(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI fetchCustomMsgAttribute(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aMailFolder,
|
||||
in nsIMsgWindow aMsgWindow,
|
||||
in string aAttribute,
|
||||
in string aMessageIdentifierList);
|
||||
|
||||
nsIURI storeCustomKeywords(in nsIEventQueue aClientEventQueue,
|
||||
nsIURI storeCustomKeywords(in nsIEventTarget aClientEventTarget,
|
||||
in nsIMsgFolder aMailFolder,
|
||||
in nsIMsgWindow aMsgWindow,
|
||||
in string flagsToAdd,
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include "nsIMsgIdentity.h"
|
||||
#include "nsIImapUrl.h"
|
||||
#include "nsIUrlListener.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsImapProtocol.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsVoidArray.h"
|
||||
@ -75,7 +75,6 @@
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIMsgMailNewsUrl.h"
|
||||
#include "nsIImapService.h"
|
||||
#include "nsMsgI18N.h"
|
||||
@ -100,7 +99,6 @@
|
||||
|
||||
static NS_DEFINE_CID(kImapProtocolCID, NS_IMAPPROTOCOL_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_CID(kImapServiceCID, NS_IMAPSERVICE_CID);
|
||||
static NS_DEFINE_CID(kSubscribableServerCID, NS_SUBSCRIBABLESERVER_CID);
|
||||
static NS_DEFINE_CID(kCImapHostSessionListCID, NS_IIMAPHOSTSESSIONLIST_CID);
|
||||
@ -430,14 +428,14 @@ nsImapIncomingServer::SetIsAOLServer(PRBool aBool)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapIncomingServer::GetImapConnectionAndLoadUrl(nsIEventQueue * aClientEventQueue,
|
||||
nsImapIncomingServer::GetImapConnectionAndLoadUrl(nsIEventTarget * aClientEventTarget,
|
||||
nsIImapUrl* aImapUrl,
|
||||
nsISupports* aConsumer)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr <nsIImapProtocol> aProtocol;
|
||||
|
||||
rv = GetImapConnection(aClientEventQueue, aImapUrl, getter_AddRefs(aProtocol));
|
||||
rv = GetImapConnection(aClientEventTarget, aImapUrl, getter_AddRefs(aProtocol));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(aImapUrl, &rv);
|
||||
@ -476,16 +474,10 @@ NS_IMETHODIMP
|
||||
nsImapIncomingServer::RetryUrl(nsIImapUrl *aImapUrl)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIEventQueue> aEventQueue;
|
||||
// Get current thread envent queue
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pEventQService)
|
||||
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(aEventQueue));
|
||||
nsCOMPtr <nsIImapProtocol> protocolInstance;
|
||||
nsImapProtocol::LogImapUrl("creating protocol instance to retry queued url", aImapUrl);
|
||||
rv = GetImapConnection(aEventQueue, aImapUrl, getter_AddRefs(protocolInstance));
|
||||
rv = GetImapConnection(NS_GetCurrentThread(), aImapUrl, getter_AddRefs(protocolInstance));
|
||||
if (NS_SUCCEEDED(rv) && protocolInstance)
|
||||
{
|
||||
nsCOMPtr<nsIURI> url = do_QueryInterface(aImapUrl, &rv);
|
||||
@ -691,7 +683,7 @@ nsImapIncomingServer::ConnectionTimeOut(nsIImapProtocol* aConnection)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsImapIncomingServer::GetImapConnection(nsIEventQueue *aEventQueue,
|
||||
nsImapIncomingServer::GetImapConnection(nsIEventTarget *aEventTarget,
|
||||
nsIImapUrl * aImapUrl,
|
||||
nsIImapProtocol ** aImapConnection)
|
||||
{
|
||||
@ -853,10 +845,10 @@ nsImapIncomingServer::GetImapConnection(nsIEventQueue *aEventQueue,
|
||||
// (e.g., a folder delete or msg append) but we shouldn't create new connections
|
||||
// for these types of urls if we have a free connection. So we check the actual
|
||||
// required state here.
|
||||
else if (cnt < ((PRUint32)maxConnections) && aEventQueue
|
||||
else if (cnt < ((PRUint32)maxConnections) && aEventTarget
|
||||
&& (!freeConnection || requiredState == nsIImapUrl::nsImapSelectedState))
|
||||
{
|
||||
rv = CreateProtocolInstance(aEventQueue, aImapConnection);
|
||||
rv = CreateProtocolInstance(aEventTarget, aImapConnection);
|
||||
}
|
||||
else if (freeConnection)
|
||||
{
|
||||
@ -876,7 +868,7 @@ nsImapIncomingServer::GetImapConnection(nsIEventQueue *aEventQueue,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsImapIncomingServer::CreateProtocolInstance(nsIEventQueue *aEventQueue,
|
||||
nsImapIncomingServer::CreateProtocolInstance(nsIEventTarget *aEventTarget,
|
||||
nsIImapProtocol ** aImapConnection)
|
||||
{
|
||||
// create a new connection and add it to the connection cache
|
||||
@ -899,7 +891,7 @@ nsImapIncomingServer::CreateProtocolInstance(nsIEventQueue *aEventQueue,
|
||||
nsCOMPtr<nsIImapHostSessionList> hostSession =
|
||||
do_GetService(kCImapHostSessionListCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = protocolInstance->Initialize(hostSession, this, aEventQueue);
|
||||
rv = protocolInstance->Initialize(hostSession, this, aEventTarget);
|
||||
}
|
||||
|
||||
// take the protocol instance and add it to the connectionCache
|
||||
@ -1003,16 +995,8 @@ nsImapIncomingServer::PerformExpand(nsIMsgWindow *aMsgWindow)
|
||||
nsCOMPtr<nsIImapService> imapService = do_GetService(kImapServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!imapService) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIEventQueue> queue;
|
||||
// get the Event Queue for this thread...
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!pEventQService) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(queue));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = imapService->DiscoverAllFolders(queue, rootMsgFolder, this, aMsgWindow, nsnull);
|
||||
rv = imapService->DiscoverAllFolders(NS_GetCurrentThread(), rootMsgFolder,
|
||||
this, aMsgWindow, nsnull);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -2569,19 +2553,13 @@ NS_IMETHODIMP nsImapIncomingServer::OnLogonRedirectionError(const PRUnichar *pEr
|
||||
if (urlQueueCnt > 0)
|
||||
{
|
||||
nsCOMPtr <nsIImapProtocol> imapProtocol;
|
||||
nsCOMPtr <nsIEventQueue> aEventQueue;
|
||||
// Get current thread envent queue
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pEventQService)
|
||||
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(aEventQueue));
|
||||
|
||||
if (aImapUrl)
|
||||
{
|
||||
nsCOMPtr <nsIImapProtocol> protocolInstance ;
|
||||
m_waitingForConnectionInfo = PR_FALSE;
|
||||
rv = GetImapConnection(aEventQueue, aImapUrl, getter_AddRefs(protocolInstance));
|
||||
rv = GetImapConnection(NS_GetCurrentThread(), aImapUrl,
|
||||
getter_AddRefs(protocolInstance));
|
||||
// If users cancel the login then we need to reset url state.
|
||||
if (rv == NS_BINDING_ABORTED)
|
||||
resetUrlState = PR_TRUE;
|
||||
@ -2623,14 +2601,7 @@ NS_IMETHODIMP nsImapIncomingServer::OnLogonRedirectionReply(const PRUnichar *pHo
|
||||
PRBool urlRun = PR_FALSE;
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsIImapProtocol> imapProtocol;
|
||||
nsCOMPtr <nsIEventQueue> aEventQueue;
|
||||
nsCAutoString cookie(pCookieData, pCookieSize);
|
||||
// Get current thread envent queue
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && pEventQService)
|
||||
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(aEventQueue));
|
||||
// we used to logoff the external requestor...we no longer need to do
|
||||
// that.
|
||||
|
||||
@ -2648,7 +2619,8 @@ NS_IMETHODIMP nsImapIncomingServer::OnLogonRedirectionReply(const PRUnichar *pHo
|
||||
nsCOMPtr<nsISupports> aConsumer = (nsISupports*)m_urlConsumers.ElementAt(0);
|
||||
|
||||
nsCOMPtr <nsIImapProtocol> protocolInstance ;
|
||||
rv = GetImapConnection(aEventQueue, aImapUrl, getter_AddRefs(protocolInstance));
|
||||
rv = GetImapConnection(NS_GetCurrentThread(), aImapUrl,
|
||||
getter_AddRefs(protocolInstance));
|
||||
m_waitingForConnectionInfo = PR_FALSE;
|
||||
if (NS_SUCCEEDED(rv) && protocolInstance)
|
||||
{
|
||||
@ -2950,23 +2922,16 @@ nsImapIncomingServer::SubscribeToFolder(const PRUnichar *aName, PRBool subscribe
|
||||
rv = rootMsgFolder->FindSubFolder(folderCName, getter_AddRefs(msgFolder));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEventQueue> queue;
|
||||
// get the Event Queue for this thread...
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService =
|
||||
do_GetService(kEventQueueServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(queue));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsIThread *thread = NS_GetCurrentThread();
|
||||
|
||||
nsAutoString unicodeName;
|
||||
rv = CopyMUTF7toUTF16(folderCName, unicodeName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (subscribe)
|
||||
rv = imapService->SubscribeFolder(queue, msgFolder, unicodeName.get(), nsnull, aUri);
|
||||
rv = imapService->SubscribeFolder(thread, msgFolder, unicodeName.get(), nsnull, aUri);
|
||||
else
|
||||
rv = imapService->UnsubscribeFolder(queue, msgFolder, unicodeName.get(), nsnull, nsnull);
|
||||
rv = imapService->UnsubscribeFolder(thread, msgFolder, unicodeName.get(), nsnull, nsnull);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return NS_OK;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user