LeechCraft 0.6.70-14794-g33744ae6ce
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
standardnamfactory.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
10#include <QNetworkAccessManager>
11#include <QQmlEngine>
13
14namespace LC::Util
15{
17 CacheSizeGetter_f getter,
18 QQmlEngine *engine)
19 : Subpath_ (std::move (subpath))
20 , CacheSizeGetter_ (std::move (getter))
21 {
22 if (engine)
23 engine->setNetworkAccessManagerFactory (this);
24 }
25
26 QNetworkAccessManager* StandardNAMFactory::create (QObject *parent)
27 {
28 auto nam = new QNetworkAccessManager (parent);
29
30 auto cache = new NetworkDiskCache (Subpath_, nam);
31 cache->setMaximumCacheSize (CacheSizeGetter_ ());
32 nam->setCache (cache);
33
34 return nam;
35 }
36}
A thread-safe garbage-collected network disk cache.
StandardNAMFactory(QString subpath, CacheSizeGetter_f getter, QQmlEngine *engine=nullptr)
Constructs a new StandardNAMFactory.
QNetworkAccessManager * create(QObject *parent) override
Creates the network access manager with the given parent.
std::function< int()> CacheSizeGetter_f
The type of the function used to query the cache size by the factory.
STL namespace.