diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2017-01-16 15:33:37 -0500 |
---|---|---|
committer | Kohei Yoshida <libreoffice@kohei.us> | 2017-01-17 02:05:54 +0000 |
commit | 294f2e627cc6f1d0483f7affcf96467a4bd3ba5a (patch) | |
tree | 5e1b443cbeca677470e32d909fe5c7eb9ed61ee6 /package/source | |
parent | ac2105e77795970e9131092caae78fd42c86f6d9 (diff) |
tdf#97597: attempt to add test for multithreaded input stream buffering.
But it always passes, even when UseBufferedStream is set to false...
Needs improvement.
Change-Id: I98f65dcd7bec3b47a437fdc6cc42c6e8e3775522
Reviewed-on: https://gerrit.libreoffice.org/33190
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
Diffstat (limited to 'package/source')
-rw-r--r-- | package/source/zippackage/zipfileaccess.cxx | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx index 88ac19c7dc01..b6875eee9e23 100644 --- a/package/source/zippackage/zipfileaccess.cxx +++ b/package/source/zippackage/zipfileaccess.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/io/XActiveDataSink.hpp> #include <com/sun/star/io/XStream.hpp> #include <com/sun/star/io/XSeekable.hpp> +#include <com/sun/star/beans/NamedValue.hpp> #include <comphelper/processfactory.hxx> #include <cppuhelper/supportsservice.hxx> #include <zipfileaccess.hxx> @@ -182,8 +183,11 @@ void SAL_CALL OZipFileAccess::initialize( const uno::Sequence< uno::Any >& aArgu OUString aParamURL; uno::Reference< io::XStream > xStream; uno::Reference< io::XSeekable > xSeekable; + uno::Sequence<beans::NamedValue> aArgs; - if ( ( aArguments[0] >>= aParamURL ) ) + bool bUseBufferedStream = false; + + auto openInputStream = [&]() { ::ucbhelper::Content aContent( aParamURL, @@ -196,6 +200,11 @@ void SAL_CALL OZipFileAccess::initialize( const uno::Sequence< uno::Any >& aArgu m_bOwnContent = true; xSeekable.set( m_xContentStream, uno::UNO_QUERY ); } + }; + + if ( ( aArguments[0] >>= aParamURL ) ) + { + openInputStream(); } else if ( (aArguments[0] >>= xStream ) ) { @@ -207,6 +216,25 @@ void SAL_CALL OZipFileAccess::initialize( const uno::Sequence< uno::Any >& aArgu { xSeekable.set( m_xContentStream, uno::UNO_QUERY ); } + else if (aArguments[0] >>= aArgs) + { + for (sal_Int32 i = 0; i < aArgs.getLength(); ++i) + { + const beans::NamedValue& rArg = aArgs[i]; + + if (rArg.Name == "URL") + rArg.Value >>= aParamURL; + else if (rArg.Name == "UseBufferedStream") + rArg.Value >>= bUseBufferedStream; + } + + if (aParamURL.isEmpty()) + throw lang::IllegalArgumentException( + THROW_WHERE"required argument 'URL' is not given or invalid.", + uno::Reference<uno::XInterface>(), 1); + + openInputStream(); + } else throw lang::IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 1 ); @@ -224,6 +252,8 @@ void SAL_CALL OZipFileAccess::initialize( const uno::Sequence< uno::Any >& aArgu m_xContentStream, m_xContext, true ); + + m_pZipFile->setUseBufferedStream(bUseBufferedStream); } // XNameAccess |