Merge lp:~saviq/unity8/cache-network-data into lp:unity8

Proposed by Michał Sawicz
Status: Superseded
Proposed branch: lp:~saviq/unity8/cache-network-data
Merge into: lp:unity8
Diff against target: 123 lines (+77/-2)
4 files modified
src/CMakeLists.txt (+1/-0)
src/CachingNetworkManagerFactory.cpp (+34/-0)
src/CachingNetworkManagerFactory.h (+37/-0)
src/main.cpp (+5/-2)
To merge this branch: bzr merge lp:~saviq/unity8/cache-network-data
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Florian Boucault Pending
Review via email: mp+221079@code.launchpad.net

Commit message

Implement a caching network access manager to cache images.

Description of the change

It's the first step to improving our network usage and dash icon loading speed.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~saviq/unity8/cache-network-data updated
919. By Michał Sawicz

Merge trunk.

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

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2014-03-07 18:36:53 +0000
+++ src/CMakeLists.txt 2014-06-04 11:13:15 +0000
@@ -19,6 +19,7 @@
19 ApplicationArguments.h19 ApplicationArguments.h
20 main.cpp20 main.cpp
21 MouseTouchAdaptor.cpp21 MouseTouchAdaptor.cpp
22 CachingNetworkManagerFactory.cpp
22 ${QML_FILES} # This is to make qml and image files appear in the IDE's project tree23 ${QML_FILES} # This is to make qml and image files appear in the IDE's project tree
23 )24 )
24add_executable(${SHELL_APP} ${COMMON_SRCS})25add_executable(${SHELL_APP} ${COMMON_SRCS})
2526
=== added file 'src/CachingNetworkManagerFactory.cpp'
--- src/CachingNetworkManagerFactory.cpp 1970-01-01 00:00:00 +0000
+++ src/CachingNetworkManagerFactory.cpp 2014-06-04 11:13:15 +0000
@@ -0,0 +1,34 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#include "CachingNetworkManagerFactory.h"
19
20#include <QNetworkDiskCache>
21#include <QNetworkAccessManager>
22#include <QStandardPaths>
23
24CachingNetworkManagerFactory::CachingNetworkManagerFactory()
25 : m_cache(new QNetworkDiskCache())
26{
27 m_cache->setCacheDirectory(QString("%1/network").arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)));
28}
29
30QNetworkAccessManager *CachingNetworkManagerFactory::create(QObject *parent) {
31 QNetworkAccessManager *manager = new QNetworkAccessManager(parent);
32 manager->setCache(m_cache);
33 return manager;
34}
035
=== added file 'src/CachingNetworkManagerFactory.h'
--- src/CachingNetworkManagerFactory.h 1970-01-01 00:00:00 +0000
+++ src/CachingNetworkManagerFactory.h 2014-06-04 11:13:15 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#ifndef CACHINGNETWORKMANAGERFACTORY_H
19#define CACHINGNETWORKMANAGERFACTORY_H
20
21#include <QQmlNetworkAccessManagerFactory>
22
23class QNetworkDiskCache;
24class QNetworkAccessManager;
25
26class CachingNetworkManagerFactory : public QQmlNetworkAccessManagerFactory
27{
28public:
29 CachingNetworkManagerFactory();
30
31 QNetworkAccessManager *create(QObject *parent) override;
32
33private:
34 QNetworkDiskCache *m_cache;
35};
36
37#endif // CACHINGNETWORKMANAGERFACTORY_H
038
=== modified file 'src/main.cpp'
--- src/main.cpp 2014-05-20 03:01:51 +0000
+++ src/main.cpp 2014-06-04 11:13:15 +0000
@@ -35,15 +35,15 @@
35#include <paths.h>35#include <paths.h>
36#include "MouseTouchAdaptor.h"36#include "MouseTouchAdaptor.h"
37#include "ApplicationArguments.h"37#include "ApplicationArguments.h"
38#include "CachingNetworkManagerFactory.h"
3839
39#include <unity-mir/qmirserver.h>40#include <unity-mir/qmirserver.h>
4041
41
42int startShell(int argc, const char** argv, void* server)42int startShell(int argc, const char** argv, void* server)
43{43{
44 const bool isUbuntuMirServer = qgetenv("QT_QPA_PLATFORM") == "ubuntumirserver";44 const bool isUbuntuMirServer = qgetenv("QT_QPA_PLATFORM") == "ubuntumirserver";
4545
46 QGuiApplication::setApplicationName(UNITY8_GREETER ? "Unity 8 Greeter" : "Unity 8");46 QGuiApplication::setApplicationName(UNITY8_GREETER ? "unity8-greeter" : "unity8");
47 QGuiApplication *application;47 QGuiApplication *application;
4848
49 QCommandLineParser parser;49 QCommandLineParser parser;
@@ -160,6 +160,9 @@
160 }160 }
161 appendImportPaths(view->engine(), ::fallbackImportPaths());161 appendImportPaths(view->engine(), ::fallbackImportPaths());
162162
163 CachingNetworkManagerFactory *managerFactory = new CachingNetworkManagerFactory();
164 view->engine()->setNetworkAccessManagerFactory(managerFactory);
165
163 view->setSource(source);166 view->setSource(source);
164 view->setColor(Qt::transparent);167 view->setColor(Qt::transparent);
165168

Subscribers

People subscribed via source and target branches