summaryrefslogtreecommitdiff
path: root/package/inc
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-06-29 09:15:16 +0200
committerNoel Grandin <noel@peralex.com>2015-06-29 09:16:18 +0200
commit371200675c2fb2fef0ac8362ebd7bf4203835440 (patch)
treef694a17d0837d052be53ae104b3390b189bb846d /package/inc
parentefc66942f29c0127691d30a9d4f31b684443b672 (diff)
drop yet another reimplementation of rtl::Reference (SotMutexHolderRef)
Change-Id: I57f9dff931242405420bd45fae7ec5f13718707f
Diffstat (limited to 'package/inc')
-rw-r--r--package/inc/ZipFile.hxx10
-rw-r--r--package/inc/ZipPackage.hxx4
-rw-r--r--package/inc/mutexholder.hxx86
-rw-r--r--package/inc/zipfileaccess.hxx2
4 files changed, 15 insertions, 87 deletions
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<SotMutexHolder>& 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<SotMutexHolder>& 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<SotMutexHolder>& 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<SotMutexHolder>& 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<SotMutexHolder>& 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<SotMutexHolder> 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<SotMutexHolder>& 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 <osl/mutex.hxx>
+#include <rtl/ref.hxx>
class SotMutexHolder
{
+friend class rtl::Reference<SotMutexHolder>;
+
::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<SotMutexHolder> m_aMutexHolder;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;