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

Unified Diff: src/GlobalJsObject.cpp

Issue 10173031: Don`t use references to JsEngine to avoid use-after-free errors,switch to shared_ptr instead (Closed)
Patch Set: Created April 18, 2013, 4:15 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/GlobalJsObject.h ('k') | src/JsEngine.cpp » ('j') | src/JsEngine.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/GlobalJsObject.cpp
===================================================================
--- a/src/GlobalJsObject.cpp
+++ b/src/GlobalJsObject.cpp
@@ -1,12 +1,11 @@
#include <vector>
#include <stdexcept>
-#include <AdblockPlus/JsEngine.h>
#include <AdblockPlus/JsValue.h>
#include "AppInfoJsObject.h"
#include "ConsoleJsObject.h"
#include "FileSystemJsObject.h"
#include "GlobalJsObject.h"
#include "ConsoleJsObject.h"
#include "WebRequestJsObject.h"
@@ -49,38 +48,38 @@ namespace
v8::Handle<v8::Value> SetTimeoutCallback(const v8::Arguments& arguments)
{
TimeoutThread* timeoutThread;
try
{
AdblockPlus::JsValueList converted =
AdblockPlus::JsEngine::FromArguments(arguments)
- .ConvertArguments(arguments);
+ ->ConvertArguments(arguments);
timeoutThread = new TimeoutThread(converted);
}
catch (const std::exception& e)
{
return v8::ThrowException(v8::String::New(e.what()));
}
timeoutThread->Start();
// We should actually return the timer ID here, which could be
// used via clearTimeout(). But since we don't seem to need
// clearTimeout(), we can save that for later.
return v8::Undefined();
}
}
-JsValuePtr GlobalJsObject::Setup(JsEngine& jsEngine, const AppInfo& appInfo,
+JsValuePtr GlobalJsObject::Setup(JsEnginePtr jsEngine, const AppInfo& appInfo,
JsValuePtr obj)
{
- obj->SetProperty("setTimeout", jsEngine.NewCallback(::SetTimeoutCallback));
+ obj->SetProperty("setTimeout", jsEngine->NewCallback(::SetTimeoutCallback));
obj->SetProperty("_fileSystem",
- FileSystemJsObject::Setup(jsEngine, jsEngine.NewObject()));
+ FileSystemJsObject::Setup(jsEngine, jsEngine->NewObject()));
obj->SetProperty("_webRequest",
- WebRequestJsObject::Setup(jsEngine, jsEngine.NewObject()));
+ WebRequestJsObject::Setup(jsEngine, jsEngine->NewObject()));
obj->SetProperty("console",
- ConsoleJsObject::Setup(jsEngine, jsEngine.NewObject()));
+ ConsoleJsObject::Setup(jsEngine, jsEngine->NewObject()));
obj->SetProperty("_appInfo",
- AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine.NewObject()));
+ AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine->NewObject()));
return obj;
}
« no previous file with comments | « src/GlobalJsObject.h ('k') | src/JsEngine.cpp » ('j') | src/JsEngine.cpp » ('J')

Powered by Google App Engine
This is Rietveld