LibreOffice Module ucb (master) 1
PropfindCache.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_PROPFINDCACHE_HXX
11#define INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_PROPFINDCACHE_HXX
12
13#include <sal/types.h>
14#include <rtl/ustring.hxx>
15#include <mutex>
16#include <map>
17#include <vector>
18
19#include "DAVResource.hxx"
20
21namespace http_dav_ucp
22{
23 // A property names cache mechanism, URL driven.
24 // It is used to cache the property names received
25 // from the WebDAV server, to minimize the need of
26 // net transactions (e.g. PROPFIND).
27 // The cache lifetime should be short
28 // just to remove the annoying slowness when
29 // typing text or moving cursor around when the
30 // net link is slow.
31
32 // Define the properties cache element
34 {
36 sal_uInt32 m_nStaleTime;
37 OUString m_sURL;
38 // the property name list received from WebDAV server
39 std::vector< DAVResourceInfo > m_aPropertiesNames;
40
41 public:
43 explicit PropertyNames( OUString aURL );
44
45 sal_uInt32 getStaleTime() const { return m_nStaleTime; };
46 void setStaleTime( const sal_uInt32 nStaleTime ) { m_nStaleTime = nStaleTime; };
47
48 OUString& getURL() { return m_sURL; };
49
50 const std::vector< DAVResourceInfo >& getPropertiesNames() { return m_aPropertiesNames; };
51 void setPropertiesNames( const std::vector< DAVResourceInfo >& aPropertiesNames ) { m_aPropertiesNames = aPropertiesNames; };
52 };
53
54 // Define the PropertyNames cache
55 // TODO: the OUString key element in std::map needs to be changed with a URI representation
56 // with a specific compare (std::less) implementation, this last one implementing
57 // as suggested in <https://tools.ietf.org/html/rfc3986#section-6>.
58 // To find by URI and not by string equality.
59 typedef std::map< OUString, PropertyNames,
60 std::less< OUString > >PropNameCache;
61
63 {
65 std::mutex m_aMutex;
66
67 public:
70
71 bool getCachedPropertyNames( const OUString& URL, PropertyNames& rCacheElement );
72 void removeCachedPropertyNames( const OUString& URL );
73 void addCachePropertyNames( PropertyNames& rCacheElement, const sal_uInt32 nLifeTime );
74 };
75
76}
77
78#endif
79
80/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
void removeCachedPropertyNames(const OUString &URL)
void addCachePropertyNames(PropertyNames &rCacheElement, const sal_uInt32 nLifeTime)
bool getCachedPropertyNames(const OUString &URL, PropertyNames &rCacheElement)
sal_uInt32 m_nStaleTime
target time when this element becomes stale
const std::vector< DAVResourceInfo > & getPropertiesNames()
void setPropertiesNames(const std::vector< DAVResourceInfo > &aPropertiesNames)
void setStaleTime(const sal_uInt32 nStaleTime)
sal_uInt32 getStaleTime() const
std::vector< DAVResourceInfo > m_aPropertiesNames
std::map< OUString, PropertyNames, std::less< OUString > > PropNameCache