From 371200675c2fb2fef0ac8362ebd7bf4203835440 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 29 Jun 2015 09:15:16 +0200 Subject: drop yet another reimplementation of rtl::Reference (SotMutexHolderRef) Change-Id: I57f9dff931242405420bd45fae7ec5f13718707f --- package/inc/ZipFile.hxx | 10 ++--- package/inc/ZipPackage.hxx | 4 +- package/inc/mutexholder.hxx | 86 ++++--------------------------------------- package/inc/zipfileaccess.hxx | 2 +- 4 files changed, 15 insertions(+), 87 deletions(-) (limited to 'package/inc') diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx index 510353ec6900..18d2f0ab3160 100644 --- a/package/inc/ZipFile.hxx +++ b/package/inc/ZipFile.hxx @@ -81,7 +81,7 @@ protected: // aMediaType parameter is used only for raw stream header creation com::sun::star::uno::Reference < com::sun::star::io::XInputStream > createUnbufferedStream( - SotMutexHolderRef aMutexHolder, + const rtl::Reference& aMutexHolder, ZipEntry & rEntry, const ::rtl::Reference < EncryptionData > &rData, sal_Int8 nStreamMode, @@ -121,7 +121,7 @@ public: ZipEntry& rEntry, const ::rtl::Reference < EncryptionData > &rData, bool bDecrypt, - SotMutexHolderRef aMutexHolder ) + const rtl::Reference& aMutexHolder ) throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException); static ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XDigestContext > StaticGetDigestContextForChecksum( @@ -164,14 +164,14 @@ public: ZipEntry& rEntry, const ::rtl::Reference < EncryptionData > &rData, bool bDecrypt, - SotMutexHolderRef aMutexHolder ) + const rtl::Reference& aMutexHolder ) throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException); ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getDataStream( ZipEntry& rEntry, const ::rtl::Reference < EncryptionData > &rData, bool bDecrypt, - SotMutexHolderRef aMutexHolder ) + const rtl::Reference& aMutexHolder ) throw ( ::com::sun::star::packages::WrongPasswordException, ::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, @@ -181,7 +181,7 @@ public: ZipEntry& rEntry, const ::rtl::Reference < EncryptionData > &rData, const OUString& aMediaType, - SotMutexHolderRef aMutexHolder ) + const rtl::Reference& aMutexHolder ) throw ( ::com::sun::star::packages::NoEncryptionException, ::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx index 86d6e10c8290..131887664292 100644 --- a/package/inc/ZipPackage.hxx +++ b/package/inc/ZipPackage.hxx @@ -75,7 +75,7 @@ class ZipPackage : public cppu::WeakImplHelper7 > { protected: - SotMutexHolderRef m_aMutexHolder; + rtl::Reference m_aMutexHolder; ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > m_aStorageEncryptionKeys; ::com::sun::star::uno::Sequence< sal_Int8 > m_aEncryptionKey; @@ -133,7 +133,7 @@ public: sal_Int32 GetChecksumAlgID() const { return m_nChecksumDigestID; } sal_Int32 GetDefaultDerivedKeySize() const { return m_nCommonEncryptionID == ::com::sun::star::xml::crypto::CipherID::AES_CBC_W3C_PADDING ? 32 : 16; } - SotMutexHolderRef GetSharedMutexRef() { return m_aMutexHolder; } + rtl::Reference& GetSharedMutexRef() { return m_aMutexHolder; } void ConnectTo( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInStream ); const ::com::sun::star::uno::Sequence< sal_Int8 > GetEncryptionKey(); diff --git a/package/inc/mutexholder.hxx b/package/inc/mutexholder.hxx index 4b2e47f208dc..dac105f0157c 100644 --- a/package/inc/mutexholder.hxx +++ b/package/inc/mutexholder.hxx @@ -21,102 +21,30 @@ #define INCLUDED_PACKAGE_INC_MUTEXHOLDER_HXX #include +#include class SotMutexHolder { +friend class rtl::Reference; + ::osl::Mutex m_aMutex; sal_Int32 m_nRefCount; - public: - SotMutexHolder() : m_nRefCount( 0 ) {} - - void AddRef() + void acquire() { m_nRefCount++; } - void ReleaseRef() + void release() { if ( !--m_nRefCount ) delete this; } - ::osl::Mutex& GetMutex() { return m_aMutex; } -}; - -class SotMutexHolderRef -{ - SotMutexHolder* m_pHolder; - public: - SotMutexHolderRef() - : m_pHolder( NULL ) - {} - - SotMutexHolderRef( SotMutexHolder* pHolder ) - : m_pHolder( pHolder ) - { - if ( m_pHolder ) - m_pHolder->AddRef(); - } - - SotMutexHolderRef( const SotMutexHolderRef& rRef ) - : m_pHolder( rRef.m_pHolder ) - { - if ( m_pHolder ) - m_pHolder->AddRef(); - } - - ~SotMutexHolderRef() - { - if ( m_pHolder ) - m_pHolder->ReleaseRef(); - } - - SotMutexHolderRef& operator =( const SotMutexHolderRef& rRef ) - { - if ( m_pHolder ) - m_pHolder->ReleaseRef(); - - m_pHolder = rRef.m_pHolder; - - if ( m_pHolder ) - m_pHolder->AddRef(); - - return *this; - } - - SotMutexHolderRef& operator =( SotMutexHolder* pHolder ) - { - if ( m_pHolder ) - m_pHolder->ReleaseRef(); - - m_pHolder = pHolder; - - if ( m_pHolder ) - m_pHolder->AddRef(); - return *this; - } - - SotMutexHolder* operator ->() const - { - return m_pHolder; - } - - SotMutexHolder& operator *() const - { - return *m_pHolder; - } - - operator SotMutexHolder*() const - { - return m_pHolder; - } + SotMutexHolder() : m_nRefCount( 0 ) {} - bool Is() const - { - return m_pHolder != NULL; - } + ::osl::Mutex& GetMutex() { return m_aMutex; } }; #endif diff --git a/package/inc/zipfileaccess.hxx b/package/inc/zipfileaccess.hxx index 553d4cbe41a1..c7cee90aaab5 100644 --- a/package/inc/zipfileaccess.hxx +++ b/package/inc/zipfileaccess.hxx @@ -42,7 +42,7 @@ class OZipFileAccess : public ::cppu::WeakImplHelper4< ::com::sun::star::lang::XComponent, ::com::sun::star::lang::XServiceInfo > { - SotMutexHolderRef m_aMutexHolder; + rtl::Reference m_aMutexHolder; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; -- cgit