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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/AdblockPlus/JsEngine.h ('k') | src/JsEngine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 }); 258 });
259 } 259 }
260 260
261 jsEngine->SetEventCallback("_init", [jsEngine, filterEngine, onCreated](JsValu eList&& params) 261 jsEngine->SetEventCallback("_init", [jsEngine, filterEngine, onCreated](JsValu eList&& params)
262 { 262 {
263 filterEngine->firstRun = params.size() && params[0].AsBool(); 263 filterEngine->firstRun = params.size() && params[0].AsBool();
264 onCreated(filterEngine); 264 onCreated(filterEngine);
265 jsEngine->RemoveEventCallback("_init"); 265 jsEngine->RemoveEventCallback("_init");
266 }); 266 });
267 267
268 std::weak_ptr<FilterEngine> weakFilterEngine = filterEngine;
269 filterEngine->SetFilterChangeCallback([weakFilterEngine](const std::string& re ason, JsValue&&)
270 {
271 auto filterEngine = weakFilterEngine.lock();
272 if (!filterEngine)
273 return;
274 if (reason == "save")
275 filterEngine->GetJsEngine()->NotifyLowMemory();
276 });
277
268 // Lock the JS engine while we are loading scripts, no timeouts should fire 278 // Lock the JS engine while we are loading scripts, no timeouts should fire
269 // until we are done. 279 // until we are done.
270 const JsContext context(*jsEngine); 280 const JsContext context(*jsEngine);
271 // Set the preconfigured prefs 281 // Set the preconfigured prefs
272 auto preconfiguredPrefsObject = jsEngine->NewObject(); 282 auto preconfiguredPrefsObject = jsEngine->NewObject();
273 for (const auto& pref : params.preconfiguredPrefs) 283 for (const auto& pref : params.preconfiguredPrefs)
274 { 284 {
275 preconfiguredPrefsObject.SetProperty(pref.first, pref.second); 285 preconfiguredPrefsObject.SetProperty(pref.first, pref.second);
276 } 286 }
277 jsEngine->SetGlobalProperty("_preconfiguredPrefs", preconfiguredPrefsObject); 287 jsEngine->SetGlobalProperty("_preconfiguredPrefs", preconfiguredPrefsObject);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url); 636 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url);
627 if (filter) 637 if (filter)
628 { 638 {
629 return filter; 639 return filter;
630 } 640 }
631 currentUrl = parentUrl; 641 currentUrl = parentUrl;
632 } 642 }
633 while (urlIterator != documentUrls.end()); 643 while (urlIterator != documentUrls.end());
634 return FilterPtr(); 644 return FilterPtr();
635 } 645 }
OLDNEW
« 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