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: Created Nov. 3, 2016, 11:26 a.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 2ed1fd55a663692a5fa7097f90cc3396b3ac9e18..6c90e2320fc62274a34ff0cb14082ed9d81568d5 100644
--- a/src/FileSystemJsObject.cpp
+++ b/src/FileSystemJsObject.cpp
@@ -35,13 +35,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;
};
@@ -73,8 +75,8 @@ namespace
error = "Unknown error while reading from " + path;
}
- const JsContext context(jsEngine);
- JsValuePtr result = jsEngine->NewObject();
+ JsContext context(m_jsEngine);
+ JsValuePtr result = context.jsEngine().NewObject();
result->SetProperty("content", content);
result->SetProperty("error", error);
JsValueList params;
@@ -113,8 +115,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.jsEngine().NewValue(error);
JsValueList params;
params.push_back(errorValue);
callback->Call(params);
@@ -150,8 +152,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.jsEngine().NewValue(error);
JsValueList params;
params.push_back(errorValue);
callback->Call(params);
@@ -187,8 +189,8 @@ namespace
error = "Unknown error while removing " + path;
}
- const JsContext context(jsEngine);
- JsValuePtr errorValue = jsEngine->NewValue(error);
+ JsContext context(m_jsEngine);
+ JsValuePtr errorValue = context.jsEngine().NewValue(error);
JsValueList params;
params.push_back(errorValue);
callback->Call(params);
@@ -225,8 +227,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.jsEngine().NewObject();
result->SetProperty("exists", statResult.exists);
result->SetProperty("isFile", statResult.isFile);
result->SetProperty("isDirectory", statResult.isDirectory);

Powered by Google App Engine
This is Rietveld