2014-06-30 19:39:45 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2002-06-11 23:36:42 +04:00
|
|
|
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
|
|
|
|
|
|
|
nsresult
|
2014-06-27 05:35:39 +04:00
|
|
|
nsGetInterface::operator()(const nsIID& aIID, void** aInstancePtr) const
|
2002-06-11 23:36:42 +04:00
|
|
|
{
|
2005-11-06 21:31:09 +03:00
|
|
|
nsresult status;
|
2002-06-11 23:36:42 +04:00
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
if (mSource) {
|
|
|
|
nsCOMPtr<nsIInterfaceRequestor> factoryPtr = do_QueryInterface(mSource);
|
|
|
|
if (factoryPtr) {
|
2005-11-06 21:31:09 +03:00
|
|
|
status = factoryPtr->GetInterface(aIID, aInstancePtr);
|
2014-06-27 05:35:39 +04:00
|
|
|
} else {
|
2005-11-06 21:31:09 +03:00
|
|
|
status = NS_ERROR_NO_INTERFACE;
|
2014-06-27 05:35:39 +04:00
|
|
|
}
|
|
|
|
} else {
|
2005-11-06 21:31:09 +03:00
|
|
|
status = NS_ERROR_NULL_POINTER;
|
2014-06-27 05:35:39 +04:00
|
|
|
}
|
2002-06-11 23:36:42 +04:00
|
|
|
|
2014-06-27 05:35:39 +04:00
|
|
|
if (NS_FAILED(status)) {
|
2010-04-16 17:03:00 +04:00
|
|
|
*aInstancePtr = 0;
|
2014-06-27 05:35:39 +04:00
|
|
|
}
|
|
|
|
if (mErrorPtr) {
|
2005-11-06 21:31:09 +03:00
|
|
|
*mErrorPtr = status;
|
2014-06-27 05:35:39 +04:00
|
|
|
}
|
2005-11-06 21:31:09 +03:00
|
|
|
return status;
|
2002-06-11 23:36:42 +04:00
|
|
|
}
|