summaryrefslogtreecommitdiff
path: root/ucbhelper/source/client/content.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-05-05 22:50:16 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-06 20:57:08 +0200
commit9d0a8f7a2e3e473ebb3042f90dd82696dd8705da (patch)
tree25f42587e714bc4f8ba5e7852682a65bc931bd67 /ucbhelper/source/client/content.cxx
parent738b8f09c52a0e0234842c622786fccbb027621b (diff)
osl::Mutex->std::mutex in Content_Impl
Change-Id: I5e3983958629ac732c031b9b59e96deaac63e7ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133913 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucbhelper/source/client/content.cxx')
-rw-r--r--ucbhelper/source/client/content.cxx91
1 files changed, 52 insertions, 39 deletions
diff --git a/ucbhelper/source/client/content.cxx b/ucbhelper/source/client/content.cxx
index dfe2a9103add..948c4848c6f4 100644
--- a/ucbhelper/source/client/content.cxx
+++ b/ucbhelper/source/client/content.cxx
@@ -23,7 +23,7 @@
#include <o3tl/unreachable.hxx>
#include <osl/diagnose.h>
-#include <osl/mutex.hxx>
+#include <mutex>
#include <sal/log.hxx>
#include <salhelper/simplereferenceobject.hxx>
#include <cppuhelper/weak.hxx>
@@ -159,11 +159,13 @@ friend ContentEventListener_Impl;
Reference< XCommandProcessor > m_xCommandProcessor;
Reference< XCommandEnvironment > m_xEnv;
Reference< XContentEventListener > m_xContentEventListener;
- mutable osl::Mutex m_aMutex;
+ mutable std::mutex m_aMutex;
private:
void reinit( const Reference< XContent >& xContent );
void disposing(const EventObject& Source);
+ Reference< XContent > getContent_NoLock();
+ const OUString& getURL_NoLock() const;
public:
Content_Impl() {};
@@ -1089,7 +1091,7 @@ Content_Impl::Content_Impl( const Reference< XComponentContext >& rCtx,
void Content_Impl::reinit( const Reference< XContent >& xContent )
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
m_xCommandProcessor = nullptr;
@@ -1114,14 +1116,14 @@ void Content_Impl::reinit( const Reference< XContent >& xContent )
#if OSL_DEBUG_LEVEL > 0
// Only done on demand in product version for performance reasons,
// but a nice debug helper.
- getURL();
+ getURL_NoLock();
#endif
}
else
{
// We need m_xContent's URL in order to be able to create the
// content object again if demanded ( --> Content_Impl::getContent() )
- getURL();
+ getURL_NoLock();
m_xContent = nullptr;
}
@@ -1149,7 +1151,7 @@ void Content_Impl::disposing( const EventObject& Source )
Reference<XContent> xContent;
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
if(Source.Source != m_xContent)
return;
@@ -1177,53 +1179,64 @@ const OUString& Content_Impl::getURL() const
{
if ( m_aURL.isEmpty() && m_xContent.is() )
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
- if ( m_aURL.isEmpty() && m_xContent.is() )
- {
- Reference< XContentIdentifier > xId = m_xContent->getIdentifier();
- if ( xId.is() )
- m_aURL = xId->getContentIdentifier();
- }
+ return getURL_NoLock();
}
return m_aURL;
}
+const OUString& Content_Impl::getURL_NoLock() const
+{
+ if ( m_aURL.isEmpty() && m_xContent.is() )
+ {
+ Reference< XContentIdentifier > xId = m_xContent->getIdentifier();
+ if ( xId.is() )
+ m_aURL = xId->getContentIdentifier();
+ }
+
+ return m_aURL;
+}
Reference< XContent > Content_Impl::getContent()
{
if ( !m_xContent.is() && !m_aURL.isEmpty() )
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
+ return getContent_NoLock();
+ }
+ return m_xContent;
+}
- if ( !m_xContent.is() && !m_aURL.isEmpty() )
- {
- Reference< XUniversalContentBroker > pBroker(
- UniversalContentBroker::create( getComponentContext() ) );
+Reference< XContent > Content_Impl::getContent_NoLock()
+{
+ if ( !m_xContent.is() && !m_aURL.isEmpty() )
+ {
+ Reference< XUniversalContentBroker > pBroker(
+ UniversalContentBroker::create( getComponentContext() ) );
- OSL_ENSURE( pBroker->queryContentProviders().hasElements(),
- "Content Broker not configured (no providers)!" );
+ OSL_ENSURE( pBroker->queryContentProviders().hasElements(),
+ "Content Broker not configured (no providers)!" );
- Reference< XContentIdentifier > xId
- = pBroker->createContentIdentifier( m_aURL );
+ Reference< XContentIdentifier > xId
+ = pBroker->createContentIdentifier( m_aURL );
- OSL_ENSURE( xId.is(), "No Content Identifier!" );
+ OSL_ENSURE( xId.is(), "No Content Identifier!" );
- if ( xId.is() )
+ if ( xId.is() )
+ {
+ try
{
- try
- {
- m_xContent = pBroker->queryContent( xId );
- }
- catch ( IllegalIdentifierException const & )
- {
- }
-
- if ( m_xContent.is() )
- m_xContent->addContentEventListener(
- m_xContentEventListener );
+ m_xContent = pBroker->queryContent( xId );
}
+ catch ( IllegalIdentifierException const & )
+ {
+ }
+
+ if ( m_xContent.is() )
+ m_xContent->addContentEventListener(
+ m_xContentEventListener );
}
}
@@ -1235,10 +1248,10 @@ Reference< XCommandProcessor > Content_Impl::getCommandProcessor()
{
if ( !m_xCommandProcessor.is() )
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
if ( !m_xCommandProcessor.is() )
- m_xCommandProcessor.set( getContent(), UNO_QUERY );
+ m_xCommandProcessor.set( getContent_NoLock(), UNO_QUERY );
}
return m_xCommandProcessor;
@@ -1266,7 +1279,7 @@ inline const Reference< XCommandEnvironment >&
inline void Content_Impl::setEnvironment(
const Reference< XCommandEnvironment >& xNewEnv )
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
m_xEnv = xNewEnv;
}
@@ -1274,7 +1287,7 @@ inline void Content_Impl::setEnvironment(
void Content_Impl::inserted()
{
// URL might have changed during 'insert' => recalculate in next getURL()
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
m_aURL.clear();
}