LibreOffice Module ucb (master) 1
SerfLockStore.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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
21#pragma once
22
23#include <map>
24#include <mutex>
25#include <rtl/ref.hxx>
26#include <rtl/ustring.hxx>
27#include <com/sun/star/ucb/Lock.hpp>
28#include <utility>
29
30#include "CurlSession.hxx"
31
32namespace http_dav_ucp
33{
34
35class TickerThread;
36
38{
39 OUString m_sToken;
40 css::ucb::Lock m_Lock;
43
46
47 LockInfo( OUString sToken,
48 css::ucb::Lock aLock,
50 sal_Int32 nLastChanceToSendRefreshRequest )
51 : m_sToken(std::move(sToken))
52 , m_Lock(std::move(aLock))
53 , m_xSession(std::move(xSession))
54 , m_nLastChanceToSendRefreshRequest(nLastChanceToSendRefreshRequest)
55 {}
56};
57
58typedef std::map< OUString, LockInfo > LockInfoMap;
59
61{
62 std::mutex m_aMutex;
65
66public:
69
70 OUString const* getLockTokenForURI(OUString const& rURI, css::ucb::Lock const* pLock);
71
72 void addLock( const OUString& rURI,
73 css::ucb::Lock const& rLock,
74 const OUString& sToken,
75 rtl::Reference<CurlSession> const & xSession,
76 // time in seconds since Jan 1 1970
77 // -1: infinite lock, no refresh
78 sal_Int32 nLastChanceToSendRefreshRequest );
79
80 void removeLock(const OUString& rURI);
81
82 void refreshLocks();
83
84private:
85 void removeLockImpl(std::unique_lock<std::mutex> & rGuard, const OUString& rURI);
86 void startTicker();
87 void stopTicker(std::unique_lock<std::mutex> & rGuard);
88};
89
90} // namespace http_dav_ucp
91
92/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void removeLockImpl(std::unique_lock< std::mutex > &rGuard, const OUString &rURI)
rtl::Reference< TickerThread > m_pTickerThread
OUString const * getLockTokenForURI(OUString const &rURI, css::ucb::Lock const *pLock)
void removeLock(const OUString &rURI)
void stopTicker(std::unique_lock< std::mutex > &rGuard)
void addLock(const OUString &rURI, css::ucb::Lock const &rLock, const OUString &sToken, rtl::Reference< CurlSession > const &xSession, sal_Int32 nLastChanceToSendRefreshRequest)
std::map< OUString, LockInfo > LockInfoMap
rtl::Reference< CurlSession > m_xSession
LockInfo(OUString sToken, css::ucb::Lock aLock, rtl::Reference< CurlSession > xSession, sal_Int32 nLastChanceToSendRefreshRequest)
sal_Int32 m_nLastChanceToSendRefreshRequest