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

Unified Diff: src/FilterEngine.cpp

Issue 29447555: Issue 5275 - Minimize memory usage as soon as possible (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created May 24, 2017, 12:09 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/JsEngine.h ('k') | src/JsEngine.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FilterEngine.cpp
diff --git a/src/FilterEngine.cpp b/src/FilterEngine.cpp
index 19a045e7169216533beb3b4cccaf7c965e2724cb..745d1d52b77b9e2bf7e5fde6bb56b48ba135df6f 100644
--- a/src/FilterEngine.cpp
+++ b/src/FilterEngine.cpp
@@ -265,6 +265,16 @@ void FilterEngine::CreateAsync(const JsEnginePtr& jsEngine,
jsEngine->RemoveEventCallback("_init");
});
+ std::weak_ptr<FilterEngine> weakFilterEngine = filterEngine;
+ filterEngine->SetFilterChangeCallback([weakFilterEngine](const std::string& reason, JsValue&&)
+ {
+ auto filterEngine = weakFilterEngine.lock();
+ if (!filterEngine)
+ return;
+ if (reason == "save")
+ filterEngine->GetJsEngine()->NotifyLowMemory();
+ });
+
// Lock the JS engine while we are loading scripts, no timeouts should fire
// until we are done.
const JsContext context(*jsEngine);
« no previous file with comments | « include/AdblockPlus/JsEngine.h ('k') | src/JsEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld