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

Unified Diff: src/FileSystemJsObject.cpp

Issue 29361562: Issue 3594 - remove circular references JsEngine-JsValue-JsEngine (Closed)
Patch Set: address comments Created Nov. 25, 2016, 12:02 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/FileSystemJsObject.cpp
diff --git a/src/FileSystemJsObject.cpp b/src/FileSystemJsObject.cpp
index fffa32f1e74c61a21992bd60c60dc91952d1c76a..8b8be6e432488c94d4734bf7cd4e2a4b7cc7c513 100644
--- a/src/FileSystemJsObject.cpp
+++ b/src/FileSystemJsObject.cpp
@@ -34,13 +34,15 @@ namespace
{
public:
IoThread(JsEnginePtr jsEngine, JsValuePtr callback)
- : Thread(true), jsEngine(jsEngine), fileSystem(jsEngine->GetFileSystem()),
- callback(callback)
+ : Thread(true)
+ , m_jsEngine(jsEngine)
+ , fileSystem(jsEngine->GetFileSystem())
+ , callback(callback)
{
}
protected:
- JsEnginePtr jsEngine;
+ std::weak_ptr<JsEngine> m_jsEngine;
FileSystemPtr fileSystem;
JsValuePtr callback;
};
@@ -72,8 +74,8 @@ namespace
error = "Unknown error while reading from " + path;
}
- const JsContext context(jsEngine);
- JsValuePtr result = jsEngine->NewObject();
+ JsContext context(m_jsEngine);
+ JsValuePtr result = context.GetJsEngine().NewObject();
result->SetProperty("content", content);
result->SetProperty("error", error);
JsValueList params;
@@ -112,8 +114,8 @@ namespace
error = "Unknown error while writing to " + path;
}
- const JsContext context(jsEngine);
- JsValuePtr errorValue = jsEngine->NewValue(error);
+ JsContext context(m_jsEngine);
+ JsValuePtr errorValue = context.GetJsEngine().NewValue(error);
JsValueList params;
params.push_back(errorValue);
callback->Call(params);
@@ -149,8 +151,8 @@ namespace
error = "Unknown error while moving " + fromPath + " to " + toPath;
}
- const JsContext context(jsEngine);
- JsValuePtr errorValue = jsEngine->NewValue(error);
+ JsContext context(m_jsEngine);
+ JsValuePtr errorValue = context.GetJsEngine().NewValue(error);
JsValueList params;
params.push_back(errorValue);
callback->Call(params);
@@ -186,8 +188,8 @@ namespace
error = "Unknown error while removing " + path;
}
- const JsContext context(jsEngine);
- JsValuePtr errorValue = jsEngine->NewValue(error);
+ JsContext context(m_jsEngine);
+ JsValuePtr errorValue = context.GetJsEngine().NewValue(error);
JsValueList params;
params.push_back(errorValue);
callback->Call(params);
@@ -224,8 +226,8 @@ namespace
error = "Unknown error while calling stat on " + path;
}
- const JsContext context(jsEngine);
- JsValuePtr result = jsEngine->NewObject();
+ JsContext context(m_jsEngine);
+ JsValuePtr result = context.GetJsEngine().NewObject();
result->SetProperty("exists", statResult.exists);
result->SetProperty("isFile", statResult.isFile);
result->SetProperty("isDirectory", statResult.isDirectory);
« no previous file with comments | « include/AdblockPlus/JsValue.h ('k') | src/FilterEngine.cpp » ('j') | src/JsValue.cpp » ('J')

Powered by Google App Engine
This is Rietveld