diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-19 17:06:34 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-20 14:13:35 +0200 |
commit | 809e2d33b45b54b4438a4c55aed93efd73d2aa49 (patch) | |
tree | 27f4995f949f25e7f26b3ac94028cecf0624ecb8 /package/inc | |
parent | f6add3f04bd5acc162ada79597a87398236f1320 (diff) |
create comphelper::RefCountedMutex
and merge the two existing implementations of the idea - SotMutexHolder
from package and RefCountedMutex from connectivity
Change-Id: I87f09f359ac798cf934381a2c75225dab71dd43e
Reviewed-on: https://gerrit.libreoffice.org/38972
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'package/inc')
-rw-r--r-- | package/inc/ZipFile.hxx | 21 | ||||
-rw-r--r-- | package/inc/ZipPackage.hxx | 6 | ||||
-rw-r--r-- | package/inc/ZipPackageStream.hxx | 2 | ||||
-rw-r--r-- | package/inc/mutexholder.hxx | 52 | ||||
-rw-r--r-- | package/inc/zipfileaccess.hxx | 5 |
5 files changed, 16 insertions, 70 deletions
diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx index 0362011e62d3..54e6dc74f6b9 100644 --- a/package/inc/ZipFile.hxx +++ b/package/inc/ZipFile.hxx @@ -26,13 +26,12 @@ #include <com/sun/star/xml/crypto/XCipherContext.hpp> #include <com/sun/star/xml/crypto/XDigestContext.hpp> +#include <comphelper/refcountedmutex.hxx> #include <package/Inflater.hxx> #include <ByteGrabber.hxx> #include <HashMaps.hxx> #include <EncryptionData.hxx> -#include <mutexholder.hxx> - #include <memory> namespace com { namespace sun { namespace star { @@ -55,7 +54,7 @@ class ZipEnumeration; class ZipFile { - rtl::Reference<SotMutexHolder> m_aMutexHolder; + rtl::Reference<comphelper::RefCountedMutex> m_aMutexHolder; EntryHash aEntries; ByteGrabber aGrabber; @@ -67,7 +66,7 @@ class ZipFile // aMediaType parameter is used only for raw stream header creation css::uno::Reference < css::io::XInputStream > createStreamForZipEntry( - const rtl::Reference<SotMutexHolder>& aMutexHolder, + const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder, ZipEntry & rEntry, const ::rtl::Reference < EncryptionData > &rData, sal_Int8 nStreamMode, @@ -89,12 +88,12 @@ class ZipFile public: - ZipFile( const rtl::Reference<SotMutexHolder>& aMutexHolder, + ZipFile( const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder, css::uno::Reference < css::io::XInputStream > &xInput, const css::uno::Reference < css::uno::XComponentContext > &rxContext, bool bInitialise ); - ZipFile( const rtl::Reference<SotMutexHolder>& aMutexHolder, + ZipFile( const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder, css::uno::Reference < css::io::XInputStream > &xInput, const css::uno::Reference < css::uno::XComponentContext > &rxContext, bool bInitialise, @@ -109,7 +108,7 @@ public: ZipEntry& rEntry, const ::rtl::Reference < EncryptionData > &rData, bool bDecrypt, - const rtl::Reference<SotMutexHolder>& aMutexHolder ); + const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder ); static css::uno::Reference< css::xml::crypto::XDigestContext > StaticGetDigestContextForChecksum( const css::uno::Reference< css::uno::XComponentContext >& xArgContext, @@ -135,7 +134,7 @@ public: const css::uno::Reference < css::io::XInputStream >& rStream ); static css::uno::Reference< css::io::XInputStream > StaticGetDataFromRawStream( - const rtl::Reference<SotMutexHolder>& aMutexHolder, + const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder, const css::uno::Reference< css::uno::XComponentContext >& rxContext, const css::uno::Reference< css::io::XInputStream >& xStream, const ::rtl::Reference < EncryptionData > &rData ); @@ -149,19 +148,19 @@ public: ZipEntry& rEntry, const ::rtl::Reference < EncryptionData > &rData, bool bDecrypt, - const rtl::Reference<SotMutexHolder>& aMutexHolder ); + const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder ); css::uno::Reference< css::io::XInputStream > getDataStream( ZipEntry& rEntry, const ::rtl::Reference < EncryptionData > &rData, bool bDecrypt, - const rtl::Reference<SotMutexHolder>& aMutexHolder ); + const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder ); css::uno::Reference< css::io::XInputStream > getWrappedRawStream( ZipEntry& rEntry, const ::rtl::Reference < EncryptionData > &rData, const OUString& aMediaType, - const rtl::Reference<SotMutexHolder>& aMutexHolder ); + const rtl::Reference<comphelper::RefCountedMutex>& aMutexHolder ); std::unique_ptr<ZipEnumeration> entries(); }; diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx index 42f04801b643..cd5a8caba757 100644 --- a/package/inc/ZipPackage.hxx +++ b/package/inc/ZipPackage.hxx @@ -31,10 +31,10 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/xml/crypto/CipherID.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <comphelper/refcountedmutex.hxx> #include <HashMaps.hxx> #include <osl/file.h> -#include <mutexholder.hxx> #include <vector> #include <memory> @@ -69,7 +69,7 @@ class ZipPackage : public cppu::WeakImplHelper > { protected: - rtl::Reference<SotMutexHolder> m_aMutexHolder; + rtl::Reference<comphelper::RefCountedMutex> m_aMutexHolder; css::uno::Sequence< css::beans::NamedValue > m_aStorageEncryptionKeys; css::uno::Sequence< sal_Int8 > m_aEncryptionKey; @@ -126,7 +126,7 @@ public: sal_Int32 GetChecksumAlgID() const { return m_nChecksumDigestID; } sal_Int32 GetDefaultDerivedKeySize() const { return m_nCommonEncryptionID == css::xml::crypto::CipherID::AES_CBC_W3C_PADDING ? 32 : 16; } - rtl::Reference<SotMutexHolder>& GetSharedMutexRef() { return m_aMutexHolder; } + rtl::Reference<comphelper::RefCountedMutex>& GetSharedMutexRef() { return m_aMutexHolder; } void ConnectTo( const css::uno::Reference< css::io::XInputStream >& xInStream ); const css::uno::Sequence< sal_Int8 > GetEncryptionKey(); diff --git a/package/inc/ZipPackageStream.hxx b/package/inc/ZipPackageStream.hxx index ed0799779273..2ae82d23c164 100644 --- a/package/inc/ZipPackageStream.hxx +++ b/package/inc/ZipPackageStream.hxx @@ -26,10 +26,10 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <ZipPackageEntry.hxx> #include <rtl/ref.hxx> +#include <comphelper/refcountedmutex.hxx> #include <cppuhelper/implbase.hxx> #include <EncryptionData.hxx> -#include <mutexholder.hxx> #define PACKAGE_STREAM_NOTSET 0 #define PACKAGE_STREAM_PACKAGEMEMBER 1 diff --git a/package/inc/mutexholder.hxx b/package/inc/mutexholder.hxx deleted file mode 100644 index dac105f0157c..000000000000 --- a/package/inc/mutexholder.hxx +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_PACKAGE_INC_MUTEXHOLDER_HXX -#define INCLUDED_PACKAGE_INC_MUTEXHOLDER_HXX - -#include <osl/mutex.hxx> -#include <rtl/ref.hxx> - -class SotMutexHolder -{ -friend class rtl::Reference<SotMutexHolder>; - - ::osl::Mutex m_aMutex; - sal_Int32 m_nRefCount; - - void acquire() - { - m_nRefCount++; - } - - void release() - { - if ( !--m_nRefCount ) - delete this; - } - -public: - SotMutexHolder() : m_nRefCount( 0 ) {} - - ::osl::Mutex& GetMutex() { return m_aMutex; } -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/package/inc/zipfileaccess.hxx b/package/inc/zipfileaccess.hxx index b4c32af3e182..112e882c42de 100644 --- a/package/inc/zipfileaccess.hxx +++ b/package/inc/zipfileaccess.hxx @@ -29,10 +29,9 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <comphelper/interfacecontainer2.hxx> +#include <comphelper/refcountedmutex.hxx> #include <cppuhelper/implbase.hxx> -#include <mutexholder.hxx> - #include <ZipFile.hxx> #include <HashMaps.hxx> @@ -44,7 +43,7 @@ class OZipFileAccess : public ::cppu::WeakImplHelper< css::lang::XComponent, css::lang::XServiceInfo > { - rtl::Reference<SotMutexHolder> m_aMutexHolder; + rtl::Reference<comphelper::RefCountedMutex> m_aMutexHolder; css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::io::XInputStream > m_xContentStream; std::unique_ptr<ZipFile> m_pZipFile; |