Bug 364692: Process pending script requests asynchronously when the last blocker is removed. r/sr=jst

This commit is contained in:
cvshook%sicking.cc 2007-01-09 01:07:29 +00:00
Родитель c636130624
Коммит d0c8e1ee3b
2 изменённых файлов: 29 добавлений и 3 удалений

Просмотреть файл

@ -68,6 +68,7 @@
#include "nsIXPConnect.h"
#include "nsContentErrors.h"
#include "nsIParser.h"
#include "nsThreadUtils.h"
//////////////////////////////////////////////////////////////
//
@ -639,6 +640,17 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
return rv;
}
void
nsScriptLoader::ProcessPendingRequestsAsync()
{
if (mPendingRequests.Count()) {
nsCOMPtr<nsIRunnable> ev = new nsRunnableMethod<nsScriptLoader>(this,
&nsScriptLoader::ProcessPendingRequests);
NS_DispatchToCurrentThread(ev);
}
}
void
nsScriptLoader::ProcessPendingRequests()
{

Просмотреть файл

@ -136,6 +136,9 @@ public:
}
void SetEnabled(PRBool aEnabled)
{
if (!mEnabled && aEnabled) {
ProcessPendingRequestsAsync();
}
mEnabled = aEnabled;
}
@ -153,7 +156,7 @@ public:
void RemoveExecuteBlocker()
{
if (!--mBlockerCount) {
ProcessPendingRequests();
ProcessPendingRequestsAsync();
}
}
@ -173,10 +176,22 @@ public:
const nsString& aHintCharset,
nsIDocument* aDocument, nsString& aString);
/**
* Processes any pending requests that are ready for processing.
*/
void ProcessPendingRequests();
protected:
/**
* Process any pending requests asyncronously (i.e. off an event) if there
* are any. Note that this is a no-op if there aren't any currently pending
* requests.
*/
void ProcessPendingRequestsAsync();
PRBool ReadyToExecuteScripts()
{
return !mBlockerCount;
return mEnabled && !mBlockerCount;
}
nsresult ProcessRequest(nsScriptLoadRequest* aRequest);
@ -186,7 +201,6 @@ protected:
nsScriptLoadRequest* aRequest);
nsresult EvaluateScript(nsScriptLoadRequest* aRequest,
const nsAFlatString& aScript);
void ProcessPendingRequests();
nsresult PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
nsIStreamLoader* aLoader,