LCOV - code coverage report
Current view: top level - ucb/source/ucp/webdav-neon - DAVSessionFactory.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 36 5.6 %
Date: 2015-06-13 12:38:46 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*************************************************************************
       3             :  *
       4             :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5             :  *
       6             :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7             :  *
       8             :  * OpenOffice.org - a multi-platform office productivity suite
       9             :  *
      10             :  * This file is part of OpenOffice.org.
      11             :  *
      12             :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13             :  * it under the terms of the GNU Lesser General Public License version 3
      14             :  * only, as published by the Free Software Foundation.
      15             :  *
      16             :  * OpenOffice.org is distributed in the hope that it will be useful,
      17             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19             :  * GNU Lesser General Public License version 3 for more details
      20             :  * (a copy is included in the LICENSE file that accompanied this code).
      21             :  *
      22             :  * You should have received a copy of the GNU Lesser General Public License
      23             :  * version 3 along with OpenOffice.org.  If not, see
      24             :  * <http://www.openoffice.org/license.html>
      25             :  * for a copy of the LGPLv3 License.
      26             :  *
      27             :  ************************************************************************/
      28             : 
      29             : #include "DAVSessionFactory.hxx"
      30             : #include "NeonSession.hxx"
      31             : #include "NeonUri.hxx"
      32             : #include <osl/diagnose.h>
      33             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      34             : 
      35             : using namespace webdav_ucp;
      36             : using namespace com::sun::star;
      37             : 
      38           4 : DAVSessionFactory::~DAVSessionFactory()
      39             : {
      40           4 : }
      41             : 
      42           0 : rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession(
      43             :                 const OUString & inUri,
      44             :                 const uno::Sequence< beans::NamedValue >& rFlags,
      45             :                 const uno::Reference< uno::XComponentContext > & rxContext )
      46             :     throw( DAVException )
      47             : {
      48           0 :     m_xContext = rxContext;
      49             : 
      50           0 :     osl::MutexGuard aGuard( m_aMutex );
      51             : 
      52           0 :     if ( !m_xProxyDecider.get() )
      53           0 :         m_xProxyDecider.reset( new ucbhelper::InternetProxyDecider( rxContext ) );
      54             : 
      55           0 :     Map::iterator aIt( m_aMap.begin() );
      56           0 :     Map::iterator aEnd( m_aMap.end() );
      57             : 
      58           0 :     while ( aIt != aEnd )
      59             :     {
      60           0 :         if ( (*aIt).second->CanUse( inUri, rFlags ) )
      61           0 :             break;
      62             : 
      63           0 :         ++aIt;
      64             :     }
      65             : 
      66           0 :     if ( aIt == aEnd )
      67             :     {
      68           0 :         NeonUri aURI( inUri );
      69             : 
      70             :         std::unique_ptr< DAVSession > xElement(
      71           0 :             new NeonSession( this, inUri, rFlags, *m_xProxyDecider.get() ) );
      72             : 
      73           0 :         aIt = m_aMap.insert( Map::value_type( inUri, xElement.get() ) ).first;
      74           0 :         aIt->second->m_aContainerIt = aIt;
      75           0 :         xElement.release();
      76           0 :         return aIt->second;
      77             :     }
      78           0 :     else if ( osl_atomic_increment( &aIt->second->m_nRefCount ) > 1 )
      79             :     {
      80           0 :         rtl::Reference< DAVSession > xElement( aIt->second );
      81           0 :         osl_atomic_decrement( &aIt->second->m_nRefCount );
      82           0 :         return xElement;
      83             :     }
      84             :     else
      85             :     {
      86           0 :         osl_atomic_decrement( &aIt->second->m_nRefCount );
      87           0 :         aIt->second->m_aContainerIt = m_aMap.end();
      88             : 
      89             :         // If URL scheme is different from http or https we definitely
      90             :         // have to use a proxy and therefore can optimize the getProxy
      91             :         // call a little:
      92           0 :         NeonUri aURI( inUri );
      93             : 
      94           0 :         aIt->second = new NeonSession( this, inUri, rFlags, *m_xProxyDecider.get() );
      95           0 :         aIt->second->m_aContainerIt = aIt;
      96           0 :         return aIt->second;
      97           0 :     }
      98             : }
      99             : 
     100           0 : void DAVSessionFactory::releaseElement( DAVSession * pElement )
     101             : {
     102             :     OSL_ASSERT( pElement );
     103           0 :     osl::MutexGuard aGuard( m_aMutex );
     104           0 :     if ( pElement->m_aContainerIt != m_aMap.end() )
     105           0 :         m_aMap.erase( pElement->m_aContainerIt );
     106           0 : }
     107             : 
     108             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11