Merge lp:~osomon/webbrowser-app/favicon-optimizations into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 1468
Merged at revision: 1480
Proposed branch: lp:~osomon/webbrowser-app/favicon-optimizations
Merge into: lp:webbrowser-app
Diff against target: 130 lines (+24/-8)
4 files modified
src/app/Favicon.qml (+5/-2)
src/app/favicon-fetcher.cpp (+14/-2)
src/app/favicon-fetcher.h (+2/-1)
tests/unittests/favicon-fetcher/tst_FaviconFetcherTests.cpp (+3/-3)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/favicon-optimizations
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+295968@code.launchpad.net

Commit message

Various favicon optimizations.

To post a comment you must log in.
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1468
https://jenkins.canonical.com/system-apps/job/lp-webbrowser-app-ci/507/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/509
    FAILURE: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/45/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/509
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/502
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial/502
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/497
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/497/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial/497
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial/497/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/497
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/497/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial/497
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial/497/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/497
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/497/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial/497
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial/497/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-webbrowser-app-ci/507/rebuild

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/Favicon.qml'
2--- src/app/Favicon.qml 2015-08-10 15:22:00 +0000
3+++ src/app/Favicon.qml 2016-05-27 15:37:30 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright 2014-2015 Canonical Ltd.
7+ * Copyright 2014-2016 Canonical Ltd.
8 *
9 * This file is part of webbrowser-app.
10 *
11@@ -21,7 +21,9 @@
12 import webbrowsercommon.private 0.1
13
14 Item {
15- property alias source: fetcher.url
16+ id: favicon
17+
18+ property url source
19 property bool fallbackIcon: true
20 property alias shouldCache: fetcher.shouldCache
21
22@@ -36,6 +38,7 @@
23
24 FaviconFetcher {
25 id: fetcher
26+ url: favicon.visible ? favicon.source : ""
27 }
28
29 Icon {
30
31=== modified file 'src/app/favicon-fetcher.cpp'
32--- src/app/favicon-fetcher.cpp 2015-09-21 19:41:22 +0000
33+++ src/app/favicon-fetcher.cpp 2016-05-27 15:37:30 +0000
34@@ -1,5 +1,5 @@
35 /*
36- * Copyright 2014-2015 Canonical Ltd.
37+ * Copyright 2014-2016 Canonical Ltd.
38 *
39 * This file is part of webbrowser-app.
40 *
41@@ -96,7 +96,9 @@
42
43 QFileInfo fileinfo(m_filepath);
44 if (fileinfo.exists() && (fileinfo.lastModified().daysTo(QDateTime::currentDateTime()) < CACHE_EXPIRATION_DAYS)) {
45- setLocalUrl(QUrl::fromLocalFile(m_filepath));
46+ if (fileinfo.size() > 0) {
47+ setLocalUrl(QUrl::fromLocalFile(m_filepath));
48+ }
49 } else {
50 m_redirections = 0;
51 download(url);
52@@ -150,6 +152,13 @@
53 m_reply = m_manager->get(request);
54 }
55
56+void FaviconFetcher::cacheEmptyFile() const
57+{
58+ // Write an empty file to the cache to avoid subsequent attempts
59+ // to download an inexistent icon over and over again.
60+ QFile(m_filepath).open(QIODevice::WriteOnly);
61+}
62+
63 void FaviconFetcher::downloadFinished(QNetworkReply* reply)
64 {
65 if (reply->error() == QNetworkReply::OperationCanceledError) {
66@@ -171,6 +180,8 @@
67 setLocalUrl(QUrl("data:image/png;base64," + ba.toBase64()));
68 }
69 }
70+ } else {
71+ cacheEmptyFile();
72 }
73 reply->deleteLater();
74 m_reply = 0;
75@@ -185,6 +196,7 @@
76 qWarning() << "Failed to download"
77 << m_url.toString().toUtf8().data()
78 << ": too many redirections";
79+ cacheEmptyFile();
80 }
81 }
82 }
83
84=== modified file 'src/app/favicon-fetcher.h'
85--- src/app/favicon-fetcher.h 2015-05-26 21:42:54 +0000
86+++ src/app/favicon-fetcher.h 2016-05-27 15:37:30 +0000
87@@ -1,5 +1,5 @@
88 /*
89- * Copyright 2014-2015 Canonical Ltd.
90+ * Copyright 2014-2016 Canonical Ltd.
91 *
92 * This file is part of webbrowser-app.
93 *
94@@ -62,6 +62,7 @@
95
96 private:
97 void setLocalUrl(const QUrl& url);
98+ void cacheEmptyFile() const;
99
100 bool m_shouldCache;
101 QString m_cacheLocation;
102
103=== modified file 'tests/unittests/favicon-fetcher/tst_FaviconFetcherTests.cpp'
104--- tests/unittests/favicon-fetcher/tst_FaviconFetcherTests.cpp 2015-10-07 17:49:58 +0000
105+++ tests/unittests/favicon-fetcher/tst_FaviconFetcherTests.cpp 2016-05-27 15:37:30 +0000
106@@ -1,5 +1,5 @@
107 /*
108- * Copyright 2014-2015 Canonical Ltd.
109+ * Copyright 2014-2016 Canonical Ltd.
110 *
111 * This file is part of webbrowser-app.
112 *
113@@ -193,7 +193,7 @@
114 QCOMPARE(cache.count(), (uint) 0);
115 }
116
117- void shouldNotCacheInvalidIcon()
118+ void shouldFailToDownloadInvalidIcon()
119 {
120 // First fetch a valid icon to ensure localUrl is initially not empty
121 QUrl url(server->baseURL() + "/favicon1.ico");
122@@ -201,7 +201,7 @@
123 QVERIFY(fetcherSpy->wait());
124 QVERIFY(!fetcher->localUrl().isEmpty());
125 // Then request an invalid one
126- url = QUrl(server->baseURL() + "/invalid");
127+ url = QUrl(server->baseURL() + "/invalid.png");
128 fetcher->setUrl(url);
129 QVERIFY(serverSpy->wait());
130 QVERIFY(fetcher->localUrl().isEmpty());

Subscribers

People subscribed via source and target branches

to status/vote changes: