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: 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 | « include/AdblockPlus/Platform.h ('k') | src/FileSystemJsObject.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « include/AdblockPlus/Platform.h ('k') | src/FileSystemJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld