xpcom/glue/nsIInterfaceRequestorUtils.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/glue/nsIInterfaceRequestorUtils.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,31 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsIInterfaceRequestor.h"
    1.10 +#include "nsIInterfaceRequestorUtils.h"
    1.11 +
    1.12 +nsresult
    1.13 +nsGetInterface::operator()( const nsIID& aIID, void** aInstancePtr ) const
    1.14 +{
    1.15 +  nsresult status;
    1.16 +
    1.17 +  if ( mSource )
    1.18 +  {
    1.19 +    nsCOMPtr<nsIInterfaceRequestor> factoryPtr = do_QueryInterface(mSource, &status);
    1.20 +
    1.21 +    if ( factoryPtr )
    1.22 +      status = factoryPtr->GetInterface(aIID, aInstancePtr);
    1.23 +    else
    1.24 +      status = NS_ERROR_NO_INTERFACE;
    1.25 +  }
    1.26 +  else
    1.27 +    status = NS_ERROR_NULL_POINTER;
    1.28 +
    1.29 +  if ( NS_FAILED(status) )
    1.30 +    *aInstancePtr = 0;
    1.31 +  if ( mErrorPtr )
    1.32 +    *mErrorPtr = status;
    1.33 +  return status;
    1.34 +}

mercurial