Merge lp:~osomon/webbrowser-app/maxCacheSizeHint into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 936
Merged at revision: 1019
Proposed branch: lp:~osomon/webbrowser-app/maxCacheSizeHint
Merge into: lp:webbrowser-app
Diff against target: 110 lines (+35/-3)
3 files modified
debian/control (+1/-1)
src/Ubuntu/Web/UbuntuWebContext.qml (+5/-2)
src/Ubuntu/Web/plugin.cpp (+29/-0)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/maxCacheSizeHint
Reviewer Review Type Date Requested Status
Alexandre Abreu (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+252472@code.launchpad.net

Commit message

Make use of the WebContext.maxCacheSizeHint property, introduced in Oxide 1.6.
This bumps the dependency of qtdeclarative5-ubuntu-web-plugin on liboxideqt-qmlplugin to 1.6.

To post a comment you must log in.
Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

I am wondering about the hardcoded value for webapp, it is pretty arbitrary and might benefit from being adjustable for certain webapps ... could you add a argument for this?

(added a nit comment inline)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandre Abreu (abreu-alexandre) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2015-04-10 13:33:10 +0000
+++ debian/control 2015-04-28 21:31:21 +0000
@@ -95,7 +95,7 @@
95Pre-Depends: ${misc:Pre-Depends}95Pre-Depends: ${misc:Pre-Depends}
96Depends: ${misc:Depends},96Depends: ${misc:Depends},
97 ${shlibs:Depends},97 ${shlibs:Depends},
98 liboxideqt-qmlplugin (>= 1.5),98 liboxideqt-qmlplugin (>= 1.6),
99 qml-module-qtquick2 | qtdeclarative5-qtquick2-plugin,99 qml-module-qtquick2 | qtdeclarative5-qtquick2-plugin,
100 qml-module-qtquick-window2 | qtdeclarative5-window-plugin,100 qml-module-qtquick-window2 | qtdeclarative5-window-plugin,
101 qtdeclarative5-ubuntu-ui-toolkit-plugin,101 qtdeclarative5-ubuntu-ui-toolkit-plugin,
102102
=== modified file 'src/Ubuntu/Web/UbuntuWebContext.qml'
--- src/Ubuntu/Web/UbuntuWebContext.qml 2015-02-24 10:32:50 +0000
+++ src/Ubuntu/Web/UbuntuWebContext.qml 2015-04-28 21:31:21 +0000
@@ -17,13 +17,16 @@
17 */17 */
1818
19import QtQuick 2.019import QtQuick 2.0
20import com.canonical.Oxide 1.3 as Oxide20import com.canonical.Oxide 1.6 as Oxide
2121
22Oxide.WebContext {22Oxide.WebContext {
23 readonly property string defaultUserAgent: __ua.defaultUA23 readonly property string defaultUserAgent: __ua.defaultUA
2424
25 dataPath: dataLocation
26
25 cachePath: cacheLocation27 cachePath: cacheLocation
26 dataPath: dataLocation28 maxCacheSizeHint: cacheSizeHint
29
27 userAgent: defaultUserAgent30 userAgent: defaultUserAgent
2831
29 networkRequestDelegate: Oxide.WebContextDelegateWorker {32 networkRequestDelegate: Oxide.WebContextDelegateWorker {
3033
=== modified file 'src/Ubuntu/Web/plugin.cpp'
--- src/Ubuntu/Web/plugin.cpp 2015-03-27 18:24:56 +0000
+++ src/Ubuntu/Web/plugin.cpp 2015-04-28 21:31:21 +0000
@@ -23,6 +23,7 @@
23#include <QtCore/QDir>23#include <QtCore/QDir>
24#include <QtCore/QObject>24#include <QtCore/QObject>
25#include <QtCore/QStandardPaths>25#include <QtCore/QStandardPaths>
26#include <QtCore/QStorageInfo>
26#include <QtCore/QString>27#include <QtCore/QString>
27#include <QtCore/QStringList>28#include <QtCore/QStringList>
28#include <QtCore/QtGlobal>29#include <QtCore/QtGlobal>
@@ -37,6 +38,7 @@
37 Q_PROPERTY(QString cacheLocation READ cacheLocation NOTIFY cacheLocationChanged)38 Q_PROPERTY(QString cacheLocation READ cacheLocation NOTIFY cacheLocationChanged)
38 Q_PROPERTY(QString dataLocation READ dataLocation NOTIFY dataLocationChanged)39 Q_PROPERTY(QString dataLocation READ dataLocation NOTIFY dataLocationChanged)
39 Q_PROPERTY(QString formFactor READ formFactor CONSTANT)40 Q_PROPERTY(QString formFactor READ formFactor CONSTANT)
41 Q_PROPERTY(int cacheSizeHint READ cacheSizeHint NOTIFY cacheSizeHintChanged)
40 Q_PROPERTY(QString webviewDevtoolsDebugHost READ devtoolsHost CONSTANT)42 Q_PROPERTY(QString webviewDevtoolsDebugHost READ devtoolsHost CONSTANT)
41 Q_PROPERTY(int webviewDevtoolsDebugPort READ devtoolsPort CONSTANT)43 Q_PROPERTY(int webviewDevtoolsDebugPort READ devtoolsPort CONSTANT)
42 Q_PROPERTY(QStringList webviewHostMappingRules READ hostMappingRules CONSTANT)44 Q_PROPERTY(QStringList webviewHostMappingRules READ hostMappingRules CONSTANT)
@@ -47,6 +49,7 @@
47 QString cacheLocation() const;49 QString cacheLocation() const;
48 QString dataLocation() const;50 QString dataLocation() const;
49 QString formFactor();51 QString formFactor();
52 int cacheSizeHint() const;
50 QString devtoolsHost();53 QString devtoolsHost();
51 int devtoolsPort();54 int devtoolsPort();
52 QStringList hostMappingRules();55 QStringList hostMappingRules();
@@ -54,6 +57,7 @@
54Q_SIGNALS:57Q_SIGNALS:
55 void cacheLocationChanged() const;58 void cacheLocationChanged() const;
56 void dataLocationChanged() const;59 void dataLocationChanged() const;
60 void cacheSizeHintChanged() const;
5761
58private:62private:
59 QString m_formFactor;63 QString m_formFactor;
@@ -72,6 +76,8 @@
72 this, SIGNAL(cacheLocationChanged()));76 this, SIGNAL(cacheLocationChanged()));
73 connect(QCoreApplication::instance(), SIGNAL(applicationNameChanged()),77 connect(QCoreApplication::instance(), SIGNAL(applicationNameChanged()),
74 this, SIGNAL(dataLocationChanged()));78 this, SIGNAL(dataLocationChanged()));
79 connect(QCoreApplication::instance(), SIGNAL(applicationNameChanged()),
80 this, SIGNAL(cacheSizeHintChanged()));
75}81}
7682
77QString UbuntuWebPluginContext::cacheLocation() const83QString UbuntuWebPluginContext::cacheLocation() const
@@ -130,6 +136,29 @@
130 return m_formFactor;136 return m_formFactor;
131}137}
132138
139int UbuntuWebPluginContext::cacheSizeHint() const
140{
141 if (QCoreApplication::applicationName() == "webbrowser-app") {
142 // Let chromium decide the optimum cache size based on available disk space
143 return 0;
144 } else {
145 // For webapps and other embedders, determine the cache size hint
146 // using heuristics based on the disk space (total, and available).
147 QStorageInfo storageInfo(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
148 const int MB = 1024 * 1024;
149 // The total cache size for all apps should not exceed 10% of the total disk space
150 int maxSharedCache = storageInfo.bytesTotal() / MB * 0.1;
151 // One given app is allowed to use up to 5% o the total cache size
152 int maxAppCacheAllowance = maxSharedCache * 0.05;
153 // Ensure it never exceeds 200 MB though
154 int maxAppCacheAbsolute = qMin(maxAppCacheAllowance, 200);
155 // Never use more than 20% of the available disk space
156 int maxAppCacheRelative = storageInfo.bytesAvailable() / MB * 0.2;
157 // Never set a size hint below 5 MB, as that would result in a very inefficient cache
158 return qMax(5, qMin(maxAppCacheAbsolute, maxAppCacheRelative));
159 }
160}
161
133QStringList UbuntuWebPluginContext::hostMappingRules()162QStringList UbuntuWebPluginContext::hostMappingRules()
134{163{
135 static const QString HOST_MAPPING_RULES_SEP = ",";164 static const QString HOST_MAPPING_RULES_SEP = ",";

Subscribers

People subscribed via source and target branches

to status/vote changes: