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

Unified Diff: src/JsEngine.cpp

Issue 29813591: Issue 6526 - Use Maybe<> version of soon to be deprecated API in v8 6.7 (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Rebased Created Aug. 6, 2018, 7:30 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 | « no previous file | src/JsValue.cpp » ('j') | src/JsValue.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/JsEngine.cpp
===================================================================
--- a/src/JsEngine.cpp
+++ b/src/JsEngine.cpp
@@ -125,22 +125,25 @@
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;
+
+ int64_t millis = CHECKED_TO_VALUE(
+ arguments[1]->IntegerValue(arguments.GetIsolate()->GetCurrentContext()));
+
jsEngine->platform.WithTimer(
- [arguments, weakJsEngine, timerParamsID](ITimer& timer)
+ [millis, weakJsEngine, timerParamsID](ITimer& timer)
{
timer.SetTimer(
- std::chrono::milliseconds(
- arguments[1]->IntegerValue()), [weakJsEngine, timerParamsID]
+ std::chrono::milliseconds(millis), [weakJsEngine, timerParamsID]
{
if (auto jsEngine = weakJsEngine.lock())
jsEngine->CallTimerTask(timerParamsID);
});
});
}
void JsEngine::CallTimerTask(const JsWeakValuesID& timerParamsID)
@@ -259,24 +262,25 @@
const JsContext context(*this);
return JsValue(shared_from_this(), v8::Object::New(GetIsolate()));
}
AdblockPlus::JsValue AdblockPlus::JsEngine::NewCallback(
const v8::FunctionCallback& callback)
{
const JsContext context(*this);
-
+ auto isolate = GetIsolate();
// Note: we are leaking this weak pointer, no obvious way to destroy it when
// it's no longer used
std::weak_ptr<JsEngine>* data =
new std::weak_ptr<JsEngine>(shared_from_this());
- v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(GetIsolate(), callback,
- v8::External::New(GetIsolate(), data));
- return JsValue(shared_from_this(), templ->GetFunction());
+ v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, callback,
+ v8::External::New(isolate, data));
+ return JsValue(shared_from_this(),
+ CHECKED_TO_LOCAL(isolate, templ->GetFunction(isolate->GetCurrentContext())));
}
AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::FromArguments(const v8::FunctionCallbackInfo<v8::Value>& arguments)
{
const v8::Local<const v8::External> external =
v8::Local<const v8::External>::Cast(arguments.Data());
std::weak_ptr<JsEngine>* data =
static_cast<std::weak_ptr<JsEngine>*>(external->Value());
« no previous file with comments | « no previous file | src/JsValue.cpp » ('j') | src/JsValue.cpp » ('J')

Powered by Google App Engine
This is Rietveld