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

Unified Diff: src/ConsoleJsObject.cpp

Issue 29543810: Issue 5118 - Lock the platform interfaces before use (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Added missing LogSystem Created Sept. 13, 2017, 5:46 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
Index: src/ConsoleJsObject.cpp
===================================================================
--- a/src/ConsoleJsObject.cpp
+++ b/src/ConsoleJsObject.cpp
@@ -41,18 +41,21 @@
message << converted[i].AsString();
}
std::stringstream source;
v8::Local<v8::StackFrame> frame = v8::StackTrace::CurrentStackTrace(arguments.GetIsolate(), 1)->GetFrame(0);
source << AdblockPlus::Utils::FromV8String(frame->GetScriptName());
source << ":" << frame->GetLineNumber();
- AdblockPlus::LogSystem& callback = jsEngine->GetPlatform().GetLogSystem();
- callback(logLevel, message.str(), source.str());
+ jsEngine->GetPlatform().WithLogSystem(
+ [logLevel, &message, &source](AdblockPlus::LogSystem& callback)
+ {
+ callback(logLevel, message.str(), source.str());
+ });
}
void LogCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments)
{
return DoLog(AdblockPlus::LogSystem::LOG_LEVEL_LOG, arguments);
}
void DebugCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments)
@@ -93,18 +96,21 @@
else
traceback << "/* anonymous */";
traceback << "() at ";
traceback << AdblockPlus::Utils::FromV8String(frame->GetScriptName());
traceback << ":" << frame->GetLineNumber();
traceback << std::endl;
}
- AdblockPlus::LogSystem& callback = jsEngine->GetPlatform().GetLogSystem();
- callback(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, traceback.str(), "");
+ jsEngine->GetPlatform().WithLogSystem(
+ [&traceback](AdblockPlus::LogSystem& callback)
+ {
+ callback(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, traceback.str(), "");
+ });
}
}
AdblockPlus::JsValue& AdblockPlus::ConsoleJsObject::Setup(
AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValue& obj)
{
obj.SetProperty("log", jsEngine.NewCallback(::LogCallback));
obj.SetProperty("debug", jsEngine.NewCallback(::DebugCallback));

Powered by Google App Engine
This is Rietveld