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 | virtual void errorInLoadingScript(const QUrl& url) = 0; | 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 | /// Interface for loading scripts | 25 | /// Interface for loading scripts |
| 24 | class ScriptCache : public QObject, public Dependency { | 26 | class ScriptCache : public QObject, public Dependency { |
| 25 | Q_OBJECT | 27 | Q_OBJECT |
| 26 | SINGLETON_DEPENDENCY | 28 | SINGLETON_DEPENDENCY |
| 27 | 29 | ||
| 28 | public: | 30 | public: |
| 31 | void getScriptContents(const QString& scriptOrURL, contentAvailableCallback contentAvailable, bool forceDownload = false); | ||
| 32 | |||
| 33 | |||
| 29 | QString getScript(const QUrl& unnormalizedURL, ScriptUser* scriptUser, bool& isPending, bool redownload = false); | 34 | QString getScript(const QUrl& unnormalizedURL, ScriptUser* scriptUser, bool& isPending, bool redownload = false); |
| 30 | void deleteScript(const QUrl& unnormalizedURL); | 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 | void addScriptToBadScriptList(const QUrl& url) { _badScripts.insert(url); } | 38 | void addScriptToBadScriptList(const QUrl& url) { _badScripts.insert(url); } |
| 32 | bool isInBadScriptList(const QUrl& url) { return _badScripts.contains(url); } | 39 | bool isInBadScriptList(const QUrl& url) { return _badScripts.contains(url); } |
| 33 | 40 | ||
| 34 | private slots: | 41 | private slots: |
| 35 | void scriptDownloaded(); | 42 | void scriptDownloaded(); // old version |
| 36 | 43 | void scriptContentAvailable(); // new version | |
| 44 | |||
| 37 | private: | 45 | private: |
| 38 | ScriptCache(QObject* parent = NULL); | 46 | ScriptCache(QObject* parent = NULL); |
| 39 | 47 | ||
| 48 | QMultiMap<QUrl, contentAvailableCallback> _contentCallbacks; | ||
| 49 | |||
| 40 | QHash<QUrl, QString> _scriptCache; | 50 | QHash<QUrl, QString> _scriptCache; |
| 41 | QMultiMap<QUrl, ScriptUser*> _scriptUsers; | 51 | QMultiMap<QUrl, ScriptUser*> _scriptUsers; |
| 42 | QSet<QUrl> _badScripts; | 52 | QSet<QUrl> _badScripts; |