Bug 1297472 - Improve nsIScriptTimeoutHandler::GetHandlerText(), r=bz

This commit is contained in:
Andrea Marchesini 2016-09-05 21:25:13 +02:00
Родитель 60d03b201e
Коммит 1738225353
4 изменённых файлов: 8 добавлений и 10 удалений

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

@ -12218,8 +12218,7 @@ nsGlobalWindow::RunTimeoutHandler(nsTimeout* aTimeout,
RefPtr<Function> callback = handler->GetCallback();
if (!callback) {
// Evaluate the timeout expression.
nsAutoString script;
handler->GetHandlerText(script);
const nsAString& script = handler->GetHandlerText();
const char* filename = nullptr;
uint32_t lineNo = 0, dummyColumn = 0;

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

@ -34,7 +34,7 @@ public:
virtual mozilla::dom::Function *GetCallback() = 0;
// Get the handler text of not a compiled object.
virtual void GetHandlerText(nsAString& aString) = 0;
virtual const nsAString& GetHandlerText() = 0;
// Get the location of the script.
// Note: The memory pointed to by aFileName is owned by the

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

@ -50,7 +50,7 @@ public:
nsJSScriptTimeoutHandler(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
const nsAString& aExpression);
virtual void GetHandlerText(nsAString& aString) override;
virtual const nsAString& GetHandlerText() override;
virtual Function* GetCallback() override
{
return mFunction;
@ -308,11 +308,11 @@ nsJSScriptTimeoutHandler::ReleaseJSObjects()
}
}
void
nsJSScriptTimeoutHandler::GetHandlerText(nsAString& aString)
const nsAString&
nsJSScriptTimeoutHandler::GetHandlerText()
{
NS_ASSERTION(!mFunction, "No expression, so no handler text!");
aString = mExpr;
return mExpr;
}
already_AddRefed<nsIScriptTimeoutHandler>

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

@ -5920,8 +5920,7 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
AutoEntryScript aes(global, reason, false);
// Evaluate the timeout expression.
nsAutoString script;
info->mHandler->GetHandlerText(script);
const nsAString& script = info->mHandler->GetHandlerText();
const char* filename = nullptr;
uint32_t lineNo = 0, dummyColumn = 0;
@ -5932,7 +5931,7 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
JS::Rooted<JS::Value> unused(aes.cx());
if (!JS::Evaluate(aes.cx(), options, script.get(),
if (!JS::Evaluate(aes.cx(), options, script.BeginReading(),
script.Length(), &unused) &&
!JS_IsExceptionPending(aCx)) {
retval = false;