LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
networkdiskcache.h
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 
9 #pragma once
10 
11 #include <QNetworkDiskCache>
12 #include <QRecursiveMutex>
13 #include <QHash>
14 #include <util/sll/util.h>
15 #include "networkconfig.h"
16 
17 namespace LC::Util
18 {
32  class UTIL_NETWORK_API NetworkDiskCache : public QNetworkDiskCache
33  {
34  Q_OBJECT
35 
36  qint64 CurrentSize_ = -1;
37 
38  mutable QRecursiveMutex InsertRemoveMutex_;
39 
40  QHash<QIODevice*, QUrl> PendingDev2Url_;
41  QHash<QUrl, QList<QIODevice*>> PendingUrl2Devs_;
42 
43  const Util::DefaultScopeGuard GcGuard_;
44  public:
55  explicit NetworkDiskCache (const QString& subpath, QObject *parent = nullptr);
56 
59  qint64 cacheSize () const override;
60 
63  QIODevice* data (const QUrl& url) override;
64 
67  void insert (QIODevice *device) override;
68 
71  QNetworkCacheMetaData metaData (const QUrl& url) override;
72 
75  QIODevice* prepare (const QNetworkCacheMetaData&) override;
76 
79  bool remove (const QUrl& url) override;
80 
83  void updateMetaData (const QNetworkCacheMetaData& metaData) override;
84  protected:
87  qint64 expire () override;
88  };
89 }
90 
LC::Util
Definition: icoreproxy.h:33
networkconfig.h
util.h
LC::Util::NetworkDiskCache
A thread-safe garbage-collected network disk cache.
Definition: networkdiskcache.h:38
LC::Util::detail::ScopeGuard
Definition: util.h:61
UTIL_NETWORK_API
#define UTIL_NETWORK_API
Definition: networkconfig.h:16