Backed out changeset 38722eed8c8a (bug 1355746)
MozReview-Commit-ID: 1HcpK10x0V4
This commit is contained in:
@@ -33,7 +33,6 @@
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsIViewSourceChannel.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "mozilla/IdleTaskRunner.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@@ -62,7 +61,7 @@ class nsHtml5ExecutorReflusher : public Runnable
|
||||
};
|
||||
|
||||
static mozilla::LinkedList<nsHtml5TreeOpExecutor>* gBackgroundFlushList = nullptr;
|
||||
StaticRefPtr<IdleTaskRunner> gBackgroundFlushRunner;
|
||||
static nsITimer* gFlushTimer = nullptr;
|
||||
|
||||
nsHtml5TreeOpExecutor::nsHtml5TreeOpExecutor()
|
||||
: nsHtml5DocumentBuilder(false)
|
||||
@@ -86,9 +85,9 @@ nsHtml5TreeOpExecutor::~nsHtml5TreeOpExecutor()
|
||||
if (gBackgroundFlushList->isEmpty()) {
|
||||
delete gBackgroundFlushList;
|
||||
gBackgroundFlushList = nullptr;
|
||||
if (gBackgroundFlushRunner) {
|
||||
gBackgroundFlushRunner->Cancel();
|
||||
gBackgroundFlushRunner = nullptr;
|
||||
if (gFlushTimer) {
|
||||
gFlushTimer->Cancel();
|
||||
NS_RELEASE(gFlushTimer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,10 +245,9 @@ nsHtml5TreeOpExecutor::MarkAsBroken(nsresult aReason)
|
||||
return aReason;
|
||||
}
|
||||
|
||||
static bool
|
||||
BackgroundFlushCallback(TimeStamp /*aDeadline*/)
|
||||
void
|
||||
FlushTimerCallback(nsITimer* aTimer, void* aClosure)
|
||||
{
|
||||
NS_WARNING("Executing BackgroundFlushCallback()....");
|
||||
RefPtr<nsHtml5TreeOpExecutor> ex = gBackgroundFlushList->popFirst();
|
||||
if (ex) {
|
||||
ex->RunFlushLoop();
|
||||
@@ -257,11 +255,9 @@ BackgroundFlushCallback(TimeStamp /*aDeadline*/)
|
||||
if (gBackgroundFlushList && gBackgroundFlushList->isEmpty()) {
|
||||
delete gBackgroundFlushList;
|
||||
gBackgroundFlushList = nullptr;
|
||||
gBackgroundFlushRunner->Cancel();
|
||||
gBackgroundFlushRunner = nullptr;
|
||||
return true;
|
||||
gFlushTimer->Cancel();
|
||||
NS_RELEASE(gFlushTimer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -281,17 +277,16 @@ nsHtml5TreeOpExecutor::ContinueInterruptedParsingAsync()
|
||||
if (!isInList()) {
|
||||
gBackgroundFlushList->insertBack(this);
|
||||
}
|
||||
if (gBackgroundFlushRunner) {
|
||||
NS_WARNING("We've already scheduled a task for background list flush.");
|
||||
return;
|
||||
if (!gFlushTimer) {
|
||||
nsCOMPtr<nsITimer> t = do_CreateInstance("@mozilla.org/timer;1");
|
||||
t.swap(gFlushTimer);
|
||||
// The timer value 50 should not hopefully slow down background pages too
|
||||
// much, yet lets event loop to process enough between ticks.
|
||||
// See bug 734015.
|
||||
gFlushTimer->InitWithNamedFuncCallback(FlushTimerCallback, nullptr,
|
||||
50, nsITimer::TYPE_REPEATING_SLACK,
|
||||
"FlushTimerCallback");
|
||||
}
|
||||
// Now we set up a repetitive idle scheduler for flushing background list.
|
||||
gBackgroundFlushRunner =
|
||||
IdleTaskRunner::Create(&BackgroundFlushCallback,
|
||||
250, // The hard deadline: 250ms.
|
||||
nsContentSink::sInteractiveTime / 1000, // Required budget.
|
||||
true, // repeating
|
||||
[]{ return false; }); // MaybeContinueProcess
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user