Showing the changes to libraries/script-engine/src/ScriptCache.h (1 of 6 files). Show all
Unified · Split
| @@ -20,23 +20,33 @@ public: · 19 unmodified lines | ||
| 20 | 20 | virtual void errorInLoadingScript(const QUrl& url) = 0; |
| 21 | 21 | }; |
| 22 | 22 | |
| 23 | +using contentAvailableCallback = std::function<void(const QString& scriptOrURL, const QString& contents, bool isURL, bool contentAvailable)>; | |
| 24 | + | |
| 23 | 25 | /// Interface for loading scripts |
| 24 | 26 | class ScriptCache : public QObject, public Dependency { |
| 25 | 27 | Q_OBJECT |
| 26 | 28 | SINGLETON_DEPENDENCY |
| 27 | 29 | |
| 28 | 30 | public: |
| 31 | + void getScriptContents(const QString& scriptOrURL, contentAvailableCallback contentAvailable, bool forceDownload = false); | |
| 32 | + | |
| 33 | + | |
| 29 | 34 | QString getScript(const QUrl& unnormalizedURL, ScriptUser* scriptUser, bool& isPending, bool redownload = false); |
| 30 | 35 | void deleteScript(const QUrl& unnormalizedURL); |
| 36 | + | |
| 37 | + // FIXME - how do we remove a script from the bad script list in the case of a redownload? | |
| 31 | 38 | void addScriptToBadScriptList(const QUrl& url) { _badScripts.insert(url); } |
| 32 | 39 | bool isInBadScriptList(const QUrl& url) { return _badScripts.contains(url); } |
| 33 | 40 | |
| 34 | 41 | private slots: |
| 35 | − void scriptDownloaded(); | |
| 36 | − | |
| 42 | + void scriptDownloaded(); // old version | |
| 43 | + void scriptContentAvailable(); // new version | |
| 44 | + | |
| 37 | 45 | private: |
| 38 | 46 | ScriptCache(QObject* parent = NULL); |
| 39 | 47 | |
| 48 | + QMultiMap<QUrl, contentAvailableCallback> _contentCallbacks; | |
| 49 | + | |
| 40 | 50 | QHash<QUrl, QString> _scriptCache; |
| 41 | 51 | QMultiMap<QUrl, ScriptUser*> _scriptUsers; |
| 42 | 52 | QSet<QUrl> _badScripts; |