Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/JsEngine.cpp

Issue 29543810: Issue 5118 - Lock the platform interfaces before use (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Last details Created Sept. 13, 2017, 8:17 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/FileSystemJsObject.cpp ('k') | src/Platform.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/JsEngine.cpp
===================================================================
--- a/src/JsEngine.cpp
+++ b/src/JsEngine.cpp
@@ -126,21 +126,27 @@
if (!arguments[0]->IsFunction())
throw std::runtime_error("First argument to setTimeout must be a function");
auto jsValueArguments = jsEngine->ConvertArguments(arguments);
auto timerParamsID = jsEngine->StoreJsValues(jsValueArguments);
std::weak_ptr<JsEngine> weakJsEngine = jsEngine;
- jsEngine->platform.GetTimer().SetTimer(std::chrono::milliseconds(arguments[1]->IntegerValue()), [weakJsEngine, timerParamsID]
- {
- if (auto jsEngine = weakJsEngine.lock())
- jsEngine->CallTimerTask(timerParamsID);
- });
+ jsEngine->platform.WithTimer(
+ [arguments, weakJsEngine, timerParamsID](ITimer& timer)
+ {
+ timer.SetTimer(
+ std::chrono::milliseconds(
+ arguments[1]->IntegerValue()), [weakJsEngine, timerParamsID]
+ {
+ if (auto jsEngine = weakJsEngine.lock())
+ jsEngine->CallTimerTask(timerParamsID);
+ });
+ });
}
void JsEngine::CallTimerTask(const JsWeakValuesID& timerParamsID)
{
auto timerParams = TakeJsValues(timerParamsID);
JsValue callback = std::move(timerParams[0]);
timerParams.erase(timerParams.begin()); // remove callback placeholder
« no previous file with comments | « src/FileSystemJsObject.cpp ('k') | src/Platform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld